From 47f09fefbd8e85aea7475cc1f6f4308980f10e76 Mon Sep 17 00:00:00 2001 From: bignutty <3515180-bignutty@users.noreply.gitlab.com> Date: Fri, 17 May 2024 22:24:50 +0200 Subject: [PATCH] resolves an issue with timeouts that seem to apply to bots now. --- labscore/client.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/labscore/client.js b/labscore/client.js index 8f00344..134fec3 100644 --- a/labscore/client.js +++ b/labscore/client.js @@ -50,7 +50,27 @@ const commandClient = new CommandClient(cluster, { ratelimits: [ {duration: 60000, limit: 50, type: 'guild'}, {duration: 5000, limit: 5, type: 'channel'}, - ] + ], + onCommandCheck: async (context, command) => { + /* + I don't know why, I don't know since when - but timeouts apply to bots now. + This code checks if the bot is currently timed out, preventing any and all + commands from being executed. + */ + + // Only apply filters below to a GUILD context. + if(!context.guild) return true; + + let b = context.guild.members.get(context.client.user.id); + // Bot member is not cached for whatever reason, fetch it. + if(b === undefined) b = await context.guild.fetchMember(context.client.user.id); + + // Bot is timed out. Do not run anything until no longer timed out. + if(b.communicationDisabledUntil !== null) return false; + + // Command should be fine to run. + return true; + } }); const interactionClient = new InteractionCommandClient(cluster, {