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,84 @@
import { commandTypeHelpers as ct } from "../../../../commandTypes";
import { canActOn, hasPermission, sendErrorMessage } from "../../../../pluginUtils";
import { resolveMember, resolveUser } from "../../../../utils";
import { actualMuteCmd } from "../../functions/actualCommands/actualMuteCmd";
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
import { modActionsMsgCmd } from "../../types";
const opts = {
mod: ct.member({ option: true }),
notify: ct.string({ option: true }),
"notify-channel": ct.textChannel({ option: true }),
};
export const ForceMuteMsgCmd = modActionsMsgCmd({
trigger: "forcemute",
permission: "can_mute",
description: "Force-mute the specified user, even if they're not on the server",
signature: [
{
user: ct.string(),
time: ct.delay(),
reason: ct.string({ required: false, catchAll: true }),
...opts,
},
{
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;
}
const memberToMute = await resolveMember(pluginData.client, pluginData.guild, user.id);
// Make sure we're allowed to mute this user
if (memberToMute && !canActOn(pluginData, msg.member, memberToMute)) {
sendErrorMessage(pluginData, msg.channel, "Cannot mute: insufficient permissions");
return;
}
// The moderator who did the action is the message author or, if used, the specified -mod
let mod = msg.member;
let ppId: string | undefined;
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;
ppId = msg.author.id;
}
let contactMethods;
try {
contactMethods = readContactMethodsFromArgs(args);
} catch (e) {
sendErrorMessage(pluginData, msg.channel, e.message);
return;
}
actualMuteCmd(
pluginData,
msg.channel,
user,
[...msg.attachments.values()],
mod,
ppId,
"time" in args ? args.time ?? undefined : undefined,
args.reason,
contactMethods,
);
},
});

View file

@ -0,0 +1,95 @@
import { ChannelType } from "discord.js";
import { slashOptions } from "knub";
import { hasPermission, sendErrorMessage } from "../../../../pluginUtils";
import { UserNotificationMethod, convertDelayStringToMS } from "../../../../utils";
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
import { actualMuteCmd } from "../../functions/actualCommands/actualMuteCmd";
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
const opts = [
slashOptions.string({ name: "time", description: "The duration of the mute", required: false }),
slashOptions.string({ name: "reason", description: "The reason", required: false }),
slashOptions.user({ name: "mod", description: "The moderator to mute as", required: false }),
slashOptions.string({
name: "notify",
description: "How to notify",
required: false,
choices: [
{ name: "DM", value: "dm" },
{ name: "Channel", value: "channel" },
],
}),
slashOptions.channel({
name: "notify-channel",
description: "The channel to notify in",
channelTypes: [ChannelType.GuildText, ChannelType.PrivateThread, ChannelType.PublicThread],
required: false,
}),
...generateAttachmentSlashOptions(NUMBER_ATTACHMENTS_CASE_CREATION, {
name: "attachment",
description: "An attachment to add to the reason of the mute",
}),
];
export const ForceMuteSlashCmd = {
name: "forcemute",
configPermission: "can_mute",
description: "Force-mute the specified user, even if they're not on the server",
allowDms: false,
signature: [slashOptions.user({ name: "user", description: "The user to mute", required: true }), ...opts],
async run({ interaction, options, pluginData }) {
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
sendErrorMessage(pluginData, interaction, "Text or attachment required", undefined, undefined, true);
return;
}
let mod = interaction.member;
let ppId: string | undefined;
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;
ppId = interaction.user.id;
}
const convertedTime = options.time ? convertDelayStringToMS(options.time) : null;
if (options.time && !convertedTime) {
sendErrorMessage(pluginData, interaction, `Could not convert ${options.time} to a delay`);
return;
}
let contactMethods: UserNotificationMethod[] | undefined;
try {
contactMethods = readContactMethodsFromArgs(options) ?? undefined;
} catch (e) {
sendErrorMessage(pluginData, interaction, e.message);
return;
}
actualMuteCmd(
pluginData,
interaction,
options.user,
attachments,
mod,
ppId,
options.time,
options.reason,
contactMethods,
);
},
};