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

Merge branch '240811_application_commands_merge_2' into next

This commit is contained in:
Dragory 2024-08-11 22:28:41 +03:00
commit 43b8017985
No known key found for this signature in database
279 changed files with 6192 additions and 3044 deletions

View file

@ -5,8 +5,9 @@ import { GuildCases } from "../../data/GuildCases.js";
import { GuildLogs } from "../../data/GuildLogs.js";
import { GuildSavedMessages } from "../../data/GuildSavedMessages.js";
import { Supporters } from "../../data/Supporters.js";
import { makePublicFn, sendSuccessMessage } from "../../pluginUtils.js";
import { makePublicFn } from "../../pluginUtils.js";
import { discardRegExpRunner, getRegExpRunner } from "../../regExpRunners.js";
import { CommonPlugin } from "../Common/CommonPlugin.js";
import { LogsPlugin } from "../Logs/LogsPlugin.js";
import { ModActionsPlugin } from "../ModActions/ModActionsPlugin.js";
import { TimeAndDatePlugin } from "../TimeAndDate/TimeAndDatePlugin.js";
@ -192,11 +193,15 @@ export const UtilityPlugin = guildPlugin<UtilityPluginType>()({
}
},
beforeStart(pluginData) {
pluginData.state.common = pluginData.getPlugin(CommonPlugin);
},
afterLoad(pluginData) {
const { guild } = pluginData;
if (activeReloads.has(guild.id)) {
sendSuccessMessage(pluginData, activeReloads.get(guild.id)!, "Reloaded!");
pluginData.state.common.sendSuccessMessage(activeReloads.get(guild.id)!, "Reloaded!");
activeReloads.delete(guild.id);
}
},

View file

@ -1,6 +1,5 @@
import { APIEmbed, ImageFormat } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { sendErrorMessage } from "../../../pluginUtils.js";
import { UnknownUser, renderUsername } from "../../../utils.js";
import { utilityCmd } from "../types.js";
@ -24,7 +23,7 @@ export const AvatarCmd = utilityCmd({
};
msg.channel.send({ embeds: [embed] });
} else {
sendErrorMessage(pluginData, msg.channel, "Invalid user ID");
void pluginData.state.common.sendErrorMessage(msg, "Invalid user ID");
}
},
});

View file

@ -1,5 +1,4 @@
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { sendErrorMessage } from "../../../pluginUtils.js";
import { getChannelInfoEmbed } from "../functions/getChannelInfoEmbed.js";
import { utilityCmd } from "../types.js";
@ -16,7 +15,7 @@ export const ChannelInfoCmd = utilityCmd({
async run({ message, args, pluginData }) {
const embed = await getChannelInfoEmbed(pluginData, args.channel);
if (!embed) {
sendErrorMessage(pluginData, message.channel, "Unknown channel");
void pluginData.state.common.sendErrorMessage(message, "Unknown channel");
return;
}

View file

@ -1,11 +1,11 @@
import { Message, Snowflake, TextChannel, User } from "discord.js";
import { Message, ModalSubmitInteraction, Snowflake, TextChannel, User } from "discord.js";
import { GuildPluginData } from "knub";
import { allowTimeout } from "../../../RegExpRunner.js";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { LogType } from "../../../data/LogType.js";
import { SavedMessage } from "../../../data/entities/SavedMessage.js";
import { humanizeDurationShort } from "../../../humanizeDurationShort.js";
import { getBaseUrl, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils.js";
import { getBaseUrl } from "../../../pluginUtils.js";
import { ModActionsPlugin } from "../../../plugins/ModActions/ModActionsPlugin.js";
import { DAYS, SECONDS, chunkArray, getInviteCodesInString, noop } from "../../../utils.js";
import { LogsPlugin } from "../../Logs/LogsPlugin.js";
@ -77,17 +77,28 @@ export interface CleanArgs {
"has-invites"?: boolean;
match?: RegExp;
"to-id"?: string;
"response-interaction"?: ModalSubmitInteraction;
}
export async function cleanCmd(pluginData: GuildPluginData<UtilityPluginType>, args: CleanArgs | any, msg) {
if (args.count > MAX_CLEAN_COUNT || args.count <= 0) {
sendErrorMessage(pluginData, msg.channel, `Clean count must be between 1 and ${MAX_CLEAN_COUNT}`);
void pluginData.state.common.sendErrorMessage(
msg,
`Clean count must be between 1 and ${MAX_CLEAN_COUNT}`,
undefined,
args["response-interaction"],
);
return;
}
const targetChannel = args.channel ? pluginData.guild.channels.cache.get(args.channel as Snowflake) : msg.channel;
if (!targetChannel?.isTextBased()) {
sendErrorMessage(pluginData, msg.channel, `Invalid channel specified`);
void pluginData.state.common.sendErrorMessage(
msg,
`Invalid channel specified`,
undefined,
args["response-interaction"],
);
return;
}
@ -99,12 +110,20 @@ export async function cleanCmd(pluginData: GuildPluginData<UtilityPluginType>, a
categoryId: targetChannel.parentId,
});
if (configForTargetChannel.can_clean !== true) {
sendErrorMessage(pluginData, msg.channel, `Missing permissions to use clean on that channel`);
void pluginData.state.common.sendErrorMessage(
msg,
`Missing permissions to use clean on that channel`,
undefined,
args["response-interaction"],
);
return;
}
}
const cleaningMessage = msg.channel.send("Cleaning...");
let cleaningMessage: Message | undefined = undefined;
if (!args["response-interaction"]) {
cleaningMessage = await msg.channel.send("Cleaning...");
}
const messagesToClean: Message[] = [];
let beforeId = msg.id;
@ -202,19 +221,29 @@ export async function cleanCmd(pluginData: GuildPluginData<UtilityPluginType>, a
}
}
responseMsg = await sendSuccessMessage(pluginData, msg.channel, responseText);
responseMsg = await pluginData.state.common.sendSuccessMessage(
msg,
responseText,
undefined,
args["response-interaction"],
);
} else {
const responseText = `Found no messages to clean${note ? ` (${note})` : ""}!`;
responseMsg = await sendErrorMessage(pluginData, msg.channel, responseText);
responseMsg = await pluginData.state.common.sendErrorMessage(
msg,
responseText,
undefined,
args["response-interaction"],
);
}
await (await cleaningMessage).delete();
cleaningMessage?.delete();
if (targetChannel.id === msg.channel.id) {
// Delete the !clean command and the bot response if a different channel wasn't specified
// (so as not to spam the cleaned channel with the command itself)
msg.delete().catch(noop);
setTimeout(() => {
msg.delete().catch(noop);
responseMsg?.delete().catch(noop);
}, CLEAN_COMMAND_DELETE_DELAY);
}

View file

@ -1,6 +1,5 @@
import { Snowflake, TextChannel } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { sendErrorMessage } from "../../../pluginUtils.js";
import { messageLink } from "../../../utils.js";
import { canReadChannel } from "../../../utils/canReadChannel.js";
import { utilityCmd } from "../types.js";
@ -23,7 +22,7 @@ export const ContextCmd = utilityCmd({
async run({ message: msg, args, pluginData }) {
if (args.channel && !(args.channel instanceof TextChannel)) {
sendErrorMessage(pluginData, msg.channel, "Channel must be a text channel");
void pluginData.state.common.sendErrorMessage(msg, "Channel must be a text channel");
return;
}
@ -31,7 +30,7 @@ export const ContextCmd = utilityCmd({
const messageId = args.messageId ?? args.message.messageId;
if (!canReadChannel(channel, msg.member)) {
sendErrorMessage(pluginData, msg.channel, "Message context not found");
void pluginData.state.common.sendErrorMessage(msg, "Message context not found");
return;
}
@ -42,7 +41,7 @@ export const ContextCmd = utilityCmd({
})
)[0];
if (!previousMessage) {
sendErrorMessage(pluginData, msg.channel, "Message context not found");
void pluginData.state.common.sendErrorMessage(msg, "Message context not found");
return;
}

View file

@ -1,5 +1,4 @@
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { sendErrorMessage } from "../../../pluginUtils.js";
import { getCustomEmojiId } from "../functions/getCustomEmojiId.js";
import { getEmojiInfoEmbed } from "../functions/getEmojiInfoEmbed.js";
import { utilityCmd } from "../types.js";
@ -17,13 +16,13 @@ export const EmojiInfoCmd = utilityCmd({
async run({ message, args, pluginData }) {
const emojiId = getCustomEmojiId(args.emoji);
if (!emojiId) {
sendErrorMessage(pluginData, message.channel, "Emoji not found");
void pluginData.state.common.sendErrorMessage(message, "Emoji not found");
return;
}
const embed = await getEmojiInfoEmbed(pluginData, emojiId);
if (!embed) {
sendErrorMessage(pluginData, message.channel, "Emoji not found");
void pluginData.state.common.sendErrorMessage(message, "Emoji not found");
return;
}

View file

@ -1,6 +1,5 @@
import { LoadedGuildPlugin, PluginCommandDefinition } from "knub";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { env } from "../../../env.js";
import { createChunkedMessage } from "../../../utils.js";
import { utilityCmd } from "../types.js";

View file

@ -1,7 +1,6 @@
import { Snowflake } from "discord.js";
import { getChannelId, getRoleId } from "knub/helpers";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { sendErrorMessage } from "../../../pluginUtils.js";
import { isValidSnowflake, noop, parseInviteCodeInput, resolveInvite, resolveUser } from "../../../utils.js";
import { canReadChannel } from "../../../utils/canReadChannel.js";
import { resolveMessageTarget } from "../../../utils/resolveMessageTarget.js";
@ -146,9 +145,8 @@ export const InfoCmd = utilityCmd({
}
// 10. No can do
sendErrorMessage(
pluginData,
message.channel,
void pluginData.state.common.sendErrorMessage(
message,
"Could not find anything with that value or you are lacking permission for the snowflake type",
);
},

View file

@ -1,5 +1,4 @@
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { sendErrorMessage } from "../../../pluginUtils.js";
import { parseInviteCodeInput } from "../../../utils.js";
import { getInviteInfoEmbed } from "../functions/getInviteInfoEmbed.js";
import { utilityCmd } from "../types.js";
@ -18,7 +17,7 @@ export const InviteInfoCmd = utilityCmd({
const inviteCode = parseInviteCodeInput(args.inviteCode);
const embed = await getInviteInfoEmbed(pluginData, inviteCode);
if (!embed) {
sendErrorMessage(pluginData, message.channel, "Unknown invite");
void pluginData.state.common.sendErrorMessage(message, "Unknown invite");
return;
}

View file

@ -3,7 +3,6 @@ import { AttachmentBuilder } from "discord.js";
import fs from "fs";
import twemoji from "twemoji";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { sendErrorMessage } from "../../../pluginUtils.js";
import { downloadFile, isEmoji, SECONDS } from "../../../utils.js";
import { utilityCmd } from "../types.js";
@ -51,7 +50,7 @@ export const JumboCmd = utilityCmd({
let file: AttachmentBuilder | undefined;
if (!isEmoji(args.emoji)) {
sendErrorMessage(pluginData, msg.channel, "Invalid emoji");
void pluginData.state.common.sendErrorMessage(msg, "Invalid emoji");
return;
}
@ -87,7 +86,7 @@ export const JumboCmd = utilityCmd({
}
}
if (!image) {
sendErrorMessage(pluginData, msg.channel, "Error occurred while jumboing default emoji");
void pluginData.state.common.sendErrorMessage(msg, "Error occurred while jumboing default emoji");
return;
}

View file

@ -1,5 +1,4 @@
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { sendErrorMessage } from "../../../pluginUtils.js";
import { canReadChannel } from "../../../utils/canReadChannel.js";
import { getMessageInfoEmbed } from "../functions/getMessageInfoEmbed.js";
import { utilityCmd } from "../types.js";
@ -16,13 +15,13 @@ export const MessageInfoCmd = utilityCmd({
async run({ message, args, pluginData }) {
if (!canReadChannel(args.message.channel, message.member)) {
sendErrorMessage(pluginData, message.channel, "Unknown message");
void pluginData.state.common.sendErrorMessage(message, "Unknown message");
return;
}
const embed = await getMessageInfoEmbed(pluginData, args.message.channel.id, args.message.messageId);
if (!embed) {
sendErrorMessage(pluginData, message.channel, "Unknown message");
void pluginData.state.common.sendErrorMessage(message, "Unknown message");
return;
}

View file

@ -1,6 +1,6 @@
import { escapeBold } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { canActOn, sendSuccessMessage } from "../../../pluginUtils.js";
import { canActOn } from "../../../pluginUtils.js";
import { errorMessage } from "../../../utils.js";
import { utilityCmd } from "../types.js";
@ -45,9 +45,8 @@ export const NicknameCmd = utilityCmd({
return;
}
sendSuccessMessage(
pluginData,
msg.channel,
void pluginData.state.common.sendSuccessMessage(
msg,
`Changed nickname of <@!${args.member.id}> from **${oldNickname}** to **${args.nickname}**`,
);
},

View file

@ -1,5 +1,5 @@
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { canActOn, sendSuccessMessage } from "../../../pluginUtils.js";
import { canActOn } from "../../../pluginUtils.js";
import { errorMessage } from "../../../utils.js";
import { utilityCmd } from "../types.js";
@ -31,6 +31,6 @@ export const NicknameResetCmd = utilityCmd({
return;
}
sendSuccessMessage(pluginData, msg.channel, `The nickname of <@!${args.member.id}> has been reset`);
void pluginData.state.common.sendSuccessMessage(msg, `The nickname of <@!${args.member.id}> has been reset`);
},
});

View file

@ -1,6 +1,5 @@
import { Role } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { sendErrorMessage } from "../../../pluginUtils.js";
import { chunkArray, sorter, trimLines } from "../../../utils.js";
import { refreshMembersIfNeeded } from "../refreshMembers.js";
import { utilityCmd } from "../types.js";
@ -62,7 +61,7 @@ export const RolesCmd = utilityCmd({
} else if (sort === "name") {
roles.sort(sorter((r) => r.name.toLowerCase(), sortDir));
} else {
sendErrorMessage(pluginData, msg.channel, "Unknown sorting method");
void pluginData.state.common.sendErrorMessage(msg, "Unknown sorting method");
return;
}

View file

@ -1,5 +1,4 @@
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { sendErrorMessage } from "../../../pluginUtils.js";
import { getServerInfoEmbed } from "../functions/getServerInfoEmbed.js";
import { utilityCmd } from "../types.js";
@ -17,7 +16,7 @@ export const ServerInfoCmd = utilityCmd({
const serverId = args.serverId || pluginData.guild.id;
const serverInfoEmbed = await getServerInfoEmbed(pluginData, serverId);
if (!serverInfoEmbed) {
sendErrorMessage(pluginData, message.channel, "Could not find information for that server");
void pluginData.state.common.sendErrorMessage(message, "Could not find information for that server");
return;
}

View file

@ -1,6 +1,6 @@
import moment from "moment-timezone";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { getBaseUrl, sendErrorMessage } from "../../../pluginUtils.js";
import { getBaseUrl } from "../../../pluginUtils.js";
import { canReadChannel } from "../../../utils/canReadChannel.js";
import { utilityCmd } from "../types.js";
@ -16,13 +16,13 @@ export const SourceCmd = utilityCmd({
async run({ message: cmdMessage, args, pluginData }) {
if (!canReadChannel(args.message.channel, cmdMessage.member)) {
sendErrorMessage(pluginData, cmdMessage.channel, "Unknown message");
void pluginData.state.common.sendErrorMessage(cmdMessage, "Unknown message");
return;
}
const message = await args.message.channel.messages.fetch(args.message.messageId);
if (!message) {
sendErrorMessage(pluginData, cmdMessage.channel, "Unknown message");
void pluginData.state.common.sendErrorMessage(cmdMessage, "Unknown message");
return;
}

View file

@ -1,5 +1,4 @@
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { sendErrorMessage } from "../../../pluginUtils.js";
import { getUserInfoEmbed } from "../functions/getUserInfoEmbed.js";
import { utilityCmd } from "../types.js";
@ -19,7 +18,7 @@ export const UserInfoCmd = utilityCmd({
const userId = args.user?.id || message.author.id;
const embed = await getUserInfoEmbed(pluginData, userId, args.compact);
if (!embed) {
sendErrorMessage(pluginData, message.channel, "User not found");
void pluginData.state.common.sendErrorMessage(message, "User not found");
return;
}

View file

@ -1,6 +1,6 @@
import { VoiceChannel } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils.js";
import { canActOn } from "../../../pluginUtils.js";
import { renderUsername } from "../../../utils.js";
import { LogsPlugin } from "../../Logs/LogsPlugin.js";
import { utilityCmd } from "../types.js";
@ -17,12 +17,12 @@ export const VcdisconnectCmd = utilityCmd({
async run({ message: msg, args, pluginData }) {
if (!canActOn(pluginData, msg.member, args.member)) {
sendErrorMessage(pluginData, msg.channel, "Cannot move: insufficient permissions");
void pluginData.state.common.sendErrorMessage(msg, "Cannot move: insufficient permissions");
return;
}
if (!args.member.voice?.channelId) {
sendErrorMessage(pluginData, msg.channel, "Member is not in a voice channel");
void pluginData.state.common.sendErrorMessage(msg, "Member is not in a voice channel");
return;
}
const channel = pluginData.guild.channels.cache.get(args.member.voice.channelId) as VoiceChannel;
@ -30,7 +30,7 @@ export const VcdisconnectCmd = utilityCmd({
try {
await args.member.voice.disconnect();
} catch {
sendErrorMessage(pluginData, msg.channel, "Failed to disconnect member");
void pluginData.state.common.sendErrorMessage(msg, "Failed to disconnect member");
return;
}
@ -40,9 +40,8 @@ export const VcdisconnectCmd = utilityCmd({
oldChannel: channel,
});
sendSuccessMessage(
pluginData,
msg.channel,
pluginData.state.common.sendSuccessMessage(
msg,
`**${renderUsername(args.member)}** disconnected from **${channel.name}**`,
);
},

View file

@ -1,6 +1,6 @@
import { ChannelType, Snowflake, VoiceChannel } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils.js";
import { canActOn } from "../../../pluginUtils.js";
import { channelMentionRegex, isSnowflake, renderUsername, simpleClosestStringMatch } from "../../../utils.js";
import { LogsPlugin } from "../../Logs/LogsPlugin.js";
import { utilityCmd } from "../types.js";
@ -23,7 +23,7 @@ export const VcmoveCmd = utilityCmd({
// Snowflake -> resolve channel directly
const potentialChannel = pluginData.guild.channels.cache.get(args.channel as Snowflake);
if (!potentialChannel || !(potentialChannel instanceof VoiceChannel)) {
sendErrorMessage(pluginData, msg.channel, "Unknown or non-voice channel");
void pluginData.state.common.sendErrorMessage(msg, "Unknown or non-voice channel");
return;
}
@ -33,7 +33,7 @@ export const VcmoveCmd = utilityCmd({
const channelId = args.channel.match(channelMentionRegex)![1];
const potentialChannel = pluginData.guild.channels.cache.get(channelId as Snowflake);
if (!potentialChannel || !(potentialChannel instanceof VoiceChannel)) {
sendErrorMessage(pluginData, msg.channel, "Unknown or non-voice channel");
void pluginData.state.common.sendErrorMessage(msg, "Unknown or non-voice channel");
return;
}
@ -45,7 +45,7 @@ export const VcmoveCmd = utilityCmd({
);
const closestMatch = simpleClosestStringMatch(args.channel, voiceChannels, (ch) => ch.name);
if (!closestMatch) {
sendErrorMessage(pluginData, msg.channel, "No matching voice channels");
void pluginData.state.common.sendErrorMessage(msg, "No matching voice channels");
return;
}
@ -53,12 +53,12 @@ export const VcmoveCmd = utilityCmd({
}
if (!args.member.voice?.channelId) {
sendErrorMessage(pluginData, msg.channel, "Member is not in a voice channel");
void pluginData.state.common.sendErrorMessage(msg, "Member is not in a voice channel");
return;
}
if (args.member.voice.channelId === channel.id) {
sendErrorMessage(pluginData, msg.channel, "Member is already on that channel!");
void pluginData.state.common.sendErrorMessage(msg, "Member is already on that channel!");
return;
}
@ -69,7 +69,7 @@ export const VcmoveCmd = utilityCmd({
channel: channel.id,
});
} catch {
sendErrorMessage(pluginData, msg.channel, "Failed to move member");
void pluginData.state.common.sendErrorMessage(msg, "Failed to move member");
return;
}
@ -80,7 +80,10 @@ export const VcmoveCmd = utilityCmd({
newChannel: channel,
});
sendSuccessMessage(pluginData, msg.channel, `**${renderUsername(args.member)}** moved to **${channel.name}**`);
void pluginData.state.common.sendSuccessMessage(
msg,
`**${renderUsername(args.member)}** moved to **${channel.name}**`,
);
},
});
@ -102,7 +105,7 @@ export const VcmoveAllCmd = utilityCmd({
// Snowflake -> resolve channel directly
const potentialChannel = pluginData.guild.channels.cache.get(args.channel as Snowflake);
if (!potentialChannel || !(potentialChannel instanceof VoiceChannel)) {
sendErrorMessage(pluginData, msg.channel, "Unknown or non-voice channel");
void pluginData.state.common.sendErrorMessage(msg, "Unknown or non-voice channel");
return;
}
@ -112,7 +115,7 @@ export const VcmoveAllCmd = utilityCmd({
const channelId = args.channel.match(channelMentionRegex)![1];
const potentialChannel = pluginData.guild.channels.cache.get(channelId as Snowflake);
if (!potentialChannel || !(potentialChannel instanceof VoiceChannel)) {
sendErrorMessage(pluginData, msg.channel, "Unknown or non-voice channel");
void pluginData.state.common.sendErrorMessage(msg, "Unknown or non-voice channel");
return;
}
@ -124,7 +127,7 @@ export const VcmoveAllCmd = utilityCmd({
);
const closestMatch = simpleClosestStringMatch(args.channel, voiceChannels, (ch) => ch.name);
if (!closestMatch) {
sendErrorMessage(pluginData, msg.channel, "No matching voice channels");
void pluginData.state.common.sendErrorMessage(msg, "No matching voice channels");
return;
}
@ -132,12 +135,12 @@ export const VcmoveAllCmd = utilityCmd({
}
if (args.oldChannel.members.size === 0) {
sendErrorMessage(pluginData, msg.channel, "Voice channel is empty");
void pluginData.state.common.sendErrorMessage(msg, "Voice channel is empty");
return;
}
if (args.oldChannel.id === channel.id) {
sendErrorMessage(pluginData, msg.channel, "Cant move from and to the same channel!");
void pluginData.state.common.sendErrorMessage(msg, "Cant move from and to the same channel!");
return;
}
@ -150,9 +153,8 @@ export const VcmoveAllCmd = utilityCmd({
// Check for permissions but allow self-moves
if (currMember.id !== msg.member.id && !canActOn(pluginData, msg.member, currMember)) {
sendErrorMessage(
pluginData,
msg.channel,
void pluginData.state.common.sendErrorMessage(
msg,
`Failed to move ${renderUsername(currMember)} (${currMember.id}): You cannot act on this member`,
);
errAmt++;
@ -165,10 +167,13 @@ export const VcmoveAllCmd = utilityCmd({
});
} catch {
if (msg.member.id === currMember.id) {
sendErrorMessage(pluginData, msg.channel, "Unknown error when trying to move members");
void pluginData.state.common.sendErrorMessage(msg, "Unknown error when trying to move members");
return;
}
sendErrorMessage(pluginData, msg.channel, `Failed to move ${renderUsername(currMember)} (${currMember.id})`);
void pluginData.state.common.sendErrorMessage(
msg,
`Failed to move ${renderUsername(currMember)} (${currMember.id})`,
);
errAmt++;
continue;
}
@ -182,13 +187,12 @@ export const VcmoveAllCmd = utilityCmd({
}
if (moveAmt !== errAmt) {
sendSuccessMessage(
pluginData,
msg.channel,
void pluginData.state.common.sendSuccessMessage(
msg,
`${moveAmt - errAmt} members from **${args.oldChannel.name}** moved to **${channel.name}**`,
);
} else {
sendErrorMessage(pluginData, msg.channel, `Failed to move any members.`);
void pluginData.state.common.sendErrorMessage(msg, `Failed to move any members.`);
}
},
});

View file

@ -13,7 +13,7 @@ import escapeStringRegexp from "escape-string-regexp";
import { ArgsFromSignatureOrArray, GuildPluginData } from "knub";
import moment from "moment-timezone";
import { RegExpRunner, allowTimeout } from "../../RegExpRunner.js";
import { getBaseUrl, sendErrorMessage } from "../../pluginUtils.js";
import { getBaseUrl } from "../../pluginUtils.js";
import {
InvalidRegexError,
MINUTES,
@ -122,12 +122,12 @@ export async function displaySearch(
}
} catch (e) {
if (e instanceof SearchError) {
sendErrorMessage(pluginData, msg.channel, e.message);
void pluginData.state.common.sendErrorMessage(msg, e.message);
return;
}
if (e instanceof InvalidRegexError) {
sendErrorMessage(pluginData, msg.channel, e.message);
void pluginData.state.common.sendErrorMessage(msg, e.message);
return;
}
@ -135,7 +135,7 @@ export async function displaySearch(
}
if (searchResult.totalResults === 0) {
sendErrorMessage(pluginData, msg.channel, "No results found");
void pluginData.state.common.sendErrorMessage(msg, "No results found");
return;
}
@ -266,12 +266,12 @@ export async function archiveSearch(
}
} catch (e) {
if (e instanceof SearchError) {
sendErrorMessage(pluginData, msg.channel, e.message);
void pluginData.state.common.sendErrorMessage(msg, e.message);
return;
}
if (e instanceof InvalidRegexError) {
sendErrorMessage(pluginData, msg.channel, e.message);
void pluginData.state.common.sendErrorMessage(msg, e.message);
return;
}
@ -279,7 +279,7 @@ export async function archiveSearch(
}
if (results.totalResults === 0) {
sendErrorMessage(pluginData, msg.channel, "No results found");
void pluginData.state.common.sendErrorMessage(msg, "No results found");
return;
}

View file

@ -1,4 +1,4 @@
import { BasePluginType, guildPluginEventListener, guildPluginMessageCommand } from "knub";
import { BasePluginType, guildPluginEventListener, guildPluginMessageCommand, pluginUtils } from "knub";
import z from "zod";
import { RegExpRunner } from "../../RegExpRunner.js";
import { GuildArchives } from "../../data/GuildArchives.js";
@ -6,6 +6,7 @@ import { GuildCases } from "../../data/GuildCases.js";
import { GuildLogs } from "../../data/GuildLogs.js";
import { GuildSavedMessages } from "../../data/GuildSavedMessages.js";
import { Supporters } from "../../data/Supporters.js";
import { CommonPlugin } from "../Common/CommonPlugin.js";
export const zUtilityConfig = z.strictObject({
can_roles: z.boolean(),
@ -48,6 +49,8 @@ export interface UtilityPluginType extends BasePluginType {
regexRunner: RegExpRunner;
lastReload: number;
common: pluginUtils.PluginPublicInterface<typeof CommonPlugin>;
};
}