2022-12-22 02:19:56 -05:00
import Discord , { SlashCommandBuilder } from 'discord.js' ;
2023-01-27 21:33:55 -05:00
import TClient from 'src/client' ;
2022-12-22 02:19:56 -05:00
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' )
2023-02-24 19:55:11 -05:00
const word = interaction . options . getString ( 'word' , true ) ;
const wordExists = await client . bannedWords . _content . findById ( word ) ;
2023-02-09 16:45:52 -05:00
( {
2023-02-24 19:55:11 -05:00
add : async ( ) = > {
if ( wordExists ) return interaction . reply ( { content : ` \` ${ word } \` is already added. ` , ephemeral : true } ) ;
await client . bannedWords . _content . create ( { _id :word } ) . then ( a = > a . save ( ) ) ;
interaction . reply ( ` Successfully added \` ${ word } \` to the database. ` )
2023-02-09 16:45:52 -05:00
} ,
2023-02-24 19:55:11 -05:00
remove : async ( ) = > {
if ( ! wordExists ) return interaction . reply ( { content : ` \` ${ word } \` doesn't exist on the list. ` , ephemeral : true } ) ;
await client . bannedWords . _content . findOneAndDelete ( { _id :word } ) ;
interaction . reply ( ` Successfully removed \` ${ word } \` from the database. ` )
2023-02-09 16:45:52 -05:00
} ,
2023-02-24 19:55:11 -05:00
//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})
2023-02-09 16:45:52 -05:00
} as any ) [ interaction . options . getSubcommand ( ) ] ( ) ;
2022-12-22 02:19:56 -05:00
} ,
data : new SlashCommandBuilder ( )
. setName ( 'bannedwords' )
. setDescription ( 'description placeholder' )
2023-02-24 19:55:11 -05:00
/ * . a d d S u b c o m m a n d ( ( o p t ) = > o p t
2022-12-22 02:19:56 -05:00
. setName ( 'view' )
. setDescription ( 'View the list of currently banned words.' ) )
2023-02-24 19:55:11 -05:00
* / . a d d S u b c o m m a n d ( ( o p t ) = > o p t
2022-12-22 02:19:56 -05:00
. setName ( 'add' )
. setDescription ( 'What word do you want to add?' )
. addStringOption ( ( optt ) = > optt
. setName ( 'word' )
2023-02-24 19:55:11 -05:00
. setDescription ( 'Add the specific word to automod\'s bannedWords database.' )
2022-12-22 02:19:56 -05:00
. 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 ) ) )
}