summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-03-14 03:31:39 +0100
committerRory& <root@rory.gay>2026-03-14 03:31:39 +0100
commitc882be526707863f045357a3f074c3867e25d231 (patch)
treee9c3455601221a3a4e794a53b81eb75782ccee23
parentQodana: fix async warnings (diff)
downloadserver-ts-c882be526707863f045357a3f074c3867e25d231.tar.xz
Use plain assignment for permissions in message handler
-rw-r--r--src/api/util/handlers/Message.ts4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts

index a95f38c0..5ec13dd6 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts
@@ -65,14 +65,14 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> { }); if (!channel || !opts.channel_id) throw new HTTPError("Channel not found", 404); - let permission: undefined | Permissions; + let permission: null | Permissions = null; const limit = channel.rate_limit_per_user; if (limit) { const lastMsgTime = (await Message.findOne({ where: { channel_id: channel.id, author_id: opts.author_id }, select: { timestamp: true }, order: { timestamp: "DESC" } })) ?.timestamp; if (lastMsgTime && Date.now() - limit * 1000 < +lastMsgTime) { - permission ||= await getPermission(opts.author_id, channel.guild_id, channel); + permission = await getPermission(opts.author_id, channel.guild_id, channel); //FIXME MANAGE_MESSAGES and MANAGE_CHANNELS will need to be removed once they're gone as checks if (!permission.has("MANAGE_MESSAGES") && !permission.has("MANAGE_CHANNELS") && !permission.has("BYPASS_SLOWMODE")) { throw DiscordApiErrors.SLOWMODE_RATE_LIMIT;