diff --git a/src/routes/guilds/#guild_id/channels.ts b/src/routes/guilds/#guild_id/channels.ts
index 73982ed5..9e8d3506 100644
--- a/src/routes/guilds/#guild_id/channels.ts
+++ b/src/routes/guilds/#guild_id/channels.ts
@@ -16,9 +16,11 @@ router.get("/", async (req, res) => {
router.post("/", check(ChannelModifySchema), async (req, res) => {
const { guild_id } = req.params;
const body = req.body as ChannelModifySchema;
+
if (!body.permission_overwrites) body.permission_overwrites = [];
if (!body.topic) body.topic = "";
if (!body.rate_limit_per_user) body.rate_limit_per_user = 0;
+
switch (body.type) {
case ChannelType.DM:
case ChannelType.GROUP_DM:
@@ -31,9 +33,9 @@ router.post("/", check(ChannelModifySchema), async (req, res) => {
}
if (body.parent_id) {
- const exists = await ChannelModel.findOne({ id: body.parent_id }, {guild_id:true}).exec();
+ const exists = await ChannelModel.findOne({ id: body.parent_id }, { guild_id: true }).exec();
if (!exists) throw new HTTPError("Parent id channel doesn't exist", 400);
- if (exists.guild_id !== guild_id) throw new HTTPError("The category channel needs to be in the guild")
+ if (exists.guild_id !== guild_id) throw new HTTPError("The category channel needs to be in the guild");
}
const guild = await GuildModel.findOne({ id: guild_id }, { id: true }).exec();
@@ -43,8 +45,9 @@ router.post("/", check(ChannelModifySchema), async (req, res) => {
...body,
id: Snowflake.generate(),
created_at: new Date(),
- guild_id,
+ guild_id
};
+
await new ChannelModel(channel).save();
await emitEvent({ event: "CHANNEL_CREATE", data: channel, guild_id } as ChannelCreateEvent);
@@ -63,7 +66,7 @@ router.patch("/", check(ChannelModifySchema), async (req, res) => {
...body
};
const channelm = await ChannelModel.find({ guild_id }).exec();
- if(!channelm) throw new HTTPError("Channel not found", 404);
+ if (!channelm) throw new HTTPError("Channel not found", 404);
await new ChannelModel(channel).save();
diff --git a/src/routes/guilds/index.ts b/src/routes/guilds/index.ts
index 176e4e69..1ed9d0ff 100644
--- a/src/routes/guilds/index.ts
+++ b/src/routes/guilds/index.ts
@@ -58,10 +58,10 @@ router.post("/", check(GuildCreateSchema), async (req: Request, res: Response) =
welcome_screen: {
enabled: false,
description: "No description",
- welcome_channels: [],
+ welcome_channels: []
},
widget_channel_id: undefined,
- widget_enabled: false,
+ widget_enabled: false
};
const [guild_doc, role] = await Promise.all([
@@ -71,13 +71,13 @@ router.post("/", check(GuildCreateSchema), async (req: Request, res: Response) =
guild_id: guild_id,
color: 0,
hoist: false,
- managed: true,
- mentionable: true,
+ managed: false,
+ mentionable: false,
name: "@everyone",
permissions: 2251804225n,
position: 0,
- tags: null,
- }).save(),
+ tags: null
+ }).save()
]);
await addMember(req.user_id, guild_id, { guild: guild_doc });
|