2019-09-13 20:02:41 +00:00
const database = require ( "../utils/database.js" ) ;
exports . run = async ( message , args ) => {
2020-07-10 17:07:24 +00:00
const guildDB = await database . query ( "SELECT * FROM guilds WHERE guild_id = $1" , [ message . channel . guild . id ] ) ;
2019-09-13 20:02:41 +00:00
if ( args . length !== 0 ) {
2019-11-15 16:59:50 +00:00
if ( ! message . member . permission . has ( "administrator" ) && message . member . id !== process . env . OWNER ) return ` ${ message . author . mention } , you need to be an administrator to change the bot prefix! ` ;
2020-07-10 17:07:24 +00:00
if ( args [ 0 ] . length > 15 ) return ` ${ message . author . mention } , that prefix is too long! ` ;
await database . query ( "UPDATE guilds SET prefix = $1 WHERE guild_id = $2" , [ args [ 0 ] , message . channel . guild . id ] ) ;
2019-09-13 20:02:41 +00:00
return ` The prefix has been changed to ${ args [ 0 ] } . ` ;
} else {
2020-07-10 17:07:24 +00:00
return ` ${ message . author . mention } , the current prefix is \` ${ guildDB . rows [ 0 ] . prefix } \` . ` ;
2019-09-13 20:02:41 +00:00
}
} ;
exports . aliases = [ "setprefix" , "changeprefix" , "checkprefix" ] ;
2019-12-02 20:47:22 +00:00
exports . category = 1 ;
2019-12-05 16:58:46 +00:00
exports . help = "Checks/changes the server prefix" ;
exports . params = "{prefix}" ;