From 6800fa832c3f9078769579a91374673797287f35 Mon Sep 17 00:00:00 2001 From: Dark <7890309+DarkView@users.noreply.github.com> Date: Wed, 29 Jul 2020 00:38:23 +0200 Subject: [PATCH 1/6] Fix follow -active not being a switch --- backend/src/plugins/LocateUser/commands/FollowCmd.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/plugins/LocateUser/commands/FollowCmd.ts b/backend/src/plugins/LocateUser/commands/FollowCmd.ts index 8b562aee..bcbd253d 100644 --- a/backend/src/plugins/LocateUser/commands/FollowCmd.ts +++ b/backend/src/plugins/LocateUser/commands/FollowCmd.ts @@ -16,7 +16,7 @@ export const FollowCmd = locateUserCommand({ reminder: ct.string({ required: false, catchAll: true }), duration: ct.delay({ option: true, shortcut: "d" }), - active: ct.bool({ option: true, shortcut: "a" }), + active: ct.bool({ option: true, shortcut: "a", isSwitch: true }), }, async run({ message: msg, args, pluginData }) { From ccd8b0d07b61895a0fc96c6a5d20b927204b7ccc Mon Sep 17 00:00:00 2001 From: Dark <7890309+DarkView@users.noreply.github.com> Date: Wed, 29 Jul 2020 01:04:17 +0200 Subject: [PATCH 2/6] Have forcemute not DM the user -> Consistency with Forceban --- backend/src/plugins/ModActions/commands/ForcemuteCmd.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/plugins/ModActions/commands/ForcemuteCmd.ts b/backend/src/plugins/ModActions/commands/ForcemuteCmd.ts index ad505f93..f61ae5a8 100644 --- a/backend/src/plugins/ModActions/commands/ForcemuteCmd.ts +++ b/backend/src/plugins/ModActions/commands/ForcemuteCmd.ts @@ -43,6 +43,6 @@ export const ForcemuteCmd = modActionsCommand({ return; } - actualMuteUserCmd(pluginData, user, msg, args); + actualMuteUserCmd(pluginData, user, msg, { ...args, notify: "none" }); }, }); From eeaf1d8616b4f957b9d9b6c45b4ac3d3ce425b80 Mon Sep 17 00:00:00 2001 From: Dark <7890309+DarkView@users.noreply.github.com> Date: Wed, 29 Jul 2020 01:14:02 +0200 Subject: [PATCH 3/6] Fix rejoin mutes not working --- backend/src/plugins/Mutes/MutesPlugin.ts | 4 ++++ .../events/ClearActiveMuteOnMemberBanEvt.ts | 15 +++++++++++++ .../events/ReapplyActiveMuteOnJoinEvt.ts | 22 +++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 backend/src/plugins/Mutes/events/ClearActiveMuteOnMemberBanEvt.ts create mode 100644 backend/src/plugins/Mutes/events/ReapplyActiveMuteOnJoinEvt.ts diff --git a/backend/src/plugins/Mutes/MutesPlugin.ts b/backend/src/plugins/Mutes/MutesPlugin.ts index 597d450b..1d477892 100644 --- a/backend/src/plugins/Mutes/MutesPlugin.ts +++ b/backend/src/plugins/Mutes/MutesPlugin.ts @@ -15,6 +15,8 @@ import { muteUser } from "./functions/muteUser"; import { unmuteUser } from "./functions/unmuteUser"; import { CaseArgs } from "../Cases/types"; import { Member } from "eris"; +import { ClearActiveMuteOnMemberBanEvt } from "./events/ClearActiveMuteOnMemberBanEvt"; +import { ReapplyActiveMuteOnJoinEvt } from "./events/ReapplyActiveMuteOnJoinEvt"; const defaultOptions = { config: { @@ -70,6 +72,8 @@ export const MutesPlugin = zeppelinPlugin()("mutes", { // prettier-ignore events: [ ClearActiveMuteOnRoleRemovalEvt, + ClearActiveMuteOnMemberBanEvt, + ReapplyActiveMuteOnJoinEvt, ], public: { diff --git a/backend/src/plugins/Mutes/events/ClearActiveMuteOnMemberBanEvt.ts b/backend/src/plugins/Mutes/events/ClearActiveMuteOnMemberBanEvt.ts new file mode 100644 index 00000000..ff2756e3 --- /dev/null +++ b/backend/src/plugins/Mutes/events/ClearActiveMuteOnMemberBanEvt.ts @@ -0,0 +1,15 @@ +import { eventListener } from "knub"; +import { MutesPluginType } from "../types"; + +/** + * Clear active mute from the member if the member is banned + */ +export const ClearActiveMuteOnMemberBanEvt = eventListener()( + "guildBanAdd", + async ({ pluginData, args: { user } }) => { + const mute = await pluginData.state.mutes.findExistingMuteForUserId(user.id); + if (mute) { + pluginData.state.mutes.clear(user.id); + } + }, +); diff --git a/backend/src/plugins/Mutes/events/ReapplyActiveMuteOnJoinEvt.ts b/backend/src/plugins/Mutes/events/ReapplyActiveMuteOnJoinEvt.ts new file mode 100644 index 00000000..13eeafc5 --- /dev/null +++ b/backend/src/plugins/Mutes/events/ReapplyActiveMuteOnJoinEvt.ts @@ -0,0 +1,22 @@ +import { eventListener } from "knub"; +import { MutesPluginType } from "../types"; +import { LogType } from "src/data/LogType"; +import { stripObjectToScalars } from "src/utils"; + +/** + * Reapply active mutes on join + */ +export const ReapplyActiveMuteOnJoinEvt = eventListener()( + "guildMemberAdd", + async ({ pluginData, args: { member } }) => { + const mute = await pluginData.state.mutes.findExistingMuteForUserId(member.id); + if (mute) { + const muteRole = pluginData.config.get().mute_role; + await member.addRole(muteRole); + + pluginData.state.serverLogs.log(LogType.MEMBER_MUTE_REJOIN, { + member: stripObjectToScalars(member, ["user", "roles"]), + }); + } + }, +); From 43f26f4c0d41d8fa0e8905608c6332acf63c04e0 Mon Sep 17 00:00:00 2001 From: Dark <7890309+DarkView@users.noreply.github.com> Date: Wed, 29 Jul 2020 01:28:00 +0200 Subject: [PATCH 4/6] Add "use maincontent instead of -content" to post_embed --- backend/src/plugins/Post/commands/PostEmbedCmd.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/src/plugins/Post/commands/PostEmbedCmd.ts b/backend/src/plugins/Post/commands/PostEmbedCmd.ts index 299aef7c..707b97f5 100644 --- a/backend/src/plugins/Post/commands/PostEmbedCmd.ts +++ b/backend/src/plugins/Post/commands/PostEmbedCmd.ts @@ -3,7 +3,7 @@ import { commandTypeHelpers as ct } from "../../../commandTypes"; import { actualPostCmd } from "../util/actualPostCmd"; import { sendErrorMessage } from "src/pluginUtils"; import { Embed } from "eris"; -import { isValidEmbed } from "src/utils"; +import { isValidEmbed, trimLines } from "src/utils"; import { formatContent } from "../util/formatContent"; const COLOR_MATCH_REGEX = /^#?([0-9a-f]{6})$/; @@ -71,6 +71,17 @@ export const PostEmbedCmd = postCmd({ } } + if (args.content) { + const prefix = pluginData.guildConfig.prefix || "!"; + msg.channel.createMessage( + trimLines(` + <@!${msg.author.id}> You can now specify an embed's content directly at the end of the command: + \`${prefix}edit_embed -title "Some title" content goes here\` + The \`-content\` option will soon be removed in favor of this. + `), + ); + } + actualPostCmd(pluginData, msg, args.channel, { embed }, args); }, }); From a8c83d6811ccc81d4367de87c2131a6c6665c462 Mon Sep 17 00:00:00 2001 From: Dark <7890309+DarkView@users.noreply.github.com> Date: Wed, 29 Jul 2020 01:32:57 +0200 Subject: [PATCH 5/6] Fix crash on reminder id 0 --- backend/src/plugins/Reminders/commands/RemindersDeleteCmd.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/plugins/Reminders/commands/RemindersDeleteCmd.ts b/backend/src/plugins/Reminders/commands/RemindersDeleteCmd.ts index e31677b4..6196d198 100644 --- a/backend/src/plugins/Reminders/commands/RemindersDeleteCmd.ts +++ b/backend/src/plugins/Reminders/commands/RemindersDeleteCmd.ts @@ -16,7 +16,7 @@ export const RemindersDeleteCmd = remindersCommand({ reminders.sort(sorter("remind_at")); const lastNum = reminders.length + 1; - if (args.num > lastNum || args.num < 0) { + if (args.num > lastNum || args.num <= 0) { sendErrorMessage(pluginData, msg.channel, "Unknown reminder"); return; } From fcda64d5b82327b6b3f4fb65458645411c6ac05d Mon Sep 17 00:00:00 2001 From: Dark <7890309+DarkView@users.noreply.github.com> Date: Wed, 29 Jul 2020 01:42:16 +0200 Subject: [PATCH 6/6] Fix crash on reminder id length+1 --- backend/src/plugins/Reminders/commands/RemindersDeleteCmd.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/src/plugins/Reminders/commands/RemindersDeleteCmd.ts b/backend/src/plugins/Reminders/commands/RemindersDeleteCmd.ts index 6196d198..f19905d2 100644 --- a/backend/src/plugins/Reminders/commands/RemindersDeleteCmd.ts +++ b/backend/src/plugins/Reminders/commands/RemindersDeleteCmd.ts @@ -14,9 +14,8 @@ export const RemindersDeleteCmd = remindersCommand({ async run({ message: msg, args, pluginData }) { const reminders = await pluginData.state.reminders.getRemindersByUserId(msg.author.id); reminders.sort(sorter("remind_at")); - const lastNum = reminders.length + 1; - if (args.num > lastNum || args.num <= 0) { + if (args.num > reminders.length || args.num <= 0) { sendErrorMessage(pluginData, msg.channel, "Unknown reminder"); return; }