2018-12-30 01:20:24 +01:00
const { Listener } = require ( 'discord-akairo' ) ;
2021-03-13 18:21:18 +01:00
const Blacklists = require ( '../../models' ) . Blacklists ;
2018-12-30 01:20:24 +01:00
class CommandBlockedListener extends Listener {
2019-01-02 08:09:45 +01:00
constructor ( ) {
super ( 'commandBlocked' , {
emitter : 'commandHandler' ,
2019-01-02 21:46:12 +01:00
event : 'commandBlocked'
2019-01-02 08:09:45 +01:00
} ) ;
}
2018-12-30 01:20:24 +01:00
2019-01-14 11:33:01 +01:00
async exec ( message , command , reason ) {
2021-03-13 18:21:18 +01:00
const blacklist = await Blacklists . findOne ( { where : { type : command . id , uid : message . author . id } } ) ;
2019-01-02 08:09:45 +01:00
console . log ( ` ${ message . author . username } was blocked from using ${ command . id } because of ${ reason } ! ` ) ;
let ownerMessage ;
2019-03-23 23:55:52 +01:00
let blacklistMessage ;
2020-03-02 19:53:25 +01:00
let Embed = this . client . util . embed ( )
. setColor ( 'RED' )
. setTitle ( 'Error' )
. setDescription ( 'Something blocked you' ) ;
2019-01-02 08:09:45 +01:00
switch ( reason ) {
2019-01-14 11:33:01 +01:00
case 'owner' :
2019-01-02 08:09:45 +01:00
ownerMessage = [ 'Nice try but you aren\'t the owner <a:memed:433320880135733248>' , 'LOADING SUPER SECRET COMMAND <a:loadingmin:527579785212329984> Wait a minute... you aren\'t the owner!' , 'uhm, how about no' ] ;
2020-03-02 19:53:25 +01:00
Embed . setTitle ( 'You are not the owner.' ) ;
Embed . setDescription ( ownerMessage [ Math . floor ( Math . random ( ) * ownerMessage . length ) ] ) ;
message . reply ( Embed ) ;
2019-01-02 08:09:45 +01:00
break ;
2019-01-14 11:33:01 +01:00
case 'guild' :
2020-03-19 23:24:31 +01:00
message . reply ( 'You can\'t use this command in DM!' ) ;
2019-01-02 08:09:45 +01:00
break ;
2019-01-14 11:33:01 +01:00
case 'dm' :
2020-03-19 23:24:31 +01:00
message . reply ( 'You can\'t use this command in a guild!' ) ;
2019-01-02 08:09:45 +01:00
break ;
case 'blacklist' :
2019-03-23 23:55:52 +01:00
blacklistMessage = [ 'bro... i think you are blacklisted.... OWNED!!!' , 'You can\'t use this command because you have been blacklisted!' , ' you are blacklisted!!!1111!! be less naughty next time!' , 'blacklisted,,,,,, lol owned bro' ] ;
2020-03-02 19:53:25 +01:00
Embed . setTitle ( 'You are blacklisted.' ) ;
Embed . setDescription ( blacklistMessage [ Math . floor ( Math . random ( ) * blacklistMessage . length ) ] ) ;
message . reply ( Embed ) ;
2019-04-13 17:49:58 +02:00
break ;
2019-01-19 19:11:27 +01:00
case 'serverblacklist' :
2020-03-02 19:53:25 +01:00
Embed . setTitle ( 'Server blacklisted.' ) ;
2020-11-05 20:58:33 +01:00
Embed . setDescription ( ` This server have been blacklisted... to appeal contact ${ this . client . users . resolve ( this . client . ownerID ) . tag } , and now i will yeet out of here ` ) ;
2020-03-02 19:53:25 +01:00
message . channel . send ( Embed ) ;
2019-01-21 22:13:11 +01:00
message . guild . leave ( ) ;
2019-01-19 19:11:27 +01:00
break ;
2020-03-18 02:28:29 +01:00
case 'commandblock' :
Embed . setTitle ( 'Command blocked.' ) ;
Embed . setDescription ( 'The admins of this server blocked this command.' ) ;
message . channel . send ( Embed ) ;
break ;
2021-03-13 18:21:18 +01:00
case 'commandblacklist' :
Embed . setTitle ( 'Command blocked.' ) ;
Embed . setDescription ( ` You've been blocked from this command for the following reason: \` ${ blacklist . reason } \` ` ) ;
message . channel . send ( Embed ) ;
break ;
2019-01-02 08:09:45 +01:00
}
}
2018-12-30 01:20:24 +01:00
}
module . exports = CommandBlockedListener ;