From ec8eff224b5fd511098b8d863f0694ed0e28479d Mon Sep 17 00:00:00 2001 From: Matthew R Date: Fri, 17 Apr 2020 12:33:03 -0400 Subject: [PATCH] fix multiple issues with property, message.guild does not exist --- src/commands/ban.ts | 4 ++-- src/commands/game.ts | 2 +- src/commands/roleinfo.ts | 4 ++-- src/commands/unban.ts | 2 +- src/commands/whois.ts | 18 +++++++++--------- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/commands/ban.ts b/src/commands/ban.ts index 887192d..d8718c4 100644 --- a/src/commands/ban.ts +++ b/src/commands/ban.ts @@ -15,7 +15,7 @@ export default class Ban extends Command { public async run(message: Message, args: string[]) { try { - const member = this.client.util.resolveMember(args[0], message.guild); + const member = this.client.util.resolveMember(args[0], this.client.guilds.get(this.client.config.guildID)); let user: User; if (!member) { try { @@ -25,7 +25,7 @@ export default class Ban extends Command { } } try { - await message.guild.getBan(args[0]); + await this.client.guilds.get(this.client.config.guildID).getBan(args[0]); return this.error(message.channel, 'This user is already banned.'); } catch {} // eslint-disable-line no-empty if (member && !this.client.util.moderation.checkPermissions(member, message.member)) return this.error(message.channel, 'Permission Denied.'); diff --git a/src/commands/game.ts b/src/commands/game.ts index 50f3ac9..6404a7e 100644 --- a/src/commands/game.ts +++ b/src/commands/game.ts @@ -27,7 +27,7 @@ export default class Game extends Command { let member: Member; if (!args[0]) member = message.member; else { - member = this.client.util.resolveMember(args.join(' '), message.guild); + member = this.client.util.resolveMember(args.join(' '), this.client.guilds.get(this.client.config.guildID)); if (!member) { return this.error(message.channel, 'Member not found.'); } diff --git a/src/commands/roleinfo.ts b/src/commands/roleinfo.ts index aa68eb0..0bd16bf 100644 --- a/src/commands/roleinfo.ts +++ b/src/commands/roleinfo.ts @@ -16,9 +16,9 @@ export default class Roleinfo extends Command { try { if (!args[0]) return this.error(message.channel, 'You need to specifiy a role ID or a role name.'); - let role: Role = message.guild.roles.find((r: Role) => r.id === args[0]); + let role: Role = this.client.guilds.get(this.client.config.guildID).roles.find((r: Role) => r.id === args[0]); if (!role) { // if it's a role name - role = message.guild.roles.find((r: Role) => r.name.toLowerCase().includes(args.join(' ').toLowerCase())); + role = this.client.guilds.get(this.client.config.guildID).roles.find((r: Role) => r.name.toLowerCase().includes(args.join(' ').toLowerCase())); } if (!role) return this.error(message.channel, 'Could not find role.'); diff --git a/src/commands/unban.ts b/src/commands/unban.ts index 1e0ed94..025758c 100644 --- a/src/commands/unban.ts +++ b/src/commands/unban.ts @@ -21,7 +21,7 @@ export default class Unban extends Command { return this.error(message.channel, 'Could find find user.'); } try { - await message.guild.getBan(args[0]); + await this.client.guilds.get(this.client.config.guildID).getBan(args[0]); } catch { return this.error(message.channel, 'This user is not banned.'); } diff --git a/src/commands/whois.ts b/src/commands/whois.ts index 44a020d..dcd2d76 100644 --- a/src/commands/whois.ts +++ b/src/commands/whois.ts @@ -21,7 +21,7 @@ export default class Whois extends Command { let member: Member; if (!args[0]) member = message.member; else { - member = this.client.util.resolveMember(args.join(' '), message.guild); + member = this.client.util.resolveMember(args.join(' '), this.client.guilds.get(this.client.config.guildID)); } if (!member) { @@ -42,26 +42,26 @@ export default class Whois extends Command { const ackResolve = this.resolveStaffInformation(member.id); let description = ''; if (ackResolve) { - if (ackResolve.title && ackResolve.dept) { + if (ackResolve?.title && ackResolve?.dept) { description += `${emotes.titleAndDepartment} __**${ackResolve.title}**__, ${ackResolve.dept}\n\n`; } - if (ackResolve.emailAddress) { + if (ackResolve?.emailAddress) { description += `${emotes.email} ${ackResolve.emailAddress}\n`; } - if (ackResolve.gitlab) { + if (ackResolve?.gitlab) { description += `${emotes.gitlab} ${ackResolve.gitlab}\n`; } - if (ackResolve.github) { + if (ackResolve?.github) { description += `${emotes.github} ${ackResolve.github}\n`; } - if (ackResolve.bio) { + if (ackResolve?.bio) { description += `${emotes.bio} *${ackResolve.bio}*\n`; } } description += `\n<@${member.id}>`; embed.setDescription(description); - const roles = member.roles.map((r) => message.guild.roles.get(r)).sort((a, b) => b.position - a.position); + const roles = member.roles.map((r) => this.client.guilds.get(this.client.config.guildID).roles.get(r)).sort((a, b) => b.position - a.position); const { color } = roles.find((r) => r.color); embed.setColor(color); @@ -72,7 +72,7 @@ export default class Whois extends Command { const permissions: string[] = []; const serverAcknowledgements: string[] = []; const bit = member.permission.allow; - if (message.guild.ownerID === member.id) serverAcknowledgements.push('Server Owner'); + if (this.client.guilds.get(this.client.config.guildID).ownerID === member.id) serverAcknowledgements.push('Server Owner'); if ((bit | 8) === bit) { permissions.push('Administrator'); serverAcknowledgements.push('Server Admin'); } if ((bit | 20) === bit) { permissions.push('Manage Server'); serverAcknowledgements.push('Server Manager'); } if ((bit | 10) === bit) permissions.push('Manage Channels'); @@ -88,7 +88,7 @@ export default class Whois extends Command { if (serverAcknowledgements.length > 0) { embed.addField('Acknowledgements', serverAcknowledgements[0]); } - if (ackResolve && ackResolve.acknowledgements) { + if (ackResolve?.acknowledgements) { embed.addField('Bot Acknowledgements', ackResolve.acknowledgements.join(', ')); } embed.setFooter(this.client.user.username, this.client.user.avatarURL);