mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Used guildPluginSlashCommand instead of raw blueprints
This commit is contained in:
parent
7eff7bcaa6
commit
cbec6101e0
27 changed files with 168 additions and 121 deletions
|
@ -170,26 +170,26 @@ export const ModActionsPlugin = zeppelinGuildPlugin<ModActionsPluginType>()({
|
|||
description: "Moderation actions",
|
||||
defaultMemberPermissions: "0",
|
||||
subcommands: [
|
||||
{ type: "slash", ...AddCaseSlashCmd },
|
||||
{ type: "slash", ...BanSlashCmd },
|
||||
{ type: "slash", ...CaseSlashCmd },
|
||||
{ type: "slash", ...CasesSlashCmd },
|
||||
{ type: "slash", ...DeleteCaseSlashCmd },
|
||||
{ type: "slash", ...ForceBanSlashCmd },
|
||||
{ type: "slash", ...ForceMuteSlashCmd },
|
||||
{ type: "slash", ...ForceUnmuteSlashCmd },
|
||||
{ type: "slash", ...HideCaseSlashCmd },
|
||||
{ type: "slash", ...KickSlashCmd },
|
||||
{ type: "slash", ...MassBanSlashCmd },
|
||||
{ type: "slash", ...MassMuteSlashSlashCmd },
|
||||
{ type: "slash", ...MassUnbanSlashCmd },
|
||||
{ type: "slash", ...MuteSlashCmd },
|
||||
{ type: "slash", ...NoteSlashCmd },
|
||||
{ type: "slash", ...UnbanSlashCmd },
|
||||
{ type: "slash", ...UnhideCaseSlashCmd },
|
||||
{ type: "slash", ...UnmuteSlashCmd },
|
||||
{ type: "slash", ...UpdateSlashCmd },
|
||||
{ type: "slash", ...WarnSlashCmd },
|
||||
AddCaseSlashCmd,
|
||||
BanSlashCmd,
|
||||
CaseSlashCmd,
|
||||
CasesSlashCmd,
|
||||
DeleteCaseSlashCmd,
|
||||
ForceBanSlashCmd,
|
||||
ForceMuteSlashCmd,
|
||||
ForceUnmuteSlashCmd,
|
||||
HideCaseSlashCmd,
|
||||
KickSlashCmd,
|
||||
MassBanSlashCmd,
|
||||
MassMuteSlashSlashCmd,
|
||||
MassUnbanSlashCmd,
|
||||
MuteSlashCmd,
|
||||
NoteSlashCmd,
|
||||
UnbanSlashCmd,
|
||||
UnhideCaseSlashCmd,
|
||||
UnmuteSlashCmd,
|
||||
UpdateSlashCmd,
|
||||
WarnSlashCmd,
|
||||
],
|
||||
}),
|
||||
],
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { CaseTypes } from "../../../../data/CaseTypes";
|
||||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualAddCaseCmd } from "../../functions/actualCommands/actualAddCaseCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
const opts = [
|
||||
|
@ -15,7 +18,7 @@ const opts = [
|
|||
}),
|
||||
];
|
||||
|
||||
export const AddCaseSlashCmd = {
|
||||
export const AddCaseSlashCmd = modActionsSlashCmd({
|
||||
name: "addcase",
|
||||
configPermission: "can_addcase",
|
||||
description: "Add an arbitrary case to the specified user without taking any action",
|
||||
|
@ -38,7 +41,7 @@ export const AddCaseSlashCmd = {
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = interaction.member;
|
||||
let mod = interaction.member as GuildMember;
|
||||
const canActAsOther = await hasPermission(pluginData, "can_act_as_other", {
|
||||
channel: interaction.channel,
|
||||
member: interaction.member,
|
||||
|
@ -52,13 +55,13 @@ export const AddCaseSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
mod = options.mod;
|
||||
mod = (await resolveMember(pluginData.client, pluginData.guild, options.mod.id))!;
|
||||
}
|
||||
|
||||
actualAddCaseCmd(
|
||||
pluginData,
|
||||
interaction,
|
||||
interaction.member,
|
||||
interaction.member as GuildMember,
|
||||
mod,
|
||||
attachments,
|
||||
options.user,
|
||||
|
@ -66,4 +69,4 @@ export const AddCaseSlashCmd = {
|
|||
options.reason || "",
|
||||
);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import { ChannelType } from "discord.js";
|
||||
import { ChannelType, GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { UserNotificationMethod, convertDelayStringToMS } from "../../../../utils";
|
||||
import { UserNotificationMethod, convertDelayStringToMS, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualBanCmd } from "../../functions/actualCommands/actualBanCmd";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
const opts = [
|
||||
|
@ -38,7 +39,7 @@ const opts = [
|
|||
}),
|
||||
];
|
||||
|
||||
export const BanSlashCmd = {
|
||||
export const BanSlashCmd = modActionsSlashCmd({
|
||||
name: "ban",
|
||||
configPermission: "can_ban",
|
||||
description: "Ban or Tempban the specified member",
|
||||
|
@ -58,7 +59,7 @@ export const BanSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
let mod = interaction.member;
|
||||
let mod = interaction.member as GuildMember;
|
||||
const canActAsOther = await hasPermission(pluginData, "can_act_as_other", {
|
||||
channel: interaction.channel,
|
||||
member: interaction.member,
|
||||
|
@ -72,7 +73,7 @@ export const BanSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
mod = options.mod;
|
||||
mod = (await resolveMember(pluginData.client, pluginData.guild, options.mod.id))!;
|
||||
}
|
||||
|
||||
let contactMethods: UserNotificationMethod[] | undefined;
|
||||
|
@ -96,9 +97,9 @@ export const BanSlashCmd = {
|
|||
convertedTime,
|
||||
options.reason || "",
|
||||
attachments,
|
||||
interaction.member,
|
||||
interaction.member as GuildMember,
|
||||
mod,
|
||||
contactMethods,
|
||||
);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import { slashOptions } from "knub";
|
||||
import { actualCaseCmd } from "../../functions/actualCommands/actualCaseCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
|
||||
const opts = [
|
||||
slashOptions.boolean({ name: "show", description: "To make the result visible to everyone", required: false }),
|
||||
];
|
||||
|
||||
export const CaseSlashCmd = {
|
||||
export const CaseSlashCmd = modActionsSlashCmd({
|
||||
name: "case",
|
||||
configPermission: "can_view",
|
||||
description: "Show information about a specific case",
|
||||
|
@ -21,4 +22,4 @@ export const CaseSlashCmd = {
|
|||
await interaction.deferReply({ ephemeral: options.show !== true });
|
||||
actualCaseCmd(pluginData, interaction, interaction.user.id, options["case-number"], options.show);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { actualCasesCmd } from "../../functions/actualCommands/actualCasesCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
|
||||
const opts = [
|
||||
slashOptions.user({ name: "user", description: "The user to show cases for", required: false }),
|
||||
|
@ -21,7 +23,7 @@ const opts = [
|
|||
slashOptions.boolean({ name: "show", description: "To make the result visible to everyone", required: false }),
|
||||
];
|
||||
|
||||
export const CasesSlashCmd = {
|
||||
export const CasesSlashCmd = modActionsSlashCmd({
|
||||
name: "cases",
|
||||
configPermission: "can_view",
|
||||
description: "Show a list of cases the specified user has or the specified mod made",
|
||||
|
@ -35,9 +37,9 @@ export const CasesSlashCmd = {
|
|||
return actualCasesCmd(
|
||||
pluginData,
|
||||
interaction,
|
||||
options.mod,
|
||||
options.mod?.id ?? null,
|
||||
options.user,
|
||||
interaction.member,
|
||||
interaction.member as GuildMember,
|
||||
options.notes,
|
||||
options.warns,
|
||||
options.mutes,
|
||||
|
@ -51,4 +53,4 @@ export const CasesSlashCmd = {
|
|||
options.show,
|
||||
);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { actualDeleteCaseCmd } from "../../functions/actualCommands/actualDeleteCaseCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
|
||||
const opts = [slashOptions.boolean({ name: "force", description: "Whether or not to force delete", required: false })];
|
||||
|
||||
export const DeleteCaseSlashCmd = {
|
||||
export const DeleteCaseSlashCmd = modActionsSlashCmd({
|
||||
name: "deletecase",
|
||||
configPermission: "can_deletecase",
|
||||
description: "Delete the specified case. This operation can *not* be reversed.",
|
||||
|
@ -21,9 +23,9 @@ export const DeleteCaseSlashCmd = {
|
|||
actualDeleteCaseCmd(
|
||||
pluginData,
|
||||
interaction,
|
||||
interaction.member,
|
||||
options["case-number"].split(/[\s,]+/),
|
||||
interaction.member as GuildMember,
|
||||
options["case-number"].split(/\D+/).map(Number),
|
||||
!!options.force,
|
||||
);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { convertDelayStringToMS } from "../../../../utils";
|
||||
import { convertDelayStringToMS, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualForceBanCmd } from "../../functions/actualCommands/actualForceBanCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
const opts = [
|
||||
|
@ -15,7 +17,7 @@ const opts = [
|
|||
}),
|
||||
];
|
||||
|
||||
export const ForceBanSlashCmd = {
|
||||
export const ForceBanSlashCmd = modActionsSlashCmd({
|
||||
name: "forceban",
|
||||
configPermission: "can_ban",
|
||||
description: "Force-ban the specified user, even if they aren't on the server",
|
||||
|
@ -35,7 +37,7 @@ export const ForceBanSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
let mod = interaction.member;
|
||||
let mod = interaction.member as GuildMember;
|
||||
const canActAsOther = await hasPermission(pluginData, "can_act_as_other", {
|
||||
channel: interaction.channel,
|
||||
member: interaction.member,
|
||||
|
@ -49,7 +51,7 @@ export const ForceBanSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
mod = options.mod;
|
||||
mod = (await resolveMember(pluginData.client, pluginData.guild, options.mod.id))!;
|
||||
}
|
||||
|
||||
const convertedTime = options.time ? convertDelayStringToMS(options.time) : null;
|
||||
|
@ -58,6 +60,14 @@ export const ForceBanSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
actualForceBanCmd(pluginData, interaction, interaction.user.id, options.user, options.reason, attachments, mod);
|
||||
actualForceBanCmd(
|
||||
pluginData,
|
||||
interaction,
|
||||
interaction.user.id,
|
||||
options.user,
|
||||
options.reason ?? "",
|
||||
attachments,
|
||||
mod,
|
||||
);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import { ChannelType } from "discord.js";
|
||||
import { ChannelType, GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { UserNotificationMethod, convertDelayStringToMS } from "../../../../utils";
|
||||
import { UserNotificationMethod, convertDelayStringToMS, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualMuteCmd } from "../../functions/actualCommands/actualMuteCmd";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
const opts = [
|
||||
|
@ -33,7 +34,7 @@ const opts = [
|
|||
}),
|
||||
];
|
||||
|
||||
export const ForceMuteSlashCmd = {
|
||||
export const ForceMuteSlashCmd = modActionsSlashCmd({
|
||||
name: "forcemute",
|
||||
configPermission: "can_mute",
|
||||
description: "Force-mute the specified user, even if they're not on the server",
|
||||
|
@ -53,7 +54,7 @@ export const ForceMuteSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
let mod = interaction.member;
|
||||
let mod = interaction.member as GuildMember;
|
||||
let ppId: string | undefined;
|
||||
const canActAsOther = await hasPermission(pluginData, "can_act_as_other", {
|
||||
channel: interaction.channel,
|
||||
|
@ -68,7 +69,7 @@ export const ForceMuteSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
mod = options.mod;
|
||||
mod = (await resolveMember(pluginData.client, pluginData.guild, options.mod.id))!;
|
||||
ppId = interaction.user.id;
|
||||
}
|
||||
|
||||
|
@ -94,8 +95,8 @@ export const ForceMuteSlashCmd = {
|
|||
mod,
|
||||
ppId,
|
||||
convertedTime,
|
||||
options.reason,
|
||||
options.reason ?? "",
|
||||
contactMethods,
|
||||
);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { convertDelayStringToMS } from "../../../../utils";
|
||||
import { convertDelayStringToMS, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualUnmuteCmd } from "../../functions/actualCommands/actualUnmuteCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
const opts = [
|
||||
|
@ -16,7 +18,7 @@ const opts = [
|
|||
}),
|
||||
];
|
||||
|
||||
export const ForceUnmuteSlashCmd = {
|
||||
export const ForceUnmuteSlashCmd = modActionsSlashCmd({
|
||||
name: "forceunmute",
|
||||
configPermission: "can_mute",
|
||||
description: "Force-unmute the specified user, even if they're not on the server",
|
||||
|
@ -36,7 +38,7 @@ export const ForceUnmuteSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
let mod = interaction.member;
|
||||
let mod = interaction.member as GuildMember;
|
||||
let ppId: string | undefined;
|
||||
const canActAsOther = await hasPermission(pluginData, "can_act_as_other", {
|
||||
channel: interaction.channel,
|
||||
|
@ -51,7 +53,7 @@ export const ForceUnmuteSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
mod = options.mod;
|
||||
mod = (await resolveMember(pluginData.client, pluginData.guild, options.mod.id))!;
|
||||
ppId = interaction.user.id;
|
||||
}
|
||||
|
||||
|
@ -61,6 +63,6 @@ export const ForceUnmuteSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
actualUnmuteCmd(pluginData, interaction, options.user, attachments, mod, ppId, convertedTime, options.reason);
|
||||
actualUnmuteCmd(pluginData, interaction, options.user, attachments, mod, ppId, convertedTime, options.reason ?? "");
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { slashOptions } from "knub";
|
||||
import { actualHideCaseCmd } from "../../functions/actualCommands/actualHideCaseCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
|
||||
export const HideCaseSlashCmd = {
|
||||
export const HideCaseSlashCmd = modActionsSlashCmd({
|
||||
name: "hidecase",
|
||||
configPermission: "can_hidecase",
|
||||
description: "Hide the specified case so it doesn't appear in !cases or !info",
|
||||
|
@ -13,6 +14,6 @@ export const HideCaseSlashCmd = {
|
|||
|
||||
async run({ interaction, options, pluginData }) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
actualHideCaseCmd(pluginData, interaction, options["case-number"].split(/[\s,]+/).map(Number));
|
||||
actualHideCaseCmd(pluginData, interaction, options["case-number"].split(/\D+/).map(Number));
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import { ChannelType } from "discord.js";
|
||||
import { ChannelType, GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { UserNotificationMethod } from "../../../../utils";
|
||||
import { UserNotificationMethod, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualKickCmd } from "../../functions/actualCommands/actualKickCmd";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
const opts = [
|
||||
|
@ -37,7 +38,7 @@ const opts = [
|
|||
}),
|
||||
];
|
||||
|
||||
export const KickSlashCmd = {
|
||||
export const KickSlashCmd = modActionsSlashCmd({
|
||||
name: "kick",
|
||||
configPermission: "can_kick",
|
||||
description: "Kick the specified member",
|
||||
|
@ -57,7 +58,7 @@ export const KickSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
let mod = interaction.member;
|
||||
let mod = interaction.member as GuildMember;
|
||||
const canActAsOther = await hasPermission(pluginData, "can_act_as_other", {
|
||||
channel: interaction.channel,
|
||||
member: interaction.member,
|
||||
|
@ -71,7 +72,7 @@ export const KickSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
mod = options.mod;
|
||||
mod = (await resolveMember(pluginData.client, pluginData.guild, options.mod.id))!;
|
||||
}
|
||||
|
||||
let contactMethods: UserNotificationMethod[] | undefined;
|
||||
|
@ -85,7 +86,7 @@ export const KickSlashCmd = {
|
|||
actualKickCmd(
|
||||
pluginData,
|
||||
interaction,
|
||||
interaction.member,
|
||||
interaction.member as GuildMember,
|
||||
options.user,
|
||||
options.reason || "",
|
||||
attachments,
|
||||
|
@ -94,4 +95,4 @@ export const KickSlashCmd = {
|
|||
options.clean,
|
||||
);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualMassBanCmd } from "../../functions/actualCommands/actualMassBanCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
const opts = [
|
||||
|
@ -12,7 +14,7 @@ const opts = [
|
|||
}),
|
||||
];
|
||||
|
||||
export const MassBanSlashCmd = {
|
||||
export const MassBanSlashCmd = modActionsSlashCmd({
|
||||
name: "massban",
|
||||
configPermission: "can_massban",
|
||||
description: "Mass-ban a list of user IDs",
|
||||
|
@ -39,10 +41,10 @@ export const MassBanSlashCmd = {
|
|||
actualMassBanCmd(
|
||||
pluginData,
|
||||
interaction,
|
||||
options["user-ids"].split(/[\s,\r\n]+/),
|
||||
interaction.member,
|
||||
options["user-ids"].split(/\D+/),
|
||||
interaction.member as GuildMember,
|
||||
options.reason || "",
|
||||
attachments,
|
||||
);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualMassMuteCmd } from "../../functions/actualCommands/actualMassMuteCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
const opts = [
|
||||
|
@ -12,7 +14,7 @@ const opts = [
|
|||
}),
|
||||
];
|
||||
|
||||
export const MassMuteSlashSlashCmd = {
|
||||
export const MassMuteSlashSlashCmd = modActionsSlashCmd({
|
||||
name: "massmute",
|
||||
configPermission: "can_massmute",
|
||||
description: "Mass-mute a list of user IDs",
|
||||
|
@ -39,10 +41,10 @@ export const MassMuteSlashSlashCmd = {
|
|||
actualMassMuteCmd(
|
||||
pluginData,
|
||||
interaction,
|
||||
options["user-ids"].split(/[\s,\r\n]+/),
|
||||
interaction.member,
|
||||
options["user-ids"].split(/\D+/),
|
||||
interaction.member as GuildMember,
|
||||
options.reason || "",
|
||||
attachments,
|
||||
);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualMassUnbanCmd } from "../../functions/actualCommands/actualMassUnbanCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
const opts = [
|
||||
|
@ -12,7 +14,7 @@ const opts = [
|
|||
}),
|
||||
];
|
||||
|
||||
export const MassUnbanSlashCmd = {
|
||||
export const MassUnbanSlashCmd = modActionsSlashCmd({
|
||||
name: "massunban",
|
||||
configPermission: "can_massunban",
|
||||
description: "Mass-unban a list of user IDs",
|
||||
|
@ -40,9 +42,9 @@ export const MassUnbanSlashCmd = {
|
|||
pluginData,
|
||||
interaction,
|
||||
options["user-ids"].split(/[\s,\r\n]+/),
|
||||
interaction.member,
|
||||
interaction.member as GuildMember,
|
||||
options.reason || "",
|
||||
attachments,
|
||||
);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ChannelType } from "discord.js";
|
||||
import { ChannelType, GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { canActOn, hasPermission } from "../../../../pluginUtils";
|
||||
import { UserNotificationMethod, convertDelayStringToMS, resolveMember } from "../../../../utils";
|
||||
|
@ -8,6 +8,7 @@ import { CommonPlugin } from "../../../Common/CommonPlugin";
|
|||
import { actualMuteCmd } from "../../functions/actualCommands/actualMuteCmd";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
const opts = [
|
||||
|
@ -35,7 +36,7 @@ const opts = [
|
|||
}),
|
||||
];
|
||||
|
||||
export const MuteSlashCmd = {
|
||||
export const MuteSlashCmd = modActionsSlashCmd({
|
||||
name: "mute",
|
||||
configPermission: "can_mute",
|
||||
description: "Mute the specified member",
|
||||
|
@ -61,7 +62,7 @@ export const MuteSlashCmd = {
|
|||
const reply = await waitForButtonConfirm(
|
||||
interaction,
|
||||
{ content: "User not found on the server, forcemute instead?" },
|
||||
{ confirmText: "Yes", cancelText: "No", restrictToId: interaction.member.id },
|
||||
{ confirmText: "Yes", cancelText: "No", restrictToId: interaction.user.id },
|
||||
);
|
||||
|
||||
if (!reply) {
|
||||
|
@ -74,12 +75,12 @@ export const MuteSlashCmd = {
|
|||
}
|
||||
|
||||
// Make sure we're allowed to mute this member
|
||||
if (memberToMute && !canActOn(pluginData, interaction.member, memberToMute)) {
|
||||
if (memberToMute && !canActOn(pluginData, interaction.member as GuildMember, memberToMute)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, "Cannot mute: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
let mod = interaction.member;
|
||||
let mod = interaction.member as GuildMember;
|
||||
let ppId: string | undefined;
|
||||
const canActAsOther = await hasPermission(pluginData, "can_act_as_other", {
|
||||
channel: interaction.channel,
|
||||
|
@ -94,7 +95,7 @@ export const MuteSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
mod = options.mod;
|
||||
mod = (await resolveMember(pluginData.client, pluginData.guild, options.mod.id))!;
|
||||
ppId = interaction.user.id;
|
||||
}
|
||||
|
||||
|
@ -124,4 +125,4 @@ export const MuteSlashCmd = {
|
|||
contactMethods,
|
||||
);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -2,6 +2,7 @@ import { slashOptions } from "knub";
|
|||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualNoteCmd } from "../../functions/actualCommands/actualNoteCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
const opts = [
|
||||
|
@ -12,7 +13,7 @@ const opts = [
|
|||
}),
|
||||
];
|
||||
|
||||
export const NoteSlashCmd = {
|
||||
export const NoteSlashCmd = modActionsSlashCmd({
|
||||
name: "note",
|
||||
configPermission: "can_note",
|
||||
description: "Add a note to the specified user",
|
||||
|
@ -34,4 +35,4 @@ export const NoteSlashCmd = {
|
|||
|
||||
actualNoteCmd(pluginData, interaction, interaction.user, attachments, options.user, options.note || "");
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualUnbanCmd } from "../../functions/actualCommands/actualUnbanCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
const opts = [
|
||||
|
@ -14,7 +17,7 @@ const opts = [
|
|||
}),
|
||||
];
|
||||
|
||||
export const UnbanSlashCmd = {
|
||||
export const UnbanSlashCmd = modActionsSlashCmd({
|
||||
name: "unban",
|
||||
configPermission: "can_unban",
|
||||
description: "Unban the specified member",
|
||||
|
@ -34,7 +37,7 @@ export const UnbanSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
let mod = interaction.member;
|
||||
let mod = interaction.member as GuildMember;
|
||||
const canActAsOther = await hasPermission(pluginData, "can_act_as_other", {
|
||||
channel: interaction.channel,
|
||||
member: interaction.member,
|
||||
|
@ -48,9 +51,9 @@ export const UnbanSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
mod = options.mod;
|
||||
mod = (await resolveMember(pluginData.client, pluginData.guild, options.mod.id))!;
|
||||
}
|
||||
|
||||
actualUnbanCmd(pluginData, interaction, interaction.user.id, options.user, options.reason, attachments, mod);
|
||||
actualUnbanCmd(pluginData, interaction, interaction.user.id, options.user, options.reason ?? "", attachments, mod);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { slashOptions } from "knub";
|
||||
import { actualUnhideCaseCmd } from "../../functions/actualCommands/actualUnhideCaseCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
|
||||
export const UnhideCaseSlashCmd = {
|
||||
export const UnhideCaseSlashCmd = modActionsSlashCmd({
|
||||
name: "unhidecase",
|
||||
configPermission: "can_hidecase",
|
||||
description: "Un-hide the specified case",
|
||||
|
@ -13,6 +14,6 @@ export const UnhideCaseSlashCmd = {
|
|||
|
||||
async run({ interaction, options, pluginData }) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
actualUnhideCaseCmd(pluginData, interaction, options["case-number"].split(/[\s,]+/).map(Number));
|
||||
actualUnhideCaseCmd(pluginData, interaction, options["case-number"].split(/\D+/).map(Number));
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { canActOn, hasPermission } from "../../../../pluginUtils";
|
||||
import { convertDelayStringToMS, resolveMember } from "../../../../utils";
|
||||
|
@ -7,6 +8,7 @@ import { CommonPlugin } from "../../../Common/CommonPlugin";
|
|||
import { MutesPlugin } from "../../../Mutes/MutesPlugin";
|
||||
import { actualUnmuteCmd } from "../../functions/actualCommands/actualUnmuteCmd";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
const opts = [
|
||||
|
@ -19,7 +21,7 @@ const opts = [
|
|||
}),
|
||||
];
|
||||
|
||||
export const UnmuteSlashCmd = {
|
||||
export const UnmuteSlashCmd = modActionsSlashCmd({
|
||||
name: "unmute",
|
||||
configPermission: "can_mute",
|
||||
description: "Unmute the specified member",
|
||||
|
@ -79,12 +81,12 @@ export const UnmuteSlashCmd = {
|
|||
}
|
||||
|
||||
// Make sure we're allowed to unmute this member
|
||||
if (memberToUnmute && !canActOn(pluginData, interaction.member, memberToUnmute)) {
|
||||
if (memberToUnmute && !canActOn(pluginData, interaction.member as GuildMember, memberToUnmute)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, "Cannot unmute: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
let mod = interaction.member;
|
||||
let mod = interaction.member as GuildMember;
|
||||
let ppId: string | undefined;
|
||||
const canActAsOther = await hasPermission(pluginData, "can_act_as_other", {
|
||||
channel: interaction.channel,
|
||||
|
@ -99,7 +101,7 @@ export const UnmuteSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
mod = options.mod;
|
||||
mod = (await resolveMember(pluginData.client, pluginData.guild, options.mod.id))!;
|
||||
ppId = interaction.user.id;
|
||||
}
|
||||
|
||||
|
@ -111,4 +113,4 @@ export const UnmuteSlashCmd = {
|
|||
|
||||
actualUnmuteCmd(pluginData, interaction, options.user, attachments, mod, ppId, convertedTime, options.reason);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { slashOptions } from "knub";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { updateCase } from "../../functions/updateCase";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_UPDATE } from "../constants";
|
||||
|
||||
const opts = [
|
||||
|
@ -12,7 +13,7 @@ const opts = [
|
|||
}),
|
||||
];
|
||||
|
||||
export const UpdateSlashCmd = {
|
||||
export const UpdateSlashCmd = modActionsSlashCmd({
|
||||
name: "update",
|
||||
configPermission: "can_note",
|
||||
description: "Update the specified case (or your latest case) by adding more notes to it",
|
||||
|
@ -27,9 +28,9 @@ export const UpdateSlashCmd = {
|
|||
pluginData,
|
||||
interaction,
|
||||
interaction.user,
|
||||
options.caseNumber,
|
||||
options.note,
|
||||
options["case-number"] ? Number(options["case-number"]) : null,
|
||||
options.reason ?? "",
|
||||
retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_UPDATE, options, "attachment"),
|
||||
);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ChannelType } from "discord.js";
|
||||
import { ChannelType, GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { canActOn, hasPermission } from "../../../../pluginUtils";
|
||||
import { UserNotificationMethod, resolveMember } from "../../../../utils";
|
||||
|
@ -7,6 +7,7 @@ import { CommonPlugin } from "../../../Common/CommonPlugin";
|
|||
import { actualWarnCmd } from "../../functions/actualCommands/actualWarnCmd";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
const opts = [
|
||||
|
@ -33,7 +34,7 @@ const opts = [
|
|||
}),
|
||||
];
|
||||
|
||||
export const WarnSlashCmd = {
|
||||
export const WarnSlashCmd = modActionsSlashCmd({
|
||||
name: "warn",
|
||||
configPermission: "can_warn",
|
||||
description: "Send a warning to the specified user",
|
||||
|
@ -67,12 +68,12 @@ export const WarnSlashCmd = {
|
|||
}
|
||||
|
||||
// Make sure we're allowed to warn this member
|
||||
if (!canActOn(pluginData, interaction.member, memberToWarn)) {
|
||||
if (!canActOn(pluginData, interaction.member as GuildMember, memberToWarn)) {
|
||||
await pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, "Cannot warn: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
let mod = interaction.member;
|
||||
let mod = interaction.member as GuildMember;
|
||||
const canActAsOther = await hasPermission(pluginData, "can_act_as_other", {
|
||||
channel: interaction.channel,
|
||||
member: interaction.member,
|
||||
|
@ -86,7 +87,7 @@ export const WarnSlashCmd = {
|
|||
return;
|
||||
}
|
||||
|
||||
mod = options.mod;
|
||||
mod = (await resolveMember(pluginData.client, pluginData.guild, options.mod.id))!;
|
||||
}
|
||||
|
||||
let contactMethods: UserNotificationMethod[] | undefined;
|
||||
|
@ -108,4 +109,4 @@ export const WarnSlashCmd = {
|
|||
contactMethods,
|
||||
);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ export async function actualKickCmd(
|
|||
attachments: Attachment[],
|
||||
mod: GuildMember,
|
||||
contactMethods?: UserNotificationMethod[],
|
||||
clean?: boolean,
|
||||
clean?: boolean | null,
|
||||
) {
|
||||
if (await handleAttachmentLinkDetectionAndGetRestriction(pluginData, context, reason)) {
|
||||
return;
|
||||
|
|
|
@ -29,7 +29,7 @@ export async function actualMuteCmd(
|
|||
mod: GuildMember,
|
||||
ppId?: string,
|
||||
time?: number,
|
||||
reason?: string,
|
||||
reason?: string | null,
|
||||
contactMethods?: UserNotificationMethod[],
|
||||
) {
|
||||
if (await handleAttachmentLinkDetectionAndGetRestriction(pluginData, context, reason)) {
|
||||
|
|
|
@ -16,7 +16,7 @@ export async function actualUnmuteCmd(
|
|||
mod: GuildMember,
|
||||
ppId?: string,
|
||||
time?: number,
|
||||
reason?: string,
|
||||
reason?: string | null,
|
||||
) {
|
||||
if (await handleAttachmentLinkDetectionAndGetRestriction(pluginData, context, reason)) {
|
||||
return;
|
||||
|
|
|
@ -2,8 +2,8 @@ import { GuildTextBasedChannel } from "discord.js";
|
|||
import { disableUserNotificationStrings, UserNotificationMethod } from "../../../utils";
|
||||
|
||||
export function readContactMethodsFromArgs(args: {
|
||||
notify?: string;
|
||||
"notify-channel"?: GuildTextBasedChannel;
|
||||
notify?: string | null;
|
||||
"notify-channel"?: GuildTextBasedChannel | null;
|
||||
}): null | UserNotificationMethod[] {
|
||||
if (args.notify) {
|
||||
if (args.notify === "dm") {
|
||||
|
|
|
@ -13,7 +13,7 @@ export async function updateCase(
|
|||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
context: Message | ChatInputCommandInteraction,
|
||||
author: User,
|
||||
caseNumber?: number,
|
||||
caseNumber?: number | null,
|
||||
note = "",
|
||||
attachments: Attachment[] = [],
|
||||
) {
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
import { ChatInputCommandInteraction, Message } from "discord.js";
|
||||
import { EventEmitter } from "events";
|
||||
import { BasePluginType, guildPluginEventListener, guildPluginMessageCommand, guildPluginSlashGroup } from "knub";
|
||||
import {
|
||||
BasePluginType,
|
||||
guildPluginEventListener,
|
||||
guildPluginMessageCommand,
|
||||
guildPluginSlashCommand,
|
||||
guildPluginSlashGroup,
|
||||
} from "knub";
|
||||
import z from "zod";
|
||||
import { Queue } from "../../Queue";
|
||||
import { GuildCases } from "../../data/GuildCases";
|
||||
|
@ -152,4 +158,5 @@ export type ModActionType = "note" | "warn" | "mute" | "unmute" | "kick" | "ban"
|
|||
|
||||
export const modActionsMsgCmd = guildPluginMessageCommand<ModActionsPluginType>();
|
||||
export const modActionsSlashGroup = guildPluginSlashGroup<ModActionsPluginType>();
|
||||
export const modActionsSlashCmd = guildPluginSlashCommand<ModActionsPluginType>();
|
||||
export const modActionsEvt = guildPluginEventListener<ModActionsPluginType>();
|
||||
|
|
Loading…
Add table
Reference in a new issue