add colors to mod embeds and code refactor

merge-requests/9/merge
Matthew 2020-04-16 17:57:50 -04:00
parent 9e50426095
commit 563db7d9a7
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 9 additions and 7 deletions

View File

@ -1,5 +1,5 @@
/* eslint-disable no-bitwise */ /* eslint-disable no-bitwise */
import { Member } from 'eris'; import { Member, User } from 'eris';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
import moment, { unitOfTime } from 'moment'; import moment, { unitOfTime } from 'moment';
import { Client, RichEmbed } from '.'; import { Client, RichEmbed } from '.';
@ -40,11 +40,11 @@ export default class Moderation {
return moment.duration(length, unit).asMilliseconds(); return moment.duration(length, unit).asMilliseconds();
} }
public async ban(member: Member, moderator: Member, duration: number, reason?: string): Promise<ModerationInterface> { public async ban(user: User, moderator: Member, duration: number, reason?: string): Promise<ModerationInterface> {
await member.ban(7, reason); await this.client.guilds.get(this.client.config.guildID).banMember(user.id, 7, reason);
const logID = uuid(); const logID = uuid();
const mod = new ModerationModel({ const mod = new ModerationModel({
userID: member.id, userID: user.id,
logID, logID,
moderatorID: moderator.id, moderatorID: moderator.id,
reason: reason ?? null, reason: reason ?? null,
@ -63,9 +63,10 @@ export default class Moderation {
const embed = new RichEmbed(); const embed = new RichEmbed();
embed.setTitle(`Case ${logID} | Ban`); embed.setTitle(`Case ${logID} | Ban`);
embed.setAuthor(member.user.username, member.user.avatarURL); embed.setColor('#e74c3c');
embed.setThumbnail(member.user.avatarURL); embed.setAuthor(user.username, user.avatarURL);
embed.addField('User', `<@${member.id}>`, true); embed.setThumbnail(user.avatarURL);
embed.addField('User', `<@${user.id}>`, true);
embed.addField('Moderator', `<@${moderator.id}>`, true); embed.addField('Moderator', `<@${moderator.id}>`, true);
if (reason) { if (reason) {
embed.addField('Reason', reason, true); embed.addField('Reason', reason, true);
@ -95,6 +96,7 @@ export default class Moderation {
const embed = new RichEmbed(); const embed = new RichEmbed();
embed.setTitle(`Case ${logID} | Unban`); embed.setTitle(`Case ${logID} | Unban`);
embed.setColor('#1abc9c');
embed.setAuthor(user.username, user.avatarURL); embed.setAuthor(user.username, user.avatarURL);
embed.setThumbnail(user.avatarURL); embed.setThumbnail(user.avatarURL);
embed.addField('User', `<@${user.id}>`, true); embed.addField('User', `<@${user.id}>`, true);