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

Added Discord attachment link reaction, fixed emoji configuration and moved util functions

This commit is contained in:
Lily Bergonzat 2024-02-16 11:51:58 +01:00
parent a4c4b17a14
commit 592d037148
173 changed files with 1540 additions and 1170 deletions

View file

@ -1,6 +1,7 @@
import { commandTypeHelpers as ct } from "../../../../commandTypes";
import { canActOn, hasPermission, sendErrorMessage } from "../../../../pluginUtils";
import { canActOn, hasPermission } from "../../../../pluginUtils";
import { resolveMember, resolveUser } from "../../../../utils";
import { CommonPlugin } from "../../../Common/CommonPlugin";
import { actualMuteCmd } from "../../functions/actualCommands/actualMuteCmd";
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
import { modActionsMsgCmd } from "../../types";
@ -35,7 +36,7 @@ export const ForceMuteMsgCmd = modActionsMsgCmd({
async run({ pluginData, message: msg, args }) {
const user = await resolveUser(pluginData.client, args.user);
if (!user.id) {
sendErrorMessage(pluginData, msg.channel, `User not found`);
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, `User not found`);
return;
}
@ -43,7 +44,7 @@ export const ForceMuteMsgCmd = modActionsMsgCmd({
// Make sure we're allowed to mute this user
if (memberToMute && !canActOn(pluginData, msg.member, memberToMute)) {
sendErrorMessage(pluginData, msg.channel, "Cannot mute: insufficient permissions");
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Cannot mute: insufficient permissions");
return;
}
@ -53,7 +54,7 @@ export const ForceMuteMsgCmd = modActionsMsgCmd({
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");
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You don't have permission to use -mod");
return;
}
@ -65,13 +66,13 @@ export const ForceMuteMsgCmd = modActionsMsgCmd({
try {
contactMethods = readContactMethodsFromArgs(args);
} catch (e) {
sendErrorMessage(pluginData, msg.channel, e.message);
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, e.message);
return;
}
actualMuteCmd(
pluginData,
msg.channel,
msg,
user,
[...msg.attachments.values()],
mod,

View file

@ -1,8 +1,9 @@
import { ChannelType } from "discord.js";
import { slashOptions } from "knub";
import { hasPermission, sendErrorMessage } from "../../../../pluginUtils";
import { hasPermission } from "../../../../pluginUtils";
import { UserNotificationMethod, convertDelayStringToMS } 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 { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
@ -44,7 +45,9 @@ export const ForceMuteSlashCmd = {
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);
pluginData
.getPlugin(CommonPlugin)
.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
return;
}
@ -58,7 +61,9 @@ export const ForceMuteSlashCmd = {
if (options.mod) {
if (!canActAsOther) {
sendErrorMessage(pluginData, interaction, "You don't have permission to act as another moderator");
pluginData
.getPlugin(CommonPlugin)
.sendErrorMessage(interaction, "You don't have permission to act as another moderator");
return;
}
@ -68,7 +73,7 @@ export const ForceMuteSlashCmd = {
const convertedTime = options.time ? convertDelayStringToMS(options.time) : null;
if (options.time && !convertedTime) {
sendErrorMessage(pluginData, interaction, `Could not convert ${options.time} to a delay`);
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
return;
}
@ -76,7 +81,7 @@ export const ForceMuteSlashCmd = {
try {
contactMethods = readContactMethodsFromArgs(options) ?? undefined;
} catch (e) {
sendErrorMessage(pluginData, interaction, e.message);
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, e.message);
return;
}