|
@@ -19,6 +19,8 @@ interface ViolationInfo {
|
|
|
guild: Guild;
|
|
|
reason: string;
|
|
|
settings: GuildViolationSettings;
|
|
|
+ dryRun: boolean;
|
|
|
+ noAnnounce: boolean;
|
|
|
}
|
|
|
|
|
|
@Plugin
|
|
@@ -71,6 +73,9 @@ export class ViolationPlugin {
|
|
|
}
|
|
|
|
|
|
private async applyTimedViolation<T extends TimedViolation>(type: ObjectType<T>, info: ViolationInfo, command = "violation", apply: (user: GuildMember) => Promise<void>, remove: (user: GuildMember) => Promise<void>) {
|
|
|
+ if (info.dryRun)
|
|
|
+ return;
|
|
|
+
|
|
|
const violationRepo = getRepository(type);
|
|
|
const existingViolation = await violationRepo.findOne({
|
|
|
where: {
|
|
@@ -169,7 +174,10 @@ export class ViolationPlugin {
|
|
|
return { ok: false };
|
|
|
}
|
|
|
|
|
|
- const [, userId, duration, ...rest] = parseArgs(message.content);
|
|
|
+ const [directive, userId, duration, ...rest] = parseArgs(message.content);
|
|
|
+
|
|
|
+ const dryRun = directive.endsWith("?");
|
|
|
+ const noAnnounce = directive.endsWith("!");
|
|
|
|
|
|
if (!userId) {
|
|
|
await message.reply("no user specified!");
|
|
@@ -206,12 +214,17 @@ export class ViolationPlugin {
|
|
|
member: member,
|
|
|
reason: reason,
|
|
|
settings: settings,
|
|
|
+ dryRun: dryRun,
|
|
|
+ noAnnounce: noAnnounce
|
|
|
};
|
|
|
}
|
|
|
|
|
|
private async sendViolationMessage(message: Message, info: ViolationInfo, title: string) {
|
|
|
let announceChannel: TextChannel | null = null;
|
|
|
- if (info.settings.violationInfoChannelId) {
|
|
|
+ if (info.noAnnounce && message.channel.type == "text") {
|
|
|
+ announceChannel = message.channel;
|
|
|
+ }
|
|
|
+ else if (info.settings.violationInfoChannelId) {
|
|
|
const ch = info.guild.channels.resolve(info.settings.violationInfoChannelId);
|
|
|
if (ch && ch.type == "text")
|
|
|
announceChannel = ch as TextChannel;
|