2021-02-06 11:10:52 -06:00
module . exports = {
name : 'reload' ,
description : 'Reloads a command' ,
2022-03-26 12:31:03 -05:00
async execute ( client , message , args , footerTxt ) {
2022-03-26 03:33:18 -05:00
if ( message . author . id == 309427567004483586 || message . author . id == 475558313376088064 ) {
2022-03-26 12:31:03 -05:00
if ( ! args . length ) {
await message . channel . send ( client . generateErrorMessage ( "You forgot to provide anything to reload, you pillock" , message . author . displayAvatarURL ( ) ) ) ;
}
args . forEach ( async ( arg ) => {
const commandName = arg . toLowerCase ( ) ;
const command = message . client . commands . get ( commandName )
|| message . client . commands . find ( cmd => cmd . aliases && cmd . aliases . includes ( commandName ) ) ;
2021-02-06 11:10:52 -06:00
2022-03-26 12:31:03 -05:00
if ( ! command ) {
await message . channel . send ( client . generateErrorMessage ( ` There is no command with name or alias \` ${ commandName } \` , ${ message . author } ! ` , message . author . displayAvatarURL ( ) ) ) ;
} else {
delete require . cache [ require . resolve ( ` ./ ${ command . name } .js ` ) ] ;
2021-02-06 11:10:52 -06:00
2022-03-26 12:31:03 -05:00
try {
const newCommand = require ( ` ./ ${ command . name } .js ` ) ;
client . commands . set ( newCommand . name , newCommand ) ;
await message . channel . send ( ` <:NyabotSuccess:697211376740859914> **Reloaded \` ${ command . name } \` successfully!** ` ) ;
console . log ( ` User reloaded ${ command . name } . ` )
} catch ( error ) {
console . error ( error ) ;
await message . channel . send ( client . generateErrorMessage ( ` There was an error while reloading \` ${ command . name } \` : \n \` ${ error . message } \` ` , message . author . displayAvatarURL ( ) ) ) ;
}
2022-03-26 03:33:18 -05:00
}
2022-03-26 12:31:03 -05:00
} ) ;
2022-03-26 03:33:18 -05:00
} else {
2022-03-26 11:02:17 -05:00
message . channel . send ( { embed : {
2022-03-26 03:33:18 -05:00
"title" : "<:NyabotDenied:697145462565896194> **Access is denied**" ,
"color" : 13632027 ,
2022-03-26 12:31:03 -05:00
"footer" : {
"icon_url" : message . author . displayAvatarURL ( ) ,
"text" : footerTxt
} ,
2022-03-26 03:33:18 -05:00
"fields" : [
{
"name" : "**What Happened?**" ,
"value" : "You don't have the appropriate permissions to run this command!"
}
]
2022-03-26 11:02:17 -05:00
} } ) ;
2022-03-26 03:33:18 -05:00
}
}
2021-01-19 14:02:09 -06:00
} ;