Some fixes and cleanup
This commit is contained in:
parent
338855de15
commit
7f0833f699
3 changed files with 19 additions and 13 deletions
|
@ -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<ILogsPluginConfig> {
|
|||
);
|
||||
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")
|
||||
|
|
|
@ -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<IModActionsPluginConfig> {
|
|||
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<IModActionsPluginConfig> {
|
|||
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"}`);
|
||||
|
|
|
@ -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",
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue