2021-02-28 00:39:52 -06:00
module . exports = {
2022-04-18 11:25:40 -05:00
name : require ( 'path' ) . parse ( _ _filename ) . name ,
2022-03-26 03:33:18 -05:00
description : 'Sets your nickname' ,
2022-04-18 11:25:40 -05:00
2022-03-29 13:51:43 -05:00
async execute ( client , message , args , config ) {
2022-04-21 12:24:12 -05:00
const avatarURL = message . author . displayAvatarURL ( ) ;
2021-03-12 10:57:13 -06:00
if ( message . channel . permissionsFor ( message . author ) . has ( "CHANGE_NICKNAME" ) ) {
2022-03-26 03:33:18 -05:00
const newnick = args . slice ( 0 ) . join ( " " )
try {
await message . member . setNickname ( newnick , "Nickname change requested by the server member. If you don't want users to be able to change their nickname disable 'CHANGE_NICKNAME' via Change Nickname in Roles." )
2022-04-21 11:29:04 -05:00
await message . channel . send ( { embeds : [ {
2022-03-26 03:33:18 -05:00
"title" : "<:AnitroxSuccess:809651936819019796> Nickname Changed" ,
"color" : 9442302 ,
2022-03-26 12:31:03 -05:00
"footer" : {
"icon_url" : message . author . displayAvatarURL ( ) ,
2022-03-29 13:51:43 -05:00
"text" : config . footerTxt
2022-03-26 12:31:03 -05:00
} ,
2022-03-26 03:33:18 -05:00
"fields" : [
{
"name" : "Changed nickname successfully!" ,
2022-04-21 11:36:03 -05:00
"value" : ` New Nickname: ${ newnick } `
2022-03-26 03:33:18 -05:00
} ,
{
"name" : "New Nickname" ,
"value" : newnick ,
"inline" : true
}
]
2022-04-21 11:29:04 -05:00
} ] } ) ;
2022-03-26 03:33:18 -05:00
} catch ( error ) {
2022-04-21 12:24:12 -05:00
await message . channel . send ( client . generateErrorMessage ( "Failed to set user nickname. Does the bot have the correct permissions?" , avatarURL ) ) ;
2022-03-26 03:33:18 -05:00
} ;
2022-03-26 12:31:03 -05:00
} else {
2022-04-21 12:24:12 -05:00
await message . channel . send ( client . generateErrorMessage ( "You need to have permission ``CHANGE_NICKNAME`` to change your nick!" , avatarURL ) ) ;
2022-03-26 12:31:03 -05:00
}
2022-03-26 03:33:18 -05:00
}
}