diff --git a/src/plugins/Logs.ts b/src/plugins/Logs.ts index edb0d913..1b972495 100644 --- a/src/plugins/Logs.ts +++ b/src/plugins/Logs.ts @@ -10,6 +10,7 @@ import { findRelevantAuditLogEntry, noop, stripObjectToScalars, + unknownUser, useMediaUrls, } from "../utils"; import DefaultLogMessages from "../data/DefaultLogMessages.json"; @@ -35,12 +36,6 @@ interface ILogChannelMap { [channelId: string]: ILogChannel; } -const unknownUser = { - id: 0, - username: "Unknown", - discriminator: "0000", -}; - interface IChannelConfig { include?: string[]; exclude?: string[]; @@ -263,10 +258,14 @@ export class LogsPlugin extends ZeppelinPlugin { ); const mod = relevantAuditLogEntry ? relevantAuditLogEntry.user : unknownUser; - this.guildLogs.log(LogType.MEMBER_BAN, { - mod: stripObjectToScalars(mod), - user: stripObjectToScalars(user), - }, user.id); + this.guildLogs.log( + LogType.MEMBER_BAN, + { + mod: stripObjectToScalars(mod), + user: stripObjectToScalars(user), + }, + user.id, + ); } @d.event("guildBanRemove") diff --git a/src/plugins/ModActions.ts b/src/plugins/ModActions.ts index 0b2987d6..3dd8b0d7 100644 --- a/src/plugins/ModActions.ts +++ b/src/plugins/ModActions.ts @@ -13,6 +13,7 @@ import { stripObjectToScalars, successMessage, trimLines, + unknownUser, } from "../utils"; import { GuildMutes } from "../data/GuildMutes"; import { CaseTypes } from "../data/CaseTypes"; @@ -763,7 +764,7 @@ export class ModActionsPlugin extends ZeppelinPlugin { this.ignoreEvent(IgnoredEventType.Unban, args.userId); await this.guild.unbanMember(args.userId); } catch (e) { - msg.channel.createMessage(errorMessage("Failed to unban member")); + msg.channel.createMessage(errorMessage("Failed to unban member; are you sure they're banned?")); return; } @@ -1030,8 +1031,8 @@ export class ModActionsPlugin extends ZeppelinPlugin { const normalCases = cases.filter(c => !c.is_hidden); const hiddenCases = cases.filter(c => c.is_hidden); - const user = this.bot.users.get(args.userId); - const userName = user ? `${user.username}#${user.discriminator}` : "Unknown#0000"; + const user = this.bot.users.get(args.userId) || unknownUser; + const userName = `${user.username}#${user.discriminator}`; if (cases.length === 0) { msg.channel.createMessage(`No cases found for ${user ? `**${userName}**` : "the specified user"}`); diff --git a/src/utils.ts b/src/utils.ts index 31983c92..88ef39c6 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -494,3 +494,9 @@ export function ucfirst(str) { if (typeof str !== "string" || str === "") return str; return str[0].toUpperCase() + str.slice(1); } + +export const unknownUser = { + id: "0", + username: "Unknown", + discriminator: "0000", +};