1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-12-28 13:05:38 -05:00

Relocate whitelist system

This commit is contained in:
AnxietyisReal 2023-05-02 14:19:05 +10:00
parent 45948e4c1d
commit 751e57346c
6 changed files with 15 additions and 20 deletions

View File

@ -4,7 +4,7 @@ import {writeFileSync} from 'node:fs';
import path from 'node:path'; import path from 'node:path';
export default { export default {
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){ 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 word = interaction.options.getString('word');
const wordExists = await client.bannedWords._content.findById(word); const wordExists = await client.bannedWords._content.findById(word);
({ ({

View File

@ -22,10 +22,10 @@ const removeUsername = (text: string)=>{
}; };
export default { export default {
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>) { 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()=>{ 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; const code = interaction.options.getString('code') as string;
let output = 'error'; let output = 'error';
let error = false; let error = false;

View File

@ -24,16 +24,14 @@
], ],
"status": "online" "status": "online"
}, },
"eval": { "eval": true,
"allowed": true,
"whitelist": [ "whitelist": [
"190407856527376384", "190407856527376384",
"615761944154210305", "615761944154210305",
"633345781780185099", "633345781780185099",
"215497515934416896", "215497515934416896",
"309373272594579456" "309373272594579456"
] ],
},
"mainServer": { "mainServer": {
"id": "468835415093411861", "id": "468835415093411861",
"staffRoles": [ "staffRoles": [

View File

@ -6,7 +6,7 @@ export default {
if (interaction.isChatInputCommand()){ if (interaction.isChatInputCommand()){
const commandFile = client.commands.get(interaction.commandName); 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}`); 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){ if (commandFile){
try{ try{
commandFile.command.default.run(client, interaction); commandFile.command.default.run(client, interaction);

View File

@ -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 (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)]}`); 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) // 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}\`\`\``));
} }
} }
} }

View File

@ -143,7 +143,8 @@ export interface Config {
whitelistedServers: Array<string>, whitelistedServers: Array<string>,
botSwitches: botSwitches, botSwitches: botSwitches,
botPresence: Discord.PresenceData, botPresence: Discord.PresenceData,
eval: Eval, eval: boolean,
whitelist: Array<string>
mainServer: mainServer mainServer: mainServer
} }
interface botSwitches { interface botSwitches {
@ -154,10 +155,6 @@ interface botSwitches {
mpstats: boolean, mpstats: boolean,
autores: boolean autores: boolean
} }
interface Eval {
allowed: boolean,
whitelist: Array<string>
}
interface mainServer { interface mainServer {
id: string, id: string,
staffRoles: Array<string>, staffRoles: Array<string>,