diff --git a/.eslintrc.json b/.eslintrc.json index af3e032..cf9a1af 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -19,7 +19,7 @@ }, "parser": "@typescript-eslint/parser", "parserOptions": { - "ecmaVersion": 2018, + "ecmaVersion": 2020, "sourceType": "module" }, "plugins": [ diff --git a/package.json b/package.json index 0fbd1f2..322f8ad 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,11 @@ }, "dependencies": { "axios": "^0.19.2", +<<<<<<< HEAD "eris": "abalabahaha/eris#dev", +======= + "eris": "bsian03/eris#bsian", +>>>>>>> dev "moment": "^2.24.0", "mongoose": "^5.9.9", "signale": "^1.4.0", diff --git a/src/class/Util.ts b/src/class/Util.ts index f31a4ca..613c479 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -126,4 +126,12 @@ export default class Util { const asHex = number.toString(16); return '#000000'.substring(0, 7 - asHex.length) + asHex; } +<<<<<<< HEAD +======= + + public guildFromMessage(message: Message): Guild | null { + if (message.channel instanceof PrivateChannel || message.channel instanceof GroupChannel) return null; + return message.channel.guild; + } +>>>>>>> dev } diff --git a/src/commands/ban.ts b/src/commands/ban.ts index a5afa43..887192d 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.member.guild); + const member = this.client.util.resolveMember(args[0], message.guild); let user: User; if (!member) { try { @@ -25,7 +25,7 @@ export default class Ban extends Command { } } try { - await this.client.guilds.get(this.client.config.guildID).getBan(args[0]); + await message.guild.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 6d1aa68..50f3ac9 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.member.guild); + member = this.client.util.resolveMember(args.join(' '), message.guild); if (!member) { return this.error(message.channel, 'Member not found.'); } diff --git a/src/commands/roleinfo.ts b/src/commands/roleinfo.ts index 574a7d0..aa68eb0 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.member.guild.roles.find((r: Role) => r.id === args[0]); + let role: Role = message.guild.roles.find((r: Role) => r.id === args[0]); if (!role) { // if it's a role name - role = message.member.guild.roles.find((r: Role) => r.name.toLowerCase().includes(args.join(' ').toLowerCase())); + role = message.guild.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 025758c..1e0ed94 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 this.client.guilds.get(this.client.config.guildID).getBan(args[0]); + await message.guild.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 e6bdad9..44a020d 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.member.guild); + member = this.client.util.resolveMember(args.join(' '), message.guild); } if (!member) { @@ -61,7 +61,7 @@ export default class Whois extends Command { description += `\n<@${member.id}>`; embed.setDescription(description); - const roles = member.roles.map((r) => message.member.guild.roles.get(r)).sort((a, b) => b.position - a.position); + const roles = member.roles.map((r) => message.guild.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 (this.client.guilds.get(this.client.config.guildID).ownerID === member.id) serverAcknowledgements.push('Server Owner'); + if (message.guild.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'); diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 72a1b65..cae3794 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -1,5 +1,5 @@ /* eslint-disable no-useless-return */ -import { Message, TextChannel } from 'eris'; +import { Message, TextChannel, NewsChannel } from 'eris'; import { Client } from '../class'; export default class { @@ -16,7 +16,7 @@ export default class { const noPrefix: string[] = message.content.slice(this.client.config.prefix.length).trim().split(/ +/g); const resolved = await this.client.util.resolveCommand(noPrefix); if (!resolved) return; - if (resolved.cmd.guildOnly && !(message.channel instanceof TextChannel)) return; + if (resolved.cmd.guildOnly && !(message.channel instanceof TextChannel || message.channel instanceof NewsChannel)) return; if (!resolved.cmd.enabled) { message.channel.createMessage(`***${this.client.util.emojis.ERROR} This command has been disabled***`); return; } if (!resolved.cmd.checkPermissions(message.member)) return; this.client.util.signale.info(`User '${message.author.username}#${message.author.discriminator}' ran command '${resolved.cmd.name}' in '${message.channel.id}'.`);