From 751e57346cb3c82f0337e10011ada068016b0d84 Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Tue, 2 May 2023 14:19:05 +1000 Subject: [PATCH] Relocate whitelist system --- src/commands/bannedWords.ts | 2 +- src/commands/dev.ts | 4 ++-- src/config.json | 18 ++++++++---------- src/events/interactionCreate.ts | 2 +- src/events/messageCreate.ts | 2 +- src/typings/interfaces.d.ts | 7 ++----- 6 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/commands/bannedWords.ts b/src/commands/bannedWords.ts index 385b4c1..6e3a582 100644 --- a/src/commands/bannedWords.ts +++ b/src/commands/bannedWords.ts @@ -4,7 +4,7 @@ import {writeFileSync} from 'node:fs'; import path from 'node:path'; export default { async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){ - if (!client.isStaff(interaction.member) && !client.config.eval.whitelist.includes(interaction.member.id)) return client.youNeedRole(interaction, 'admin') + if (!client.isStaff(interaction.member) && !client.config.whitelist.includes(interaction.member.id)) return client.youNeedRole(interaction, 'admin') const word = interaction.options.getString('word'); const wordExists = await client.bannedWords._content.findById(word); ({ diff --git a/src/commands/dev.ts b/src/commands/dev.ts index fbe01a8..a17a847 100644 --- a/src/commands/dev.ts +++ b/src/commands/dev.ts @@ -22,10 +22,10 @@ const removeUsername = (text: string)=>{ }; export default { run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>) { - if (!client.config.eval.whitelist.includes(interaction.user.id)) return client.youNeedRole(interaction, 'bottech'); + if (!client.config.whitelist.includes(interaction.user.id)) return client.youNeedRole(interaction, 'bottech'); ({ eval: async()=>{ - if (!client.config.eval.allowed) return interaction.reply({content: 'Eval is disabled.', ephemeral: true}); + if (!client.config.eval) return interaction.reply({content: 'Eval is currently disabled.', ephemeral: true}); const code = interaction.options.getString('code') as string; let output = 'error'; let error = false; diff --git a/src/config.json b/src/config.json index d7e3a09..55d6147 100644 --- a/src/config.json +++ b/src/config.json @@ -24,16 +24,14 @@ ], "status": "online" }, - "eval": { - "allowed": true, - "whitelist": [ - "190407856527376384", - "615761944154210305", - "633345781780185099", - "215497515934416896", - "309373272594579456" - ] - }, + "eval": true, + "whitelist": [ + "190407856527376384", + "615761944154210305", + "633345781780185099", + "215497515934416896", + "309373272594579456" + ], "mainServer": { "id": "468835415093411861", "staffRoles": [ diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts index e852ce3..ea9371e 100644 --- a/src/events/interactionCreate.ts +++ b/src/events/interactionCreate.ts @@ -6,7 +6,7 @@ export default { if (interaction.isChatInputCommand()){ const commandFile = client.commands.get(interaction.commandName); console.log(client.logTime(), `${interaction.user.tag} used /${interaction.commandName} ${interaction.options.getSubcommand(false) ?? ''} in #${interaction.channel.name}`); - if (!client.config.botSwitches.commands && !client.config.eval.whitelist.includes(interaction.user.id)) return interaction.reply({content: 'Bot is currently being run in development mode.', ephemeral: true}); + if (!client.config.botSwitches.commands && !client.config.whitelist.includes(interaction.user.id)) return interaction.reply({content: 'Bot is currently being run in development mode.', ephemeral: true}); if (commandFile){ try{ commandFile.command.default.run(client, interaction); diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 6d9407c..30abd0b 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -114,7 +114,7 @@ export default { if (EveningArray.some(e=>message.content.toLowerCase().startsWith(e)) && message.channelId == GeneralChatID && message.type == 0) message.reply(`${EveningPhrases[Math.floor(Math.random()*EveningPhrases.length)]}`); if (NightArray.some(e=>message.content.toLowerCase().startsWith(e)) && message.channelId == GeneralChatID && message.type == 0) message.reply(`${NightPhrases[Math.floor(Math.random()*NightPhrases.length)]}`); // Failsafe thingy (Toastproof maybe) - if (message.content.startsWith('!!_wepanikfrfr') && client.config.eval.whitelist.includes(message.author.id)) (client.guilds.cache.get(message.guildId) as Discord.Guild).commands.set(client.registry).then(()=>message.reply('How did you manage to lose the commands??? Anyways, it\'s re-registered now.')).catch((e:Error)=>message.reply(`Failed to deploy slash commands:\n\`\`\`${e.message}\`\`\``)); + if (message.content.startsWith('!!_wepanikfrfr') && client.config.whitelist.includes(message.author.id)) (client.guilds.cache.get(message.guildId) as Discord.Guild).commands.set(client.registry).then(()=>message.reply('How did you manage to lose the commands??? Anyways, it\'s re-registered now.')).catch((e:Error)=>message.reply(`Failed to deploy slash commands:\n\`\`\`${e.message}\`\`\``)); } } } diff --git a/src/typings/interfaces.d.ts b/src/typings/interfaces.d.ts index 0ded2e4..c76a5ac 100644 --- a/src/typings/interfaces.d.ts +++ b/src/typings/interfaces.d.ts @@ -143,7 +143,8 @@ export interface Config { whitelistedServers: Array, botSwitches: botSwitches, botPresence: Discord.PresenceData, - eval: Eval, + eval: boolean, + whitelist: Array mainServer: mainServer } interface botSwitches { @@ -154,10 +155,6 @@ interface botSwitches { mpstats: boolean, autores: boolean } -interface Eval { - allowed: boolean, - whitelist: Array -} interface mainServer { id: string, staffRoles: Array,