3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-06-08 08:05:03 +00:00

feat: first batch of emojis 🎉

This commit is contained in:
Lily Bergonzat 2024-02-14 09:17:11 +01:00
parent dfb0e2c19d
commit a4c4b17a14
91 changed files with 3659 additions and 2032 deletions

View file

@ -0,0 +1,63 @@
import { commandTypeHelpers as ct } from "../../../../commandTypes";
import { CaseTypes } from "../../../../data/CaseTypes";
import { hasPermission, sendErrorMessage } from "../../../../pluginUtils";
import { resolveUser } from "../../../../utils";
import { actualAddCaseCmd } from "../../functions/actualCommands/actualAddCaseCmd";
import { modActionsMsgCmd } from "../../types";
const opts = {
mod: ct.member({ option: true }),
};
export const AddCaseMsgCmd = modActionsMsgCmd({
trigger: "addcase",
permission: "can_addcase",
description: "Add an arbitrary case to the specified user without taking any action",
signature: [
{
type: ct.string(),
user: ct.string(),
reason: ct.string({ required: false, catchAll: true }),
...opts,
},
],
async run({ pluginData, message: msg, args }) {
const user = await resolveUser(pluginData.client, args.user);
if (!user.id) {
sendErrorMessage(pluginData, msg.channel, `User not found`);
return;
}
// The moderator who did the action is the message author or, if used, the specified -mod
let mod = msg.member;
if (args.mod) {
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg }))) {
sendErrorMessage(pluginData, msg.channel, "You don't have permission to use -mod");
return;
}
mod = args.mod;
}
// Verify the case type is valid
const type: string = args.type[0].toUpperCase() + args.type.slice(1).toLowerCase();
if (!CaseTypes[type]) {
sendErrorMessage(pluginData, msg.channel, "Cannot add case: invalid case type");
return;
}
actualAddCaseCmd(
pluginData,
msg.channel,
msg.member,
mod,
[...msg.attachments.values()],
user,
type as keyof CaseTypes,
args.reason || "",
);
},
});

View file

@ -0,0 +1,65 @@
import { slashOptions } from "knub";
import { CaseTypes } from "../../../../data/CaseTypes";
import { hasPermission, sendErrorMessage } from "../../../../pluginUtils";
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
import { actualAddCaseCmd } from "../../functions/actualCommands/actualAddCaseCmd";
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
const opts = [
slashOptions.string({ name: "reason", description: "The reason", required: false }),
slashOptions.user({ name: "mod", description: "The moderator to add this case as", required: false }),
...generateAttachmentSlashOptions(NUMBER_ATTACHMENTS_CASE_CREATION, {
name: "attachment",
description: "An attachment to add to the reason of the case",
}),
];
export const AddCaseSlashCmd = {
name: "addcase",
configPermission: "can_addcase",
description: "Add an arbitrary case to the specified user without taking any action",
allowDms: false,
signature: [
slashOptions.string({
name: "type",
description: "The type of case to add",
required: true,
choices: Object.keys(CaseTypes).map((type) => ({ name: type, value: type })),
}),
slashOptions.user({ name: "user", description: "The user to add a case to", required: true }),
...opts,
],
async run({ interaction, options, pluginData }) {
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;
const canActAsOther = await hasPermission(pluginData, "can_act_as_other", {
channel: interaction.channel,
member: interaction.member,
});
if (options.mod) {
if (!canActAsOther) {
sendErrorMessage(pluginData, interaction, "You don't have permission to act as another moderator");
return;
}
mod = options.mod;
}
actualAddCaseCmd(
pluginData,
interaction,
interaction.member,
mod,
attachments,
options.user,
options.type as keyof CaseTypes,
options.reason || "",
);
},
};