mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 04:10:59 -05:00
revise the bannedWords command
This commit is contained in:
parent
55df26eece
commit
64466e7e15
@ -1,19 +0,0 @@
|
|||||||
import Discord,{SlashCommandBuilder} from 'discord.js';
|
|
||||||
import { TClient } from 'src/client';
|
|
||||||
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')
|
|
||||||
const word = interaction.options.getString('word');
|
|
||||||
if (client.bannedWords._content.includes(word)) return interaction.reply({content: 'That word is already added to the list.', ephemeral: true});
|
|
||||||
client.bannedWords.addData(word).forceSave();
|
|
||||||
interaction.reply(`Successfully added \`${word}\` to the list.`)
|
|
||||||
},
|
|
||||||
data: new SlashCommandBuilder()
|
|
||||||
.setName('addbannedword')
|
|
||||||
.setDescription('Add a word to bannedWords file')
|
|
||||||
.setDMPermission(false)
|
|
||||||
.addStringOption((opt)=>opt
|
|
||||||
.setName('word')
|
|
||||||
.setDescription('What word do you want automod to ban?')
|
|
||||||
.setRequired(true))
|
|
||||||
}
|
|
44
src/commands/bannedWords.ts
Normal file
44
src/commands/bannedWords.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import Discord,{SlashCommandBuilder} from 'discord.js';
|
||||||
|
import { TClient } from 'src/client';
|
||||||
|
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')
|
||||||
|
const Sub = interaction.options.getSubcommand();
|
||||||
|
const word = interaction.options.getString('word');
|
||||||
|
switch(Sub){
|
||||||
|
case 'view':
|
||||||
|
interaction.reply({content: 'Here is a complete list of banned words!\n*You can open it with a web browser, e.g Chrome/Firefox/Safari, or you can use Visual Studio Code/Notepad++*', files: ['src/database/bannedWords.json'], ephemeral: true})
|
||||||
|
break;
|
||||||
|
case 'add':
|
||||||
|
if (client.bannedWords._content.includes(word)) return interaction.reply({content: `\`${word}\` is already added.`, ephemeral: true});
|
||||||
|
client.bannedWords.addData(word).forceSave();
|
||||||
|
interaction.reply(`Successfully added \`${word}\` to the list.`)
|
||||||
|
break;
|
||||||
|
case 'remove':
|
||||||
|
if (client.bannedWords._content.includes(!word)) return interaction.reply({content: `\`${word}\` doesn't exist on the list.`, ephemeral: true});
|
||||||
|
client.bannedWords.removeData(word, 1, 0).forceSave();
|
||||||
|
interaction.reply(`Successfully removed \`${word}\` from the list.`)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName('bannedwords')
|
||||||
|
.setDescription('description placeholder')
|
||||||
|
.setDMPermission(false)
|
||||||
|
.addSubcommand((opt)=>opt
|
||||||
|
.setName('view')
|
||||||
|
.setDescription('View the list of currently banned words.'))
|
||||||
|
.addSubcommand((opt)=>opt
|
||||||
|
.setName('add')
|
||||||
|
.setDescription('What word do you want to add?')
|
||||||
|
.addStringOption((optt)=>optt
|
||||||
|
.setName('word')
|
||||||
|
.setDescription('Add the specific word to automod\'s bannedWords list.')
|
||||||
|
.setRequired(true)))
|
||||||
|
.addSubcommand((opt)=>opt
|
||||||
|
.setName('remove')
|
||||||
|
.setDescription('What word do you want to remove?')
|
||||||
|
.addStringOption((optt)=>optt
|
||||||
|
.setName('word')
|
||||||
|
.setDescription('Remove the specific word from automod\'s bannedWords list.')
|
||||||
|
.setRequired(true)))
|
||||||
|
}
|
@ -31,8 +31,6 @@ export class Database {
|
|||||||
case 1:
|
case 1:
|
||||||
this._content = this._content.filter((x:any)=>x[element] != key);
|
this._content = this._content.filter((x:any)=>x[element] != key);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
return 'Type must be properly specified';
|
|
||||||
}
|
}
|
||||||
} else if (this._dataType === 'object'){
|
} else if (this._dataType === 'object'){
|
||||||
delete this._content[key];
|
delete this._content[key];
|
||||||
|
Loading…
Reference in New Issue
Block a user