merge-requests/12/merge
Bsian 2020-05-19 22:34:55 +01:00
parent a8e0a81e55
commit 4a30a27038
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
2 changed files with 6 additions and 7 deletions

View File

@ -111,7 +111,7 @@ export default class Moderation {
return mod.save();
}
public async kick(user: User, moderator: Member, reason?: string): Promise<ModerationInterface> {
public async kick(user: Member|User, moderator: Member, reason?: string): Promise<ModerationInterface> {
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');

View File

@ -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];