mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-17 23:25:02 +00:00
Using waitForReaction to ask if we shall go on or not instead of notify
This commit is contained in:
parent
a6aacc1998
commit
565aed44a9
2 changed files with 40 additions and 19 deletions
|
@ -266,4 +266,19 @@ export class CasesPlugin extends ZeppelinPlugin<ICasesPluginConfig> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getCaseTypeAmountForUserId(userID: string, type: CaseTypes) {
|
||||||
|
const cases = (await this.cases.getByUserId(userID)).filter(c => !c.is_hidden);
|
||||||
|
let typeAmount = 0;
|
||||||
|
|
||||||
|
if (cases.length > 0) {
|
||||||
|
cases.forEach(singleCase => {
|
||||||
|
if (singleCase.type == type.valueOf()) {
|
||||||
|
typeAmount++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return typeAmount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,8 @@ interface IModActionsPluginConfig {
|
||||||
ban_message: string;
|
ban_message: string;
|
||||||
alert_on_rejoin: boolean;
|
alert_on_rejoin: boolean;
|
||||||
alert_channel: string;
|
alert_channel: string;
|
||||||
|
warn_notify_threshold: number;
|
||||||
|
warn_threshold_message: string;
|
||||||
|
|
||||||
can_note: boolean;
|
can_note: boolean;
|
||||||
can_warn: boolean;
|
can_warn: boolean;
|
||||||
|
@ -97,6 +99,8 @@ export class ModActionsPlugin extends ZeppelinPlugin<IModActionsPluginConfig> {
|
||||||
ban_message: "You have been banned from {guildName}. Reason given: {reason}",
|
ban_message: "You have been banned from {guildName}. Reason given: {reason}",
|
||||||
alert_on_rejoin: false,
|
alert_on_rejoin: false,
|
||||||
alert_channel: null,
|
alert_channel: null,
|
||||||
|
warn_notify_threshold: 5,
|
||||||
|
warn_threshold_message: "The user already has {priorWarnings} warnings. Proceed anyways?",
|
||||||
|
|
||||||
can_note: false,
|
can_note: false,
|
||||||
can_warn: false,
|
can_warn: false,
|
||||||
|
@ -256,9 +260,7 @@ export class ModActionsPlugin extends ZeppelinPlugin<IModActionsPluginConfig> {
|
||||||
if (actions.length) {
|
if (actions.length) {
|
||||||
const alertChannel: any = this.guild.channels.get(alertChannelId);
|
const alertChannel: any = this.guild.channels.get(alertChannelId);
|
||||||
alertChannel.send(
|
alertChannel.send(
|
||||||
`<@!${member.id}> (${member.user.username}#${member.user.discriminator} \`${member.id}\`) joined with ${
|
`<@!${member.id}> (${member.user.username}#${member.user.discriminator} \`${member.id}\`) joined with ${actions.length} prior record(s)`,
|
||||||
actions.length
|
|
||||||
} prior record(s)`,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -280,9 +282,7 @@ export class ModActionsPlugin extends ZeppelinPlugin<IModActionsPluginConfig> {
|
||||||
const existingCaseForThisEntry = await this.cases.findByAuditLogId(kickAuditLogEntry.id);
|
const existingCaseForThisEntry = await this.cases.findByAuditLogId(kickAuditLogEntry.id);
|
||||||
if (existingCaseForThisEntry) {
|
if (existingCaseForThisEntry) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`Tried to create duplicate case for audit log entry ${kickAuditLogEntry.id}, existing case id ${
|
`Tried to create duplicate case for audit log entry ${kickAuditLogEntry.id}, existing case id ${existingCaseForThisEntry.id}`,
|
||||||
existingCaseForThisEntry.id
|
|
||||||
}`,
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const casesPlugin = this.getPlugin<CasesPlugin>("cases");
|
const casesPlugin = this.getPlugin<CasesPlugin>("cases");
|
||||||
|
@ -406,6 +406,21 @@ export class ModActionsPlugin extends ZeppelinPlugin<IModActionsPluginConfig> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = this.getConfig();
|
const config = this.getConfig();
|
||||||
|
|
||||||
|
const casesPlugin = this.getPlugin<CasesPlugin>("cases");
|
||||||
|
|
||||||
|
const priorWarnAmount = await casesPlugin.getCaseTypeAmountForUserId(memberToWarn.id, CaseTypes.Warn);
|
||||||
|
if (priorWarnAmount >= config.warn_notify_threshold) {
|
||||||
|
const tooManyWarningsMsg = await msg.channel.createMessage(
|
||||||
|
config.warn_threshold_message.replace("{priorWarnings}", `${priorWarnAmount}`),
|
||||||
|
);
|
||||||
|
const reply = await waitForReaction(this.bot, tooManyWarningsMsg, ["✅", "❌"], msg.author.id);
|
||||||
|
tooManyWarningsMsg.delete();
|
||||||
|
if (!reply || reply.name === "❌") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const reason = this.formatReasonWithAttachments(args.reason, msg.attachments);
|
const reason = this.formatReasonWithAttachments(args.reason, msg.attachments);
|
||||||
|
|
||||||
const warnMessage = config.warn_message.replace("{guildName}", this.guild.name).replace("{reason}", reason);
|
const warnMessage = config.warn_message.replace("{guildName}", this.guild.name).replace("{reason}", reason);
|
||||||
|
@ -424,7 +439,6 @@ export class ModActionsPlugin extends ZeppelinPlugin<IModActionsPluginConfig> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const casesPlugin = this.getPlugin<CasesPlugin>("cases");
|
|
||||||
const createdCase = await casesPlugin.createCase({
|
const createdCase = await casesPlugin.createCase({
|
||||||
userId: memberToWarn.id,
|
userId: memberToWarn.id,
|
||||||
modId: mod.id,
|
modId: mod.id,
|
||||||
|
@ -438,9 +452,7 @@ export class ModActionsPlugin extends ZeppelinPlugin<IModActionsPluginConfig> {
|
||||||
|
|
||||||
msg.channel.createMessage(
|
msg.channel.createMessage(
|
||||||
successMessage(
|
successMessage(
|
||||||
`Warned **${memberToWarn.user.username}#${memberToWarn.user.discriminator}** (Case #${
|
`Warned **${memberToWarn.user.username}#${memberToWarn.user.discriminator}** (Case #${createdCase.case_number})${messageResultText}`,
|
||||||
createdCase.case_number
|
|
||||||
})${messageResultText}`,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -773,9 +785,7 @@ export class ModActionsPlugin extends ZeppelinPlugin<IModActionsPluginConfig> {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Confirm the action to the moderator
|
// Confirm the action to the moderator
|
||||||
let response = `Kicked **${memberToKick.user.username}#${memberToKick.user.discriminator}** (Case #${
|
let response = `Kicked **${memberToKick.user.username}#${memberToKick.user.discriminator}** (Case #${createdCase.case_number})`;
|
||||||
createdCase.case_number
|
|
||||||
})`;
|
|
||||||
|
|
||||||
if (userMessageResult.text) response += ` (${userMessageResult.text})`;
|
if (userMessageResult.text) response += ` (${userMessageResult.text})`;
|
||||||
msg.channel.createMessage(successMessage(response));
|
msg.channel.createMessage(successMessage(response));
|
||||||
|
@ -860,9 +870,7 @@ export class ModActionsPlugin extends ZeppelinPlugin<IModActionsPluginConfig> {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Confirm the action to the moderator
|
// Confirm the action to the moderator
|
||||||
let response = `Banned **${memberToBan.user.username}#${memberToBan.user.discriminator}** (Case #${
|
let response = `Banned **${memberToBan.user.username}#${memberToBan.user.discriminator}** (Case #${createdCase.case_number})`;
|
||||||
createdCase.case_number
|
|
||||||
})`;
|
|
||||||
|
|
||||||
if (userMessageResult.text) response += ` (${userMessageResult.text})`;
|
if (userMessageResult.text) response += ` (${userMessageResult.text})`;
|
||||||
msg.channel.createMessage(successMessage(response));
|
msg.channel.createMessage(successMessage(response));
|
||||||
|
@ -936,9 +944,7 @@ export class ModActionsPlugin extends ZeppelinPlugin<IModActionsPluginConfig> {
|
||||||
// Confirm the action to the moderator
|
// Confirm the action to the moderator
|
||||||
msg.channel.createMessage(
|
msg.channel.createMessage(
|
||||||
successMessage(
|
successMessage(
|
||||||
`Softbanned **${memberToSoftban.user.username}#${memberToSoftban.user.discriminator}** (Case #${
|
`Softbanned **${memberToSoftban.user.username}#${memberToSoftban.user.discriminator}** (Case #${createdCase.case_number})`,
|
||||||
createdCase.case_number
|
|
||||||
})`,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue