summary refs log tree commit diff
path: root/api/src/routes/guilds
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/routes/guilds')
-rw-r--r--api/src/routes/guilds/#guild_id/bans.ts6
-rw-r--r--api/src/routes/guilds/#guild_id/channels.ts4
-rw-r--r--api/src/routes/guilds/#guild_id/emojis.ts10
-rw-r--r--api/src/routes/guilds/#guild_id/index.ts4
-rw-r--r--api/src/routes/guilds/#guild_id/members/#member_id/index.ts4
-rw-r--r--api/src/routes/guilds/#guild_id/prune.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/regions.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/roles/#role_id/index.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/roles/index.ts4
-rw-r--r--api/src/routes/guilds/#guild_id/stickers.ts6
-rw-r--r--api/src/routes/guilds/#guild_id/templates.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/vanity-url.ts10
-rw-r--r--api/src/routes/guilds/#guild_id/voice-states/#user_id/index.ts10
-rw-r--r--api/src/routes/guilds/#guild_id/welcome_screen.ts4
-rw-r--r--api/src/routes/guilds/#guild_id/widget.json.ts4
-rw-r--r--api/src/routes/guilds/#guild_id/widget.png.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/widget.ts2
-rw-r--r--api/src/routes/guilds/index.ts2
-rw-r--r--api/src/routes/guilds/templates/index.ts6
19 files changed, 44 insertions, 42 deletions
diff --git a/api/src/routes/guilds/#guild_id/bans.ts b/api/src/routes/guilds/#guild_id/bans.ts
index eb38de0d..128ff250 100644
--- a/api/src/routes/guilds/#guild_id/bans.ts
+++ b/api/src/routes/guilds/#guild_id/bans.ts
@@ -32,7 +32,7 @@ const router: Router = Router();
 router.get("/", route({ permission: "BAN_MEMBERS" }), async (req: Request, res: Response) => {
 	const { guild_id } = req.params;
 
-	let bans = await Ban.find({ guild_id: guild_id });
+	let bans = await Ban.find({ where: { guild_id } });
 	let promisesToAwait: object[] = [];
 	const bansObj: object[] = [];
 
@@ -65,7 +65,7 @@ router.get("/:user", route({ permission: "BAN_MEMBERS" }), async (req: Request,
 	const { guild_id } = req.params;
 	const user_id = req.params.ban;
 
-	let ban = await Ban.findOneOrFail({ guild_id: guild_id, user_id: user_id }) as BanRegistrySchema;
+	let ban = await Ban.findOneOrFail({ where: { guild_id, user_id } }) as BanRegistrySchema;
 	
 	if (ban.user_id === ban.executor_id) throw DiscordApiErrors.UNKNOWN_BAN;
 	// pretend self-bans don't exist to prevent victim chasing
@@ -149,7 +149,7 @@ router.put("/@me", route({ body: "BanCreateSchema"}), async (req: Request, res:
 router.delete("/:user_id", route({ permission: "BAN_MEMBERS" }), async (req: Request, res: Response) => {
 	const { guild_id, user_id } = req.params;
 
-	let ban = await Ban.findOneOrFail({ guild_id: guild_id, user_id: user_id });
+	let ban = await Ban.findOneOrFail({ where: { guild_id, user_id } });
 	
 	if (ban.user_id === ban.executor_id) throw DiscordApiErrors.UNKNOWN_BAN;
 	// make self-bans irreversible and hide them from view to avoid victim chasing
diff --git a/api/src/routes/guilds/#guild_id/channels.ts b/api/src/routes/guilds/#guild_id/channels.ts
index e3c6b8bd..b952b474 100644
--- a/api/src/routes/guilds/#guild_id/channels.ts
+++ b/api/src/routes/guilds/#guild_id/channels.ts
@@ -7,7 +7,7 @@ const router = Router();
 
 router.get("/", route({}), async (req: Request, res: Response) => {
 	const { guild_id } = req.params;
-	const channels = await Channel.find({ guild_id });
+	const channels = await Channel.find({ where: { guild_id } });
 
 	res.json(channels);
 });
@@ -48,7 +48,7 @@ router.patch("/", route({ body: "ChannelReorderSchema", permission: "MANAGE_CHAN
 			}
 
 			await Channel.update({ guild_id, id: x.id }, opts);
-			const channel = await Channel.findOneOrFail({ guild_id, id: x.id });
+			const channel = await Channel.findOneOrFail({ where: { guild_id, id: x.id } });
 
 			await emitEvent({ event: "CHANNEL_UPDATE", data: channel, channel_id: x.id, guild_id } as ChannelUpdateEvent);
 		})
diff --git a/api/src/routes/guilds/#guild_id/emojis.ts b/api/src/routes/guilds/#guild_id/emojis.ts
index 85d7ac05..c4bcadf7 100644
--- a/api/src/routes/guilds/#guild_id/emojis.ts
+++ b/api/src/routes/guilds/#guild_id/emojis.ts
@@ -41,13 +41,13 @@ router.post("/", route({ body: "EmojiCreateSchema", permission: "MANAGE_EMOJIS_A
 	const body = req.body as EmojiCreateSchema;
 
 	const id = Snowflake.generate();
-	const emoji_count = await Emoji.count({ guild_id: guild_id });
+	const emoji_count = await Emoji.count({ where: { guild_id } });
 	const { maxEmojis } = Config.get().limits.guild;
 
 	if (emoji_count >= maxEmojis) throw DiscordApiErrors.MAXIMUM_NUMBER_OF_EMOJIS_REACHED.withParams(maxEmojis);
 	if (body.require_colons == null) body.require_colons = true;
 
-	const user = await User.findOneOrFail({ id: req.user_id });
+	const user = await User.findOneOrFail({ where: { id: req.user_id } });
 	body.image = (await handleFile(`/emojis/${id}`, body.image)) as string;
 
 	const emoji = await new Emoji({
@@ -66,7 +66,7 @@ router.post("/", route({ body: "EmojiCreateSchema", permission: "MANAGE_EMOJIS_A
 		guild_id: guild_id,
 		data: {
 			guild_id: guild_id,
-			emojis: await Emoji.find({ guild_id: guild_id })
+			emojis: await Emoji.find({ where: { guild_id } })
 		}
 	} as GuildEmojisUpdateEvent);
 
@@ -87,7 +87,7 @@ router.patch(
 			guild_id: guild_id,
 			data: {
 				guild_id: guild_id,
-				emojis: await Emoji.find({ guild_id: guild_id })
+				emojis: await Emoji.find({ where: { guild_id } })
 			}
 		} as GuildEmojisUpdateEvent);
 
@@ -108,7 +108,7 @@ router.delete("/:emoji_id", route({ permission: "MANAGE_EMOJIS_AND_STICKERS" }),
 		guild_id: guild_id,
 		data: {
 			guild_id: guild_id,
-			emojis: await Emoji.find({ guild_id: guild_id })
+			emojis: await Emoji.find({ where: { guild_id } })
 		}
 	} as GuildEmojisUpdateEvent);
 
diff --git a/api/src/routes/guilds/#guild_id/index.ts b/api/src/routes/guilds/#guild_id/index.ts
index d9c8f13b..2d748d61 100644
--- a/api/src/routes/guilds/#guild_id/index.ts
+++ b/api/src/routes/guilds/#guild_id/index.ts
@@ -26,8 +26,8 @@ router.get("/", route({}), async (req: Request, res: Response) => {
 	const { guild_id } = req.params;
 
 	const [guild, member] = await Promise.all([
-		Guild.findOneOrFail({ id: guild_id }),
-		Member.findOne({ guild_id: guild_id, id: req.user_id })
+		Guild.findOneOrFail({ where: { id: guild_id } }),
+		Member.findOne({ where: { guild_id, id: req.user_id } })
 	]);
 	if (!member) throw new HTTPError("You are not a member of the guild you are trying to access", 401);
 
diff --git a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts
index e4a060d6..2717ec2a 100644
--- a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts
+++ b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts
@@ -13,7 +13,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
 	const { guild_id, member_id } = req.params;
 	await Member.IsInGuildOrFail(req.user_id, guild_id);
 
-	const member = await Member.findOneOrFail({ id: member_id, guild_id });
+	const member = await Member.findOneOrFail({ where: { id: member_id, guild_id } });
 
 	return res.json(member);
 });
@@ -25,7 +25,7 @@ router.patch("/", route({ body: "MemberChangeSchema" }), async (req: Request, re
 
 	const member = await Member.findOneOrFail({ where: { id: member_id, guild_id }, relations: ["roles", "user"] });
 	const permission = await getPermission(req.user_id, guild_id);
-	const everyone = await Role.findOneOrFail({ guild_id: guild_id, name: "@everyone", position: 0 });
+	const everyone = await Role.findOneOrFail({ where: { guild_id: guild_id, name: "@everyone", position: 0 } });
 
 	if (body.roles) {
 		permission.hasThrow("MANAGE_ROLES");
diff --git a/api/src/routes/guilds/#guild_id/prune.ts b/api/src/routes/guilds/#guild_id/prune.ts
index efaad580..01f18ce4 100644
--- a/api/src/routes/guilds/#guild_id/prune.ts
+++ b/api/src/routes/guilds/#guild_id/prune.ts
@@ -33,7 +33,7 @@ export const inactiveMembers = async (guild_id: string, user_id: string, days: n
 	//I'm sure I can do this in the above db query ( and it would probably be better to do so ), but oh well.
 	if (roles.length && members.length) members = members.filter((user) => user.roles?.some((role) => roles.includes(role.id)));
 
-	const me = await Member.findOneOrFail({ id: user_id, guild_id }, { relations: ["roles"] });
+	const me = await Member.findOneOrFail({ where: { id: user_id, guild_id }, relations: ["roles"] });
 	const myHighestRole = Math.max(...(me.roles?.map((x) => x.position) || []));
 
 	const guild = await Guild.findOneOrFail({ where: { id: guild_id } });
diff --git a/api/src/routes/guilds/#guild_id/regions.ts b/api/src/routes/guilds/#guild_id/regions.ts
index 75d24fd1..308d5ee5 100644
--- a/api/src/routes/guilds/#guild_id/regions.ts
+++ b/api/src/routes/guilds/#guild_id/regions.ts
@@ -7,7 +7,7 @@ const router = Router();
 
 router.get("/", route({}), async (req: Request, res: Response) => {
 	const { guild_id } = req.params;
-	const guild = await Guild.findOneOrFail({ id: guild_id });
+	const guild = await Guild.findOneOrFail({ where: { id: guild_id } });
 	//TODO we should use an enum for guild's features and not hardcoded strings
 	return res.json(await getVoiceRegions(getIpAdress(req), guild.features.includes("VIP_REGIONS")));
 });
diff --git a/api/src/routes/guilds/#guild_id/roles/#role_id/index.ts b/api/src/routes/guilds/#guild_id/roles/#role_id/index.ts
index 7efc5382..af04fd06 100644
--- a/api/src/routes/guilds/#guild_id/roles/#role_id/index.ts
+++ b/api/src/routes/guilds/#guild_id/roles/#role_id/index.ts
@@ -9,7 +9,7 @@ const router = Router();
 router.get("/", route({}), async (req: Request, res: Response) => {
 	const { guild_id, role_id } = req.params;
 	await Member.IsInGuildOrFail(req.user_id, guild_id);
-	const role = await Role.findOneOrFail({ guild_id, id: role_id });
+	const role = await Role.findOneOrFail({ where: { guild_id, id: role_id } });
 	return res.json(role);
 });
 
diff --git a/api/src/routes/guilds/#guild_id/roles/index.ts b/api/src/routes/guilds/#guild_id/roles/index.ts
index 2f5141b8..d2d14122 100644
--- a/api/src/routes/guilds/#guild_id/roles/index.ts
+++ b/api/src/routes/guilds/#guild_id/roles/index.ts
@@ -37,7 +37,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
 
 	await Member.IsInGuildOrFail(req.user_id, guild_id);
 
-	const roles = await Role.find({ guild_id: guild_id });
+	const roles = await Role.find({ where: { guild_id } });
 
 	return res.json(roles);
 });
@@ -46,7 +46,7 @@ router.post("/", route({ body: "RoleModifySchema", permission: "MANAGE_ROLES" })
 	const guild_id = req.params.guild_id;
 	const body = req.body as RoleModifySchema;
 
-	const role_count = await Role.count({ guild_id });
+	const role_count = await Role.count({ where: { guild_id } });
 	const { maxRoles } = Config.get().limits.guild;
 
 	if (role_count > maxRoles) throw DiscordApiErrors.MAXIMUM_ROLES.withParams(maxRoles);
diff --git a/api/src/routes/guilds/#guild_id/stickers.ts b/api/src/routes/guilds/#guild_id/stickers.ts
index bfc46291..7913539b 100644
--- a/api/src/routes/guilds/#guild_id/stickers.ts
+++ b/api/src/routes/guilds/#guild_id/stickers.ts
@@ -19,7 +19,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
 	const { guild_id } = req.params;
 	await Member.IsInGuildOrFail(req.user_id, guild_id);
 
-	res.json(await Sticker.find({ guild_id }));
+	res.json(await Sticker.find({ where: { guild_id } }));
 });
 
 const bodyParser = multer({
@@ -79,7 +79,7 @@ router.get("/:sticker_id", route({}), async (req: Request, res: Response) => {
 	const { guild_id, sticker_id } = req.params;
 	await Member.IsInGuildOrFail(req.user_id, guild_id);
 
-	res.json(await Sticker.findOneOrFail({ guild_id, id: sticker_id }));
+	res.json(await Sticker.findOneOrFail({ where: { guild_id, id: sticker_id } }));
 });
 
 export interface ModifyGuildStickerSchema {
@@ -118,7 +118,7 @@ async function sendStickerUpdateEvent(guild_id: string) {
 		guild_id: guild_id,
 		data: {
 			guild_id: guild_id,
-			stickers: await Sticker.find({ guild_id: guild_id })
+			stickers: await Sticker.find({ where: { guild_id } })
 		}
 	} as GuildStickersUpdateEvent);
 }
diff --git a/api/src/routes/guilds/#guild_id/templates.ts b/api/src/routes/guilds/#guild_id/templates.ts
index 7e411907..f2de46e4 100644
--- a/api/src/routes/guilds/#guild_id/templates.ts
+++ b/api/src/routes/guilds/#guild_id/templates.ts
@@ -44,7 +44,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
 router.post("/", route({ body: "TemplateCreateSchema", permission: "MANAGE_GUILD" }), async (req: Request, res: Response) => {
 	const { guild_id } = req.params;
 	const guild = await Guild.findOneOrFail({ where: { id: guild_id }, select: TemplateGuildProjection });
-	const exists = await Template.findOneOrFail({ id: guild_id }).catch((e) => {});
+	const exists = await Template.findOneOrFail({ where: { id: guild_id } }).catch((e) => {});
 	if (exists) throw new HTTPError("Template already exists", 400);
 
 	const template = await new Template({
diff --git a/api/src/routes/guilds/#guild_id/vanity-url.ts b/api/src/routes/guilds/#guild_id/vanity-url.ts
index e841b8b3..b4d9f618 100644
--- a/api/src/routes/guilds/#guild_id/vanity-url.ts
+++ b/api/src/routes/guilds/#guild_id/vanity-url.ts
@@ -9,7 +9,7 @@ const InviteRegex = /\W/g;
 
 router.get("/", route({ permission: "MANAGE_GUILD" }), async (req: Request, res: Response) => {
 	const { guild_id } = req.params;
-	const guild = await Guild.findOneOrFail({ id: guild_id });
+	const guild = await Guild.findOneOrFail({ where: { id: guild_id } });
 
 	if (!guild.features.includes("ALIASABLE_NAMES")) {
 		const invite = await Invite.findOne({ where: { guild_id: guild_id, vanity_url: true } });
@@ -37,15 +37,15 @@ router.patch("/", route({ body: "VanityUrlSchema", permission: "MANAGE_GUILD" })
 	const body = req.body as VanityUrlSchema;
 	const code = body.code?.replace(InviteRegex, "");
 
-	const guild = await Guild.findOneOrFail({ id: guild_id });
+	const guild = await Guild.findOneOrFail({ where: { id: guild_id } });
 	if (!guild.features.includes("VANITY_URL")) throw new HTTPError("Your guild doesn't support vanity urls");
 
 	if (!code || code.length === 0) throw new HTTPError("Code cannot be null or empty");
 
-	const invite = await Invite.findOne({ code });
+	const invite = await Invite.findOne({ where: { code } });
 	if (invite) throw new HTTPError("Invite already exists");
 
-	const { id } = await Channel.findOneOrFail({ guild_id, type: ChannelType.GUILD_TEXT });
+	const { id } = await Channel.findOneOrFail({ where: { guild_id, type: ChannelType.GUILD_TEXT } });
 
 	await new Invite({
 		vanity_url: true,
@@ -60,7 +60,7 @@ router.patch("/", route({ body: "VanityUrlSchema", permission: "MANAGE_GUILD" })
 		channel_id: id
 	}).save();
 
-	return res.json({ code: code });
+	return res.json({ where: { code } });
 });
 
 export default router;
diff --git a/api/src/routes/guilds/#guild_id/voice-states/#user_id/index.ts b/api/src/routes/guilds/#guild_id/voice-states/#user_id/index.ts
index 392b002f..37ea52b5 100644
--- a/api/src/routes/guilds/#guild_id/voice-states/#user_id/index.ts
+++ b/api/src/routes/guilds/#guild_id/voice-states/#user_id/index.ts
@@ -34,14 +34,16 @@ router.patch("/", route({ body: "VoiceStateUpdateSchema" }), async (req: Request
 	if (body.request_to_speak_timestamp) perms.hasThrow("REQUEST_TO_SPEAK");
 
 	const voice_state = await VoiceState.findOne({
-		guild_id,
-		channel_id: body.channel_id,
-		user_id
+		where: {
+			guild_id,
+			channel_id: body.channel_id,
+			user_id
+		}
 	});
 	if (!voice_state) throw DiscordApiErrors.UNKNOWN_VOICE_STATE;
 
 	voice_state.assign(body);
-	const channel = await Channel.findOneOrFail({ guild_id, id: body.channel_id });
+	const channel = await Channel.findOneOrFail({ where: { guild_id, id: body.channel_id } });
 	if (channel.type !== ChannelType.GUILD_STAGE_VOICE) {
 		throw DiscordApiErrors.CANNOT_EXECUTE_ON_THIS_CHANNEL_TYPE;
 	}
diff --git a/api/src/routes/guilds/#guild_id/welcome_screen.ts b/api/src/routes/guilds/#guild_id/welcome_screen.ts
index ab125131..4093ec1d 100644
--- a/api/src/routes/guilds/#guild_id/welcome_screen.ts
+++ b/api/src/routes/guilds/#guild_id/welcome_screen.ts
@@ -19,7 +19,7 @@ export interface GuildUpdateWelcomeScreenSchema {
 router.get("/", route({}), async (req: Request, res: Response) => {
 	const guild_id = req.params.guild_id;
 
-	const guild = await Guild.findOneOrFail({ id: guild_id });
+	const guild = await Guild.findOneOrFail({ where: { id: guild_id } });
 	await Member.IsInGuildOrFail(req.user_id, guild_id);
 
 	res.json(guild.welcome_screen);
@@ -29,7 +29,7 @@ router.patch("/", route({ body: "GuildUpdateWelcomeScreenSchema", permission: "M
 	const guild_id = req.params.guild_id;
 	const body = req.body as GuildUpdateWelcomeScreenSchema;
 
-	const guild = await Guild.findOneOrFail({ id: guild_id });
+	const guild = await Guild.findOneOrFail({ where: { id: guild_id } });
 
 	if (!guild.welcome_screen.enabled) throw new HTTPError("Welcome screen disabled", 400);
 	if (body.welcome_channels) guild.welcome_screen.welcome_channels = body.welcome_channels; // TODO: check if they exist and are valid
diff --git a/api/src/routes/guilds/#guild_id/widget.json.ts b/api/src/routes/guilds/#guild_id/widget.json.ts
index 97f3c303..b7a93a46 100644
--- a/api/src/routes/guilds/#guild_id/widget.json.ts
+++ b/api/src/routes/guilds/#guild_id/widget.json.ts
@@ -17,7 +17,7 @@ const router: Router = Router();
 router.get("/", route({}), async (req: Request, res: Response) => {
 	const { guild_id } = req.params;
 
-	const guild = await Guild.findOneOrFail({ id: guild_id });
+	const guild = await Guild.findOneOrFail({ where: { id: guild_id } });
 	if (!guild.widget_enabled) throw new HTTPError("Widget Disabled", 404);
 
 	// Fetch existing widget invite for widget channel
@@ -63,7 +63,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
 
 	// Fetch members
 	// TODO: Understand how Discord's max 100 random member sample works, and apply to here (see top of this file)
-	let members = await Member.find({ guild_id: guild_id });
+	let members = await Member.find({ where: { guild_id } });
 
 	// Construct object to respond with
 	const data = {
diff --git a/api/src/routes/guilds/#guild_id/widget.png.ts b/api/src/routes/guilds/#guild_id/widget.png.ts
index 4298d0fe..ec0ac85c 100644
--- a/api/src/routes/guilds/#guild_id/widget.png.ts
+++ b/api/src/routes/guilds/#guild_id/widget.png.ts
@@ -14,7 +14,7 @@ const router: Router = Router();
 router.get("/", route({}), async (req: Request, res: Response) => {
 	const { guild_id } = req.params;
 
-	const guild = await Guild.findOneOrFail({ id: guild_id });
+	const guild = await Guild.findOneOrFail({ where: { id: guild_id } });
 	if (!guild.widget_enabled) throw new HTTPError("Unknown Guild", 404);
 
 	// Fetch guild information
diff --git a/api/src/routes/guilds/#guild_id/widget.ts b/api/src/routes/guilds/#guild_id/widget.ts
index 2640618d..103f84a3 100644
--- a/api/src/routes/guilds/#guild_id/widget.ts
+++ b/api/src/routes/guilds/#guild_id/widget.ts
@@ -13,7 +13,7 @@ const router: Router = Router();
 router.get("/", route({}), async (req: Request, res: Response) => {
 	const { guild_id } = req.params;
 
-	const guild = await Guild.findOneOrFail({ id: guild_id });
+	const guild = await Guild.findOneOrFail({ where: { id: guild_id } });
 
 	return res.json({ enabled: guild.widget_enabled || false, channel_id: guild.widget_channel_id || null });
 });
diff --git a/api/src/routes/guilds/index.ts b/api/src/routes/guilds/index.ts
index 10721413..64b9454b 100644
--- a/api/src/routes/guilds/index.ts
+++ b/api/src/routes/guilds/index.ts
@@ -24,7 +24,7 @@ router.post("/", route({ body: "GuildCreateSchema", right: "CREATE_GUILDS" }), a
 	const body = req.body as GuildCreateSchema;
 
 	const { maxGuilds } = Config.get().limits.user;
-	const guild_count = await Member.count({ id: req.user_id });
+	const guild_count = await Member.count({ where: { id: req.user_id } });
 	const rights = await getRights(req.user_id);
 	if ((guild_count >= maxGuilds)&&!rights.has("MANAGE_GUILDS")) {
 		throw DiscordApiErrors.MAXIMUM_GUILDS.withParams(maxGuilds);
diff --git a/api/src/routes/guilds/templates/index.ts b/api/src/routes/guilds/templates/index.ts
index 3d922e85..e2242ebf 100644
--- a/api/src/routes/guilds/templates/index.ts
+++ b/api/src/routes/guilds/templates/index.ts
@@ -33,7 +33,7 @@ router.get("/:code", route({}), async (req: Request, res: Response) => {
 		return res.json(code.split("external:", 2)[1]);
 	}
 
-	const template = await Template.findOneOrFail({ code: code });
+	const template = await Template.findOneOrFail({ where: { code } });
 	res.json(template);
 });
 
@@ -47,12 +47,12 @@ router.post("/:code", route({ body: "GuildTemplateCreateSchema" }), async (req:
 
 	const { maxGuilds } = Config.get().limits.user;
 
-	const guild_count = await Member.count({ id: req.user_id });
+	const guild_count = await Member.count({ where: { id: req.user_id } });
 	if (guild_count >= maxGuilds) {
 		throw DiscordApiErrors.MAXIMUM_GUILDS.withParams(maxGuilds);
 	}
 
-	const template = await Template.findOneOrFail({ code: code });
+	const template = await Template.findOneOrFail({ where: { code } });
 
 	const guild_id = Snowflake.generate();