Skip to content
Snippets Groups Projects
Commit 50335208 authored by Reviath's avatar Reviath
Browse files

Getting errors from json file and added ban command

parent cdcbebbb
No related branches found
No related tags found
No related merge requests found
const errors = require('../errors.json');
exports.run = async (client, message, args, connection) => {
if (!message.member.hasPermission('BAN_MEMBERS')) {
message.channel.send(errors.insufficient_permission_for_user);
return;
};
const user = message.mentions.users.first() || message.guild.members.cache.get(args[0]);
if (!user) {
message.channel.send(errors.insufficient_args)
return;
};
let reason = args.slice(1).join(' ');
if (reason == null) {
reason = "Unspecified."
};
if(message.guild.member(user).roles.highest.position >= message.member.roles.highest.position) {
message.channel.send(errors.equal_or_more_permission);
return;
};
if (!message.guild.member(user).bannable) {
message.channel.send(errors.insufficient_permission_for_bot);
return;
};
await message.guild.member(user).ban({reason: reason}).catch(e => {
message.channel.send(errors.unknown_error);
return;
});
message.channel.send('Successfully performed ban on specified user.');
};
module.exports.help = {
name: 'ban',
aliases: []
};
\ No newline at end of file
const config = require('../config.json');
const errors = require('../errors.json');
exports.run = async (client, message, args, connection) => {
if(!config.owner.includes(message.author.id)){
message.channel.send('You don\'t own this bot.')
message.channel.send('You don\'t own this bot.');
return;
}
};
try {
const code = args.join(' ');
if (!code) {
message.channel.send('You need to send what you want to run.');
message.channel.send(errors.insufficient_args);
return;
};
const res = eval(code);
......@@ -19,7 +18,7 @@ exports.run = async (client, message, args, connection) => {
} catch (err) {
message.channel.send(`\`Error:\` \`\`\`xl\n${err}\n\`\`\``);
};
}
};
module.exports.help = {
name: 'eval',
aliases: []
......
{
"insufficient_permission_for_user": "You don't have enough permission to run this command.",
"equal_or_more_permission": "You can't take action on members with equal or higher position.",
"insufficient_permission_for_bot": "I don't have enough permission.",
"unknown_error": "An error occurred while executing this command.",
"insufficient_args": "You must specify all required args"
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment