Merge pull request #95 from DarkView/k30_fixes

[K30] Various Fixes for K30
This commit is contained in:
Miikka 2020-07-29 19:57:31 +03:00 committed by GitHub
commit 7a73894f88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 56 additions and 5 deletions

View file

@ -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 }) {

View file

@ -43,6 +43,6 @@ export const ForcemuteCmd = modActionsCommand({
return;
}
actualMuteUserCmd(pluginData, user, msg, args);
actualMuteUserCmd(pluginData, user, msg, { ...args, notify: "none" });
},
});

View file

@ -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<MutesPluginType>()("mutes", {
// prettier-ignore
events: [
ClearActiveMuteOnRoleRemovalEvt,
ClearActiveMuteOnMemberBanEvt,
ReapplyActiveMuteOnJoinEvt,
],
public: {

View file

@ -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<MutesPluginType>()(
"guildBanAdd",
async ({ pluginData, args: { user } }) => {
const mute = await pluginData.state.mutes.findExistingMuteForUserId(user.id);
if (mute) {
pluginData.state.mutes.clear(user.id);
}
},
);

View file

@ -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<MutesPluginType>()(
"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"]),
});
}
},
);

View file

@ -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);
},
});

View file

@ -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;
}