From 4a30a27038411bcb1f899a43ffe9c46eed1a9bb7 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 19 May 2020 22:34:55 +0100 Subject: [PATCH] Fixes #8 --- src/class/Moderation.ts | 2 +- src/commands/kick.ts | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/class/Moderation.ts b/src/class/Moderation.ts index 0f730d9..1a55eaa 100644 --- a/src/class/Moderation.ts +++ b/src/class/Moderation.ts @@ -111,7 +111,7 @@ export default class Moderation { return mod.save(); } - public async kick(user: User, moderator: Member, reason?: string): Promise { + public async kick(user: Member|User, moderator: Member, reason?: string): Promise { if (reason && reason.length > 512) throw new Error('Kick reason cannot be longer than 512 characters'); await this.client.guilds.get(this.client.config.guildID).kickMember(user.id, reason); const logID = randomBytes(2).toString('hex'); diff --git a/src/commands/kick.ts b/src/commands/kick.ts index 45c3de4..2bf5c51 100644 --- a/src/commands/kick.ts +++ b/src/commands/kick.ts @@ -1,4 +1,4 @@ -import { Message, User } from 'eris'; +import { Message, User, Member } from 'eris'; import { Client, Command } from '../class'; export default class Kick extends Command { @@ -15,16 +15,15 @@ export default class Kick extends Command { public async run(message: Message, args: string[]) { try { if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); - const member = this.client.util.resolveMember(args[0], this.client.guilds.get(this.client.config.guildID)); - let user: User; - if (!member) { + let user: Member = this.client.util.resolveMember(args[0], this.client.guilds.get(this.client.config.guildID)); + if (!user) { try { - user = await this.client.getRESTUser(args[0]); + user = await this.client.getRESTGuildMember(this.client.config.guildID, args[0]); } catch { return this.error(message.channel, 'Cannot find user.'); } } - if (member && !this.client.util.moderation.checkPermissions(member, message.member)) return this.error(message.channel, 'Permission Denied.'); + if (user && !this.client.util.moderation.checkPermissions(user, message.member)) return this.error(message.channel, 'Permission Denied.'); message.delete(); const reason: string = args[1];