|
@@ -214,30 +214,30 @@ export class ViolationPlugin {
|
|
|
|
|
|
private async removeTimedViolation<T extends TimedViolation>(type: ObjectType<T>, message: Message, command = "violation") {
|
|
private async removeTimedViolation<T extends TimedViolation>(type: ObjectType<T>, message: Message, command = "violation") {
|
|
if (!message.guild) {
|
|
if (!message.guild) {
|
|
- await message.reply("cannot do in DMs!");
|
|
|
|
|
|
+ await message.reply({ content: "cannot do in DMs!", failIfNotExists: false });
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
const settingsRepo = getRepository(GuildViolationSettings);
|
|
const settingsRepo = getRepository(GuildViolationSettings);
|
|
const settings = await settingsRepo.findOne(message.guild.id);
|
|
const settings = await settingsRepo.findOne(message.guild.id);
|
|
if (!settings) {
|
|
if (!settings) {
|
|
- message.reply("this guild doesn't have violation settings set up!");
|
|
|
|
|
|
+ message.reply({ content: "this guild doesn't have violation settings set up!", failIfNotExists: false });
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
const [, userId] = parseArgs(message.content);
|
|
const [, userId] = parseArgs(message.content);
|
|
if (!userId) {
|
|
if (!userId) {
|
|
- await message.reply("no user specified!");
|
|
|
|
|
|
+ await message.reply({ content: "no user specified!", failIfNotExists: false });
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
if (userId == message.author.id) {
|
|
if (userId == message.author.id) {
|
|
- await message.reply(`cannot ${command} yourself!`);
|
|
|
|
|
|
+ await message.reply({ content: `cannot ${command} yourself!`, failIfNotExists: false });
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
const user = await this.resolveUser(userId);
|
|
const user = await this.resolveUser(userId);
|
|
if (!user) {
|
|
if (!user) {
|
|
- await message.reply("couldn't find the given user!");
|
|
|
|
|
|
+ await message.reply({ content: "couldn't find the given user!", failIfNotExists: false });
|
|
logger.error("Tried to un-%s user %s but couldn't find them by id!", command, userId);
|
|
logger.error("Tried to un-%s user %s but couldn't find them by id!", command, userId);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -251,7 +251,7 @@ export class ViolationPlugin {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
if (!existingViolation) {
|
|
if (!existingViolation) {
|
|
- await message.reply(`user has no existing active ${command}s in the DB!`);
|
|
|
|
|
|
+ await message.reply({ content: `user has no existing active ${command}s in the DB!`, failIfNotExists: false });
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -260,7 +260,7 @@ export class ViolationPlugin {
|
|
|
|
|
|
const handler = this.getViolationHandler(type);
|
|
const handler = this.getViolationHandler(type);
|
|
await handler.stop(message.guild, user.id, settings, existingViolation);
|
|
await handler.stop(message.guild, user.id, settings, existingViolation);
|
|
- await message.reply(`removed ${command} on user!`);
|
|
|
|
|
|
+ await message.reply({ content: `removed ${command} on user!`, failIfNotExists: false });
|
|
}
|
|
}
|
|
|
|
|
|
private async applyTimedViolation<T extends TimedViolation>(type: ObjectType<T>, info: ViolationInfo, command = "violation", apply: StartViolationFunction, remove: StopViolationFunction, modify?: ModifyViolationFunction) {
|
|
private async applyTimedViolation<T extends TimedViolation>(type: ObjectType<T>, info: ViolationInfo, command = "violation", apply: StartViolationFunction, remove: StopViolationFunction, modify?: ModifyViolationFunction) {
|
|
@@ -355,14 +355,14 @@ export class ViolationPlugin {
|
|
|
|
|
|
private async parseCommand(message: Message, command = "violation"): Promise<Option<ViolationInfo>> {
|
|
private async parseCommand(message: Message, command = "violation"): Promise<Option<ViolationInfo>> {
|
|
if (!message.guild) {
|
|
if (!message.guild) {
|
|
- await message.reply("cannot do in DMs!");
|
|
|
|
|
|
+ await message.reply({ content: "cannot do in DMs!", failIfNotExists: false });
|
|
return { ok: false };
|
|
return { ok: false };
|
|
}
|
|
}
|
|
const violationSettingsRepo = getRepository(GuildViolationSettings);
|
|
const violationSettingsRepo = getRepository(GuildViolationSettings);
|
|
const settings = await violationSettingsRepo.findOne(message.guild.id);
|
|
const settings = await violationSettingsRepo.findOne(message.guild.id);
|
|
|
|
|
|
if (!settings) {
|
|
if (!settings) {
|
|
- await message.reply("sorry, this server doesn't have violation settings set up.");
|
|
|
|
|
|
+ await message.reply({ content: "sorry, this server doesn't have violation settings set up.", failIfNotExists: false });
|
|
logger.error(
|
|
logger.error(
|
|
"%s was called in guild %s (%s) on user %s which doesn't have config set up!",
|
|
"%s was called in guild %s (%s) on user %s which doesn't have config set up!",
|
|
command,
|
|
command,
|
|
@@ -378,37 +378,37 @@ export class ViolationPlugin {
|
|
const noAnnounce = directive.endsWith("!");
|
|
const noAnnounce = directive.endsWith("!");
|
|
|
|
|
|
if (!userId) {
|
|
if (!userId) {
|
|
- await message.reply("no user specified!");
|
|
|
|
|
|
+ await message.reply({ content: "no user specified!", failIfNotExists: false });
|
|
return { ok: false };
|
|
return { ok: false };
|
|
}
|
|
}
|
|
|
|
|
|
const user = await this.resolveUser(userId);
|
|
const user = await this.resolveUser(userId);
|
|
|
|
|
|
if (!user) {
|
|
if (!user) {
|
|
- await message.reply("couldn't find the given user!");
|
|
|
|
|
|
+ await message.reply({ content: "couldn't find the given user!", failIfNotExists: false });
|
|
logger.error("Tried to %s user %s but couldn't find them by id!", command, userId);
|
|
logger.error("Tried to %s user %s but couldn't find them by id!", command, userId);
|
|
return { ok: false };
|
|
return { ok: false };
|
|
}
|
|
}
|
|
|
|
|
|
if (user.id == message.author.id) {
|
|
if (user.id == message.author.id) {
|
|
- await message.reply(`cannot ${command} yourself!`);
|
|
|
|
|
|
+ await message.reply({ content: `cannot ${command} yourself!`, failIfNotExists: false });
|
|
return { ok: false };
|
|
return { ok: false };
|
|
}
|
|
}
|
|
|
|
|
|
if (user.id == client.botUser.id) {
|
|
if (user.id == client.botUser.id) {
|
|
- await message.reply(`cannot apply ${command} on me!`);
|
|
|
|
|
|
+ await message.reply({ content: `cannot apply ${command} on me!`, failIfNotExists: false });
|
|
return { ok: false };
|
|
return { ok: false };
|
|
}
|
|
}
|
|
|
|
|
|
const memberResolve = await tryDo(message.guild.members.fetch(user));
|
|
const memberResolve = await tryDo(message.guild.members.fetch(user));
|
|
if (!memberResolve.ok) {
|
|
if (!memberResolve.ok) {
|
|
- await message.reply("user is not member of the server anymore!");
|
|
|
|
|
|
+ await message.reply({ content: "user is not member of the server anymore!", failIfNotExists: false });
|
|
logger.error("Tried to %s user %s but they are not on the server anymore!", command, userId);
|
|
logger.error("Tried to %s user %s but they are not on the server anymore!", command, userId);
|
|
return { ok: false };
|
|
return { ok: false };
|
|
}
|
|
}
|
|
|
|
|
|
if (await isAuthorisedAsync(memberResolve.result)) {
|
|
if (await isAuthorisedAsync(memberResolve.result)) {
|
|
- await message.reply(`cannot apply ${command} on another moderator!`);
|
|
|
|
|
|
+ await message.reply({ content: `cannot apply ${command} on another moderator!`, failIfNotExists: false });
|
|
return { ok: false };
|
|
return { ok: false };
|
|
}
|
|
}
|
|
|
|
|