Add case number to mod action confirmations
This commit is contained in:
parent
ce0b7ded08
commit
8d59420579
1 changed files with 56 additions and 32 deletions
|
@ -275,14 +275,14 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
const user = await this.bot.users.get(args.userId);
|
const user = await this.bot.users.get(args.userId);
|
||||||
const userName = user ? `${user.username}#${user.discriminator}` : "member";
|
const userName = user ? `${user.username}#${user.discriminator}` : "member";
|
||||||
|
|
||||||
await this.actions.fire("createCase", {
|
const createdCase = await this.actions.fire("createCase", {
|
||||||
userId: args.userId,
|
userId: args.userId,
|
||||||
modId: msg.author.id,
|
modId: msg.author.id,
|
||||||
type: CaseTypes.Note,
|
type: CaseTypes.Note,
|
||||||
reason: args.note
|
reason: args.note
|
||||||
});
|
});
|
||||||
|
|
||||||
msg.channel.createMessage(successMessage(`Note added on ${userName}`));
|
msg.channel.createMessage(successMessage(`Note added on ${userName} (Case #${createdCase.case_number})`));
|
||||||
}
|
}
|
||||||
|
|
||||||
@d.command("warn", "<member:Member> <reason:string$>")
|
@d.command("warn", "<member:Member> <reason:string$>")
|
||||||
|
@ -315,7 +315,7 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.actions.fire("createCase", {
|
const createdCase: Case = await this.actions.fire("createCase", {
|
||||||
userId: args.member.id,
|
userId: args.member.id,
|
||||||
modId: msg.author.id,
|
modId: msg.author.id,
|
||||||
type: CaseTypes.Warn,
|
type: CaseTypes.Warn,
|
||||||
|
@ -323,7 +323,9 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
});
|
});
|
||||||
|
|
||||||
msg.channel.createMessage(
|
msg.channel.createMessage(
|
||||||
successMessage(`Warned **${args.member.user.username}#${args.member.user.discriminator}**`)
|
successMessage(
|
||||||
|
`Warned **${args.member.user.username}#${args.member.user.discriminator}** (Case #${createdCase.case_number})`
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.serverLogs.log(LogType.MEMBER_WARN, {
|
this.serverLogs.log(LogType.MEMBER_WARN, {
|
||||||
|
@ -371,7 +373,11 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
|
|
||||||
const hasOldCase = mute.case_id != null;
|
const hasOldCase = mute.case_id != null;
|
||||||
|
|
||||||
|
let theCase;
|
||||||
|
|
||||||
if (hasOldCase) {
|
if (hasOldCase) {
|
||||||
|
theCase = await this.cases.find(mute.case_id);
|
||||||
|
|
||||||
if (args.reason) {
|
if (args.reason) {
|
||||||
// Update old case
|
// Update old case
|
||||||
await this.actions.fire("createCaseNote", mute.case_id, {
|
await this.actions.fire("createCaseNote", mute.case_id, {
|
||||||
|
@ -381,7 +387,7 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Create new case
|
// Create new case
|
||||||
const theCase: Case = await this.actions.fire("createCase", {
|
theCase = await this.actions.fire("createCase", {
|
||||||
userId: args.member.id,
|
userId: args.member.id,
|
||||||
modId: msg.author.id,
|
modId: msg.author.id,
|
||||||
type: CaseTypes.Mute,
|
type: CaseTypes.Mute,
|
||||||
|
@ -412,9 +418,13 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
// Confirm the action to the moderator
|
// Confirm the action to the moderator
|
||||||
let response;
|
let response;
|
||||||
if (muteTime) {
|
if (muteTime) {
|
||||||
response = `Muted **${args.member.user.username}#${args.member.user.discriminator}** for ${timeUntilUnmute}`;
|
response = `Muted **${args.member.user.username}#${
|
||||||
|
args.member.user.discriminator
|
||||||
|
}** for ${timeUntilUnmute} (Case #${theCase.case_number})`;
|
||||||
} else {
|
} else {
|
||||||
response = `Muted **${args.member.user.username}#${args.member.user.discriminator}** indefinitely`;
|
response = `Muted **${args.member.user.username}#${args.member.user.discriminator}** indefinitely (Case #${
|
||||||
|
theCase.case_number
|
||||||
|
})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!messageSent) response += " (failed to message user)";
|
if (!messageSent) response += " (failed to message user)";
|
||||||
|
@ -456,6 +466,14 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
args.reason = `${args.time} ${args.reason ? args.reason : ""}`.trim();
|
args.reason = `${args.time} ${args.reason ? args.reason : ""}`.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a case
|
||||||
|
const createdCase = await this.actions.fire("createCase", {
|
||||||
|
userId: args.member.id,
|
||||||
|
modId: msg.author.id,
|
||||||
|
type: CaseTypes.Unmute,
|
||||||
|
reason: args.reason
|
||||||
|
});
|
||||||
|
|
||||||
if (unmuteTime) {
|
if (unmuteTime) {
|
||||||
// If we have an unmute time, just update the old mute to expire in that time
|
// If we have an unmute time, just update the old mute to expire in that time
|
||||||
const timeUntilUnmute = unmuteTime && humanizeDuration(unmuteTime);
|
const timeUntilUnmute = unmuteTime && humanizeDuration(unmuteTime);
|
||||||
|
@ -465,7 +483,9 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
// Confirm the action to the moderator
|
// Confirm the action to the moderator
|
||||||
msg.channel.createMessage(
|
msg.channel.createMessage(
|
||||||
successMessage(
|
successMessage(
|
||||||
`Unmuting **${args.member.user.username}#${args.member.user.discriminator}** in ${timeUntilUnmute}`
|
`Unmuting **${args.member.user.username}#${args.member.user.discriminator}** in ${timeUntilUnmute} (Case #${
|
||||||
|
createdCase.case_number
|
||||||
|
})`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -475,18 +495,14 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
|
|
||||||
// Confirm the action to the moderator
|
// Confirm the action to the moderator
|
||||||
msg.channel.createMessage(
|
msg.channel.createMessage(
|
||||||
successMessage(`Unmuted **${args.member.user.username}#${args.member.user.discriminator}**`)
|
successMessage(
|
||||||
|
`Unmuted **${args.member.user.username}#${args.member.user.discriminator}** (Case #${
|
||||||
|
createdCase.case_number
|
||||||
|
})`
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a case
|
|
||||||
await this.actions.fire("createCase", {
|
|
||||||
userId: args.member.id,
|
|
||||||
modId: msg.author.id,
|
|
||||||
type: CaseTypes.Unmute,
|
|
||||||
reason: args.reason
|
|
||||||
});
|
|
||||||
|
|
||||||
// Log the action
|
// Log the action
|
||||||
this.serverLogs.log(LogType.MEMBER_UNMUTE, {
|
this.serverLogs.log(LogType.MEMBER_UNMUTE, {
|
||||||
mod: stripObjectToScalars(msg.member.user),
|
mod: stripObjectToScalars(msg.member.user),
|
||||||
|
@ -531,7 +547,7 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
args.member.kick(args.reason);
|
args.member.kick(args.reason);
|
||||||
|
|
||||||
// Create a case for this action
|
// Create a case for this action
|
||||||
await this.actions.fire("createCase", {
|
const createdCase = await this.actions.fire("createCase", {
|
||||||
userId: args.member.id,
|
userId: args.member.id,
|
||||||
modId: msg.author.id,
|
modId: msg.author.id,
|
||||||
type: CaseTypes.Kick,
|
type: CaseTypes.Kick,
|
||||||
|
@ -539,7 +555,9 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Confirm the action to the moderator
|
// Confirm the action to the moderator
|
||||||
let response = `Kicked **${args.member.user.username}#${args.member.user.discriminator}**`;
|
let response = `Kicked **${args.member.user.username}#${args.member.user.discriminator}** (Case #${
|
||||||
|
createdCase.case_number
|
||||||
|
})`;
|
||||||
if (!messageSent) response += " (failed to message user)";
|
if (!messageSent) response += " (failed to message user)";
|
||||||
msg.channel.createMessage(successMessage(response));
|
msg.channel.createMessage(successMessage(response));
|
||||||
|
|
||||||
|
@ -581,7 +599,7 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
args.member.ban(1, args.reason);
|
args.member.ban(1, args.reason);
|
||||||
|
|
||||||
// Create a case for this action
|
// Create a case for this action
|
||||||
await this.actions.fire("createCase", {
|
const createdCase = await this.actions.fire("createCase", {
|
||||||
userId: args.member.id,
|
userId: args.member.id,
|
||||||
modId: msg.author.id,
|
modId: msg.author.id,
|
||||||
type: CaseTypes.Ban,
|
type: CaseTypes.Ban,
|
||||||
|
@ -589,7 +607,9 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Confirm the action to the moderator
|
// Confirm the action to the moderator
|
||||||
let response = `Banned **${args.member.user.username}#${args.member.user.discriminator}**`;
|
let response = `Banned **${args.member.user.username}#${args.member.user.discriminator}** (Case #${
|
||||||
|
createdCase.case_number
|
||||||
|
})`;
|
||||||
if (!messageSent) response += " (failed to message user)";
|
if (!messageSent) response += " (failed to message user)";
|
||||||
msg.channel.createMessage(successMessage(response));
|
msg.channel.createMessage(successMessage(response));
|
||||||
|
|
||||||
|
@ -619,7 +639,7 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
await this.guild.unbanMember(args.member.id);
|
await this.guild.unbanMember(args.member.id);
|
||||||
|
|
||||||
// Create a case for this action
|
// Create a case for this action
|
||||||
await this.actions.fire("createCase", {
|
const createdCase = await this.actions.fire("createCase", {
|
||||||
userId: args.member.id,
|
userId: args.member.id,
|
||||||
modId: msg.author.id,
|
modId: msg.author.id,
|
||||||
type: CaseTypes.Softban,
|
type: CaseTypes.Softban,
|
||||||
|
@ -628,7 +648,11 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
|
|
||||||
// Confirm the action to the moderator
|
// Confirm the action to the moderator
|
||||||
msg.channel.createMessage(
|
msg.channel.createMessage(
|
||||||
successMessage(`Softbanned **${args.member.user.username}#${args.member.user.discriminator}**`)
|
successMessage(
|
||||||
|
`Softbanned **${args.member.user.username}#${args.member.user.discriminator}** (Case #${
|
||||||
|
createdCase.case_number
|
||||||
|
})`
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Log the action
|
// Log the action
|
||||||
|
@ -651,17 +675,17 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Confirm the action
|
|
||||||
msg.channel.createMessage(successMessage("Member unbanned!"));
|
|
||||||
|
|
||||||
// Create a case
|
// Create a case
|
||||||
await this.actions.fire("createCase", {
|
const createdCase = await this.actions.fire("createCase", {
|
||||||
userId: args.userId,
|
userId: args.userId,
|
||||||
modId: msg.author.id,
|
modId: msg.author.id,
|
||||||
type: CaseTypes.Unban,
|
type: CaseTypes.Unban,
|
||||||
reason: args.reason
|
reason: args.reason
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Confirm the action
|
||||||
|
msg.channel.createMessage(successMessage(`Member unbanned (Case #${createdCase.case_number})`));
|
||||||
|
|
||||||
// Log the action
|
// Log the action
|
||||||
this.serverLogs.log(LogType.MEMBER_UNBAN, {
|
this.serverLogs.log(LogType.MEMBER_UNBAN, {
|
||||||
mod: stripObjectToScalars(msg.member.user),
|
mod: stripObjectToScalars(msg.member.user),
|
||||||
|
@ -689,17 +713,17 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Confirm the action
|
|
||||||
msg.channel.createMessage(successMessage("Member forcebanned!"));
|
|
||||||
|
|
||||||
// Create a case
|
// Create a case
|
||||||
await this.actions.fire("createCase", {
|
const createdCase = await this.actions.fire("createCase", {
|
||||||
userId: args.userId,
|
userId: args.userId,
|
||||||
modId: msg.author.id,
|
modId: msg.author.id,
|
||||||
type: CaseTypes.Ban,
|
type: CaseTypes.Ban,
|
||||||
reason: args.reason
|
reason: args.reason
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Confirm the action
|
||||||
|
msg.channel.createMessage(successMessage(`Member forcebanned (Case #${createdCase.case_number})`));
|
||||||
|
|
||||||
// Log the action
|
// Log the action
|
||||||
this.serverLogs.log(LogType.MEMBER_FORCEBAN, {
|
this.serverLogs.log(LogType.MEMBER_FORCEBAN, {
|
||||||
mod: stripObjectToScalars(msg.member.user),
|
mod: stripObjectToScalars(msg.member.user),
|
||||||
|
@ -820,7 +844,7 @@ export class ModActionsPlugin extends ZeppelinPlugin {
|
||||||
reason: args.reason
|
reason: args.reason
|
||||||
});
|
});
|
||||||
|
|
||||||
msg.channel.createMessage(successMessage("Case created!"));
|
msg.channel.createMessage(successMessage(`Case #${theCase.case_number} created`));
|
||||||
|
|
||||||
// Log the action
|
// Log the action
|
||||||
this.serverLogs.log(LogType.CASE_CREATE, {
|
this.serverLogs.log(LogType.CASE_CREATE, {
|
||||||
|
|
Loading…
Add table
Reference in a new issue