Catch some stuff

This commit is contained in:
Daniel Odendahl Jr
2017-10-18 13:03:50 +00:00
parent c6ada36364
commit 59e97ed348
8 changed files with 34 additions and 19 deletions
+2 -4
View File
@@ -1,4 +1,4 @@
const { TOKEN, OWNERS, COMMAND_PREFIX, INVITE, DBOTS_KEY, DBOTSORG_KEY } = process.env;
const { TOKEN, OWNERS, COMMAND_PREFIX, INVITE } = process.env;
const path = require('path');
const CommandoClient = require('./structures/CommandoClient');
const client = new CommandoClient({
@@ -9,9 +9,7 @@ const client = new CommandoClient({
unknownCommandResponse: false,
disabledEvents: ['TYPING_START'],
messageCacheLifetime: 600,
messageSweepInterval: 120,
dBotsToken: DBOTS_KEY,
dBotsOrgToken: DBOTSORG_KEY
messageSweepInterval: 120
});
client.registry
+8 -4
View File
@@ -50,10 +50,14 @@ module.exports = class BanCommand extends Command {
} catch (err) {
await msg.say('Failed to send DM.');
}
await member.ban({
days: 7,
reason: `${msg.author.tag}: ${reason}`
});
try {
await member.ban({
days: 7,
reason: `${msg.author.tag}: ${reason}`
});
} catch (err) {
return msg.say(`Failed to ban ${member.user.tag}: \`${err.message}\`.`);
}
return msg.say(`Successfully banned ${member.user.tag}.`);
}
};
+1 -1
View File
@@ -49,7 +49,7 @@ module.exports = class HackbanCommand extends Command {
reason: `${msg.author.tag}: ${reason}`
});
} catch (err) {
return msg.say(`Could not hackban the user: \`${err.message}\``);
return msg.say(`Failed to hackban ${user.tag}: \`${err.message}\`.`);
}
return msg.say(`Successfully hackbanned ${user.tag}.`);
}
+5 -1
View File
@@ -50,7 +50,11 @@ module.exports = class KickCommand extends Command {
} catch (err) {
await msg.say('Failed to send DM.');
}
await member.kick(`${msg.author.tag}: ${reason}`);
try {
await member.kick(`${msg.author.tag}: ${reason}`);
} catch (err) {
return msg.say(`Failed to kick ${member.user.tag}: \`${err.message}\`.`);
}
return msg.say(`Successfully kicked ${member.user.tag}.`);
}
};
+9 -5
View File
@@ -50,11 +50,15 @@ module.exports = class SoftbanCommand extends Command {
} catch (err) {
await msg.say('Failed to send DM.');
}
await member.ban({
days: 7,
reason: `${msg.author.tag}: ${reason} (Softban)`
});
await msg.guild.unban(member.user, 'Softban');
try {
await member.ban({
days: 7,
reason: `${msg.author.tag}: ${reason} (Softban)`
});
await msg.guild.unban(member.user, 'Softban');
} catch (err) {
return msg.say(`Failed to softban ${member.user.tag}: \`${err.message}\`.`);
}
return msg.say(`Successfully softbanned ${member.user.tag}.`);
}
};
+5 -1
View File
@@ -38,7 +38,11 @@ module.exports = class UnbanCommand extends Command {
await msg.say(`Are you sure you want to unban ${member.tag} (${member.id})?`);
const verification = await verify(msg.channel, msg.author);
if (!verification) return msg.say('Aborting.');
await msg.guild.unban(member, `${msg.author.tag}: ${reason}`);
try {
await msg.guild.unban(member, `${msg.author.tag}: ${reason}`);
} catch (err) {
return msg.say(`Failed to unban ${member.tag}: \`${err.message}\`.`);
}
return msg.say(`Successfully unbanned ${member.tag}.`);
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "47.6.0",
"version": "47.6.1",
"description": "Your personal server companion.",
"main": "Shard.js",
"scripts": {
+3 -2
View File
@@ -1,12 +1,13 @@
const { Client } = require('discord.js-commando');
const snekfetch = require('snekfetch');
const { DBOTS_KEY, DBOTSORG_KEY } = process.env;
class CommandoClient extends Client {
constructor(options) {
super(options);
Object.defineProperty(this, 'dBotsToken', { value: options.dBotsToken });
Object.defineProperty(this, 'dBotsOrgToken', { value: options.dBotsOrgToken });
Object.defineProperty(this, 'dBotsToken', { value: DBOTS_KEY });
Object.defineProperty(this, 'dBotsOrgToken', { value: DBOTSORG_KEY });
this.on('guildCreate', () => {
this.dBots();