Fixes #8
parent
a8e0a81e55
commit
4a30a27038
|
@ -111,7 +111,7 @@ export default class Moderation {
|
||||||
return mod.save();
|
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');
|
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);
|
await this.client.guilds.get(this.client.config.guildID).kickMember(user.id, reason);
|
||||||
const logID = randomBytes(2).toString('hex');
|
const logID = randomBytes(2).toString('hex');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Message, User } from 'eris';
|
import { Message, User, Member } from 'eris';
|
||||||
import { Client, Command } from '../class';
|
import { Client, Command } from '../class';
|
||||||
|
|
||||||
export default class Kick extends Command {
|
export default class Kick extends Command {
|
||||||
|
@ -15,16 +15,15 @@ export default class Kick extends Command {
|
||||||
public async run(message: Message, args: string[]) {
|
public async run(message: Message, args: string[]) {
|
||||||
try {
|
try {
|
||||||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
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: Member = this.client.util.resolveMember(args[0], this.client.guilds.get(this.client.config.guildID));
|
||||||
let user: User;
|
if (!user) {
|
||||||
if (!member) {
|
|
||||||
try {
|
try {
|
||||||
user = await this.client.getRESTUser(args[0]);
|
user = await this.client.getRESTGuildMember(this.client.config.guildID, args[0]);
|
||||||
} catch {
|
} catch {
|
||||||
return this.error(message.channel, 'Cannot find user.');
|
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();
|
message.delete();
|
||||||
|
|
||||||
const reason: string = args[1];
|
const reason: string = args[1];
|
||||||
|
|
Loading…
Reference in New Issue