diff --git a/XiaoBot.js b/XiaoBot.js index fc822fac..770f35e1 100644 --- a/XiaoBot.js +++ b/XiaoBot.js @@ -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 diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js index fa7cca58..ed989213 100644 --- a/commands/moderation/ban.js +++ b/commands/moderation/ban.js @@ -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}.`); } }; diff --git a/commands/moderation/hackban.js b/commands/moderation/hackban.js index 3e3bfb70..15321cb2 100644 --- a/commands/moderation/hackban.js +++ b/commands/moderation/hackban.js @@ -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}.`); } diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index ea544951..8905e423 100644 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -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}.`); } }; diff --git a/commands/moderation/softban.js b/commands/moderation/softban.js index 3b60fe90..6e823ee6 100644 --- a/commands/moderation/softban.js +++ b/commands/moderation/softban.js @@ -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}.`); } }; diff --git a/commands/moderation/unban.js b/commands/moderation/unban.js index 8255d1f2..06f6d087 100644 --- a/commands/moderation/unban.js +++ b/commands/moderation/unban.js @@ -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}.`); } }; diff --git a/package.json b/package.json index d20d9086..c0984863 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "47.6.0", + "version": "47.6.1", "description": "Your personal server companion.", "main": "Shard.js", "scripts": { diff --git a/structures/CommandoClient.js b/structures/CommandoClient.js index 982ae247..13f326db 100644 --- a/structures/CommandoClient.js +++ b/structures/CommandoClient.js @@ -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();