blacklist user
This commit is contained in:
parent
7753345e03
commit
e0321df13d
1 changed files with 49 additions and 0 deletions
49
commands/owner/blacklist.js
Normal file
49
commands/owner/blacklist.js
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
const { Command } = require('discord.js-commando');
|
||||||
|
const fs = require('fs');
|
||||||
|
module.exports = class BlacklistCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'blacklist',
|
||||||
|
aliases: ['niggerlist'],
|
||||||
|
group: 'owner',
|
||||||
|
memberName: 'blacklist',
|
||||||
|
description: `To blacklist a user from the bot`,
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'user',
|
||||||
|
prompt: 'Who do you want to blacklist',
|
||||||
|
type: 'user',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'reasons',
|
||||||
|
prompt: 'Who do you want to blacklist',
|
||||||
|
type: 'string',
|
||||||
|
default: 'Didin\'t provide any reasons'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(message, { user, reasons }) {
|
||||||
|
let blacklist = {}
|
||||||
|
let json = JSON.stringify(blacklist)
|
||||||
|
|
||||||
|
if(user) {
|
||||||
|
fs.readFile('json/blacklist.json', 'utf8', function readFileCallback(err, data){
|
||||||
|
if (err){
|
||||||
|
console.log(err);
|
||||||
|
} else {
|
||||||
|
blacklist = JSON.parse(data); //now it an object
|
||||||
|
blacklist [user] = reasons
|
||||||
|
json = JSON.stringify(blacklist); //convert it back to json
|
||||||
|
json = json.replace(/[<@!>]/g, '')
|
||||||
|
fs.writeFile('json/blacklist.json', json, 'utf8', function(err) {
|
||||||
|
if(err) {
|
||||||
|
return console.log(err);
|
||||||
|
}
|
||||||
|
})}});
|
||||||
|
|
||||||
|
return message.say(`User ${user} have been blacklisted`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in a new issue