From 7736e7a22294cf29bebf21011ecbe519a3c9e755 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 94870ef85d3453f50a449d70505c2f3848232005 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 59ef2e6fec262275c44ae4be21027728f9a0b0c4 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 bac18a91cc3633efcefa4ecb2d8ff96f51b88481 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 381903a72a267c331fec8b08566d57af4ef9855b 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 233c7d43a2bd7e82b8299b57a7c4ab1842320551 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; }