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 }) { 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" }); }, }); 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"]), + }); + } + }, +); 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); }, }); diff --git a/backend/src/plugins/Reminders/commands/RemindersDeleteCmd.ts b/backend/src/plugins/Reminders/commands/RemindersDeleteCmd.ts index e31677b4..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; }