mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-08 03:27:20 +00:00
Fixes, refactoring and PR feedback
This commit is contained in:
parent
0be54912c4
commit
893a77d562
202 changed files with 1037 additions and 1069 deletions
|
@ -193,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)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendSuccessMessage(activeReloads.get(guild.id)!, "Reloaded!");
|
||||
pluginData.state.common.sendSuccessMessage(activeReloads.get(guild.id)!, "Reloaded!");
|
||||
activeReloads.delete(guild.id);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -24,7 +24,7 @@ export const AvatarCmd = utilityCmd({
|
|||
};
|
||||
msg.channel.send({ embeds: [embed] });
|
||||
} else {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Invalid user ID");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Invalid user ID");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ export const ChannelInfoCmd = utilityCmd({
|
|||
async run({ message, args, pluginData }) {
|
||||
const embed = await getChannelInfoEmbed(pluginData, args.channel);
|
||||
if (!embed) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "Unknown channel");
|
||||
void pluginData.state.common.sendErrorMessage(message, "Unknown channel");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,22 +83,18 @@ export interface CleanArgs {
|
|||
|
||||
export async function cleanCmd(pluginData: GuildPluginData<UtilityPluginType>, args: CleanArgs | any, msg) {
|
||||
if (args.count > MAX_CLEAN_COUNT || args.count <= 0) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(
|
||||
msg,
|
||||
`Clean count must be between 1 and ${MAX_CLEAN_COUNT}`,
|
||||
undefined,
|
||||
args["response-interaction"],
|
||||
);
|
||||
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()) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(msg, `Invalid channel specified`, undefined, args["response-interaction"]);
|
||||
void pluginData.state.common.sendErrorMessage(msg, `Invalid channel specified`, undefined, args["response-interaction"]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -110,14 +106,12 @@ export async function cleanCmd(pluginData: GuildPluginData<UtilityPluginType>, a
|
|||
categoryId: targetChannel.parentId,
|
||||
});
|
||||
if (configForTargetChannel.can_clean !== true) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(
|
||||
msg,
|
||||
`Missing permissions to use clean on that channel`,
|
||||
undefined,
|
||||
args["response-interaction"],
|
||||
);
|
||||
void pluginData.state.common.sendErrorMessage(
|
||||
msg,
|
||||
`Missing permissions to use clean on that channel`,
|
||||
undefined,
|
||||
args["response-interaction"],
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -223,14 +217,10 @@ export async function cleanCmd(pluginData: GuildPluginData<UtilityPluginType>, a
|
|||
}
|
||||
}
|
||||
|
||||
responseMsg = await pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(msg, responseText, undefined, args["response-interaction"]);
|
||||
responseMsg = await pluginData.state.common.sendSuccessMessage(msg, responseText, undefined, args["response-interaction"]);
|
||||
} else {
|
||||
const responseText = `Found no messages to clean${note ? ` (${note})` : ""}!`;
|
||||
responseMsg = await pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(msg, responseText, undefined, args["response-interaction"]);
|
||||
responseMsg = await pluginData.state.common.sendErrorMessage(msg, responseText, undefined, args["response-interaction"]);
|
||||
}
|
||||
|
||||
cleaningMessage?.delete();
|
||||
|
|
|
@ -23,7 +23,7 @@ export const ContextCmd = utilityCmd({
|
|||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
if (args.channel && !(args.channel instanceof TextChannel)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Channel must be a text channel");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Channel must be a text channel");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ export const ContextCmd = utilityCmd({
|
|||
const messageId = args.messageId ?? args.message.messageId;
|
||||
|
||||
if (!canReadChannel(channel, msg.member)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Message context not found");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Message context not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ export const ContextCmd = utilityCmd({
|
|||
})
|
||||
)[0];
|
||||
if (!previousMessage) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Message context not found");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Message context not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,13 +17,13 @@ export const EmojiInfoCmd = utilityCmd({
|
|||
async run({ message, args, pluginData }) {
|
||||
const emojiId = getCustomEmojiId(args.emoji);
|
||||
if (!emojiId) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "Emoji not found");
|
||||
void pluginData.state.common.sendErrorMessage(message, "Emoji not found");
|
||||
return;
|
||||
}
|
||||
|
||||
const embed = await getEmojiInfoEmbed(pluginData, emojiId);
|
||||
if (!embed) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "Emoji not found");
|
||||
void pluginData.state.common.sendErrorMessage(message, "Emoji not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -146,11 +146,9 @@ export const InfoCmd = utilityCmd({
|
|||
}
|
||||
|
||||
// 10. No can do
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(
|
||||
message,
|
||||
"Could not find anything with that value or you are lacking permission for the snowflake type",
|
||||
);
|
||||
void pluginData.state.common.sendErrorMessage(
|
||||
message,
|
||||
"Could not find anything with that value or you are lacking permission for the snowflake type",
|
||||
);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@ export const InviteInfoCmd = utilityCmd({
|
|||
const inviteCode = parseInviteCodeInput(args.inviteCode);
|
||||
const embed = await getInviteInfoEmbed(pluginData, inviteCode);
|
||||
if (!embed) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "Unknown invite");
|
||||
void pluginData.state.common.sendErrorMessage(message, "Unknown invite");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ export const JumboCmd = utilityCmd({
|
|||
let file: AttachmentBuilder | undefined;
|
||||
|
||||
if (!isEmoji(args.emoji)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Invalid emoji");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Invalid emoji");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ export const JumboCmd = utilityCmd({
|
|||
}
|
||||
}
|
||||
if (!image) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Error occurred while jumboing default emoji");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Error occurred while jumboing default emoji");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@ export const MessageInfoCmd = utilityCmd({
|
|||
|
||||
async run({ message, args, pluginData }) {
|
||||
if (!canReadChannel(args.message.channel, message.member)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "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) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "Unknown message");
|
||||
void pluginData.state.common.sendErrorMessage(message, "Unknown message");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,11 +46,9 @@ export const NicknameCmd = utilityCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(
|
||||
msg,
|
||||
`Changed nickname of <@!${args.member.id}> from **${oldNickname}** to **${args.nickname}**`,
|
||||
);
|
||||
void pluginData.state.common.sendSuccessMessage(
|
||||
msg,
|
||||
`Changed nickname of <@!${args.member.id}> from **${oldNickname}** to **${args.nickname}**`,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -32,6 +32,6 @@ export const NicknameResetCmd = utilityCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
pluginData.getPlugin(CommonPlugin).sendSuccessMessage(msg, `The nickname of <@!${args.member.id}> has been reset`);
|
||||
void pluginData.state.common.sendSuccessMessage(msg, `The nickname of <@!${args.member.id}> has been reset`);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -62,7 +62,7 @@ export const RolesCmd = utilityCmd({
|
|||
} else if (sort === "name") {
|
||||
roles.sort(sorter((r) => r.name.toLowerCase(), sortDir));
|
||||
} else {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Unknown sorting method");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Unknown sorting method");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ export const ServerInfoCmd = utilityCmd({
|
|||
const serverId = args.serverId || pluginData.guild.id;
|
||||
const serverInfoEmbed = await getServerInfoEmbed(pluginData, serverId);
|
||||
if (!serverInfoEmbed) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "Could not find information for that server");
|
||||
void pluginData.state.common.sendErrorMessage(message, "Could not find information for that server");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,13 +17,13 @@ export const SourceCmd = utilityCmd({
|
|||
|
||||
async run({ message: cmdMessage, args, pluginData }) {
|
||||
if (!canReadChannel(args.message.channel, cmdMessage.member)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(cmdMessage, "Unknown message");
|
||||
void pluginData.state.common.sendErrorMessage(cmdMessage, "Unknown message");
|
||||
return;
|
||||
}
|
||||
|
||||
const message = await args.message.channel.messages.fetch(args.message.messageId);
|
||||
if (!message) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(cmdMessage, "Unknown message");
|
||||
void pluginData.state.common.sendErrorMessage(cmdMessage, "Unknown message");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ export const UserInfoCmd = utilityCmd({
|
|||
const userId = args.user?.id || message.author.id;
|
||||
const embed = await getUserInfoEmbed(pluginData, userId, args.compact);
|
||||
if (!embed) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(message, "User not found");
|
||||
void pluginData.state.common.sendErrorMessage(message, "User not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@ export const VcdisconnectCmd = utilityCmd({
|
|||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
if (!canActOn(pluginData, msg.member, args.member)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Cannot move: insufficient permissions");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Cannot move: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.member.voice?.channelId) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "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;
|
||||
|
@ -31,7 +31,7 @@ export const VcdisconnectCmd = utilityCmd({
|
|||
try {
|
||||
await args.member.voice.disconnect();
|
||||
} catch {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Failed to disconnect member");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Failed to disconnect member");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -41,8 +41,9 @@ export const VcdisconnectCmd = utilityCmd({
|
|||
oldChannel: channel,
|
||||
});
|
||||
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(msg, `**${renderUsername(args.member)}** disconnected from **${channel.name}**`);
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
msg,
|
||||
`**${renderUsername(args.member)}** disconnected from **${channel.name}**`
|
||||
);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -24,7 +24,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)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Unknown or non-voice channel");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Unknown or non-voice channel");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,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)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Unknown or non-voice channel");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Unknown or non-voice channel");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ export const VcmoveCmd = utilityCmd({
|
|||
);
|
||||
const closestMatch = simpleClosestStringMatch(args.channel, voiceChannels, (ch) => ch.name);
|
||||
if (!closestMatch) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "No matching voice channels");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "No matching voice channels");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -54,12 +54,12 @@ export const VcmoveCmd = utilityCmd({
|
|||
}
|
||||
|
||||
if (!args.member.voice?.channelId) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "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) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Member is already on that channel!");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Member is already on that channel!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ export const VcmoveCmd = utilityCmd({
|
|||
channel: channel.id,
|
||||
});
|
||||
} catch {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Failed to move member");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Failed to move member");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -81,9 +81,7 @@ export const VcmoveCmd = utilityCmd({
|
|||
newChannel: channel,
|
||||
});
|
||||
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(msg, `**${renderUsername(args.member)}** moved to **${channel.name}**`);
|
||||
void pluginData.state.common.sendSuccessMessage(msg, `**${renderUsername(args.member)}** moved to **${channel.name}**`);
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -105,7 +103,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)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Unknown or non-voice channel");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Unknown or non-voice channel");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -115,7 +113,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)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Unknown or non-voice channel");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Unknown or non-voice channel");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -127,7 +125,7 @@ export const VcmoveAllCmd = utilityCmd({
|
|||
);
|
||||
const closestMatch = simpleClosestStringMatch(args.channel, voiceChannels, (ch) => ch.name);
|
||||
if (!closestMatch) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "No matching voice channels");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "No matching voice channels");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -135,12 +133,12 @@ export const VcmoveAllCmd = utilityCmd({
|
|||
}
|
||||
|
||||
if (args.oldChannel.members.size === 0) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Voice channel is empty");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Voice channel is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.oldChannel.id === channel.id) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Cant move from and to the same channel!");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Cant move from and to the same channel!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -153,12 +151,10 @@ export const VcmoveAllCmd = utilityCmd({
|
|||
|
||||
// Check for permissions but allow self-moves
|
||||
if (currMember.id !== msg.member.id && !canActOn(pluginData, msg.member, currMember)) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(
|
||||
msg,
|
||||
`Failed to move ${renderUsername(currMember)} (${currMember.id}): You cannot act on this member`,
|
||||
);
|
||||
void pluginData.state.common.sendErrorMessage(
|
||||
msg,
|
||||
`Failed to move ${renderUsername(currMember)} (${currMember.id}): You cannot act on this member`,
|
||||
);
|
||||
errAmt++;
|
||||
continue;
|
||||
}
|
||||
|
@ -169,12 +165,10 @@ export const VcmoveAllCmd = utilityCmd({
|
|||
});
|
||||
} catch {
|
||||
if (msg.member.id === currMember.id) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Unknown error when trying to move members");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "Unknown error when trying to move members");
|
||||
return;
|
||||
}
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(msg, `Failed to move ${renderUsername(currMember)} (${currMember.id})`);
|
||||
void pluginData.state.common.sendErrorMessage(msg, `Failed to move ${renderUsername(currMember)} (${currMember.id})`);
|
||||
errAmt++;
|
||||
continue;
|
||||
}
|
||||
|
@ -188,14 +182,12 @@ export const VcmoveAllCmd = utilityCmd({
|
|||
}
|
||||
|
||||
if (moveAmt !== errAmt) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(
|
||||
msg,
|
||||
`${moveAmt - errAmt} members from **${args.oldChannel.name}** moved to **${channel.name}**`,
|
||||
);
|
||||
void pluginData.state.common.sendSuccessMessage(
|
||||
msg,
|
||||
`${moveAmt - errAmt} members from **${args.oldChannel.name}** moved to **${channel.name}**`,
|
||||
);
|
||||
} else {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, `Failed to move any members.`);
|
||||
void pluginData.state.common.sendErrorMessage(msg, `Failed to move any members.`);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -25,7 +25,6 @@ import {
|
|||
} from "../../utils";
|
||||
import { asyncFilter } from "../../utils/async";
|
||||
import { hasDiscordPermissions } from "../../utils/hasDiscordPermissions";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin";
|
||||
import { banSearchSignature } from "./commands/BanSearchCmd";
|
||||
import { searchCmdSignature } from "./commands/SearchCmd";
|
||||
import { getUserInfoEmbed } from "./functions/getUserInfoEmbed";
|
||||
|
@ -123,12 +122,12 @@ export async function displaySearch(
|
|||
}
|
||||
} catch (e) {
|
||||
if (e instanceof SearchError) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, e.message);
|
||||
void pluginData.state.common.sendErrorMessage(msg, e.message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e instanceof InvalidRegexError) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, e.message);
|
||||
void pluginData.state.common.sendErrorMessage(msg, e.message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -136,7 +135,7 @@ export async function displaySearch(
|
|||
}
|
||||
|
||||
if (searchResult.totalResults === 0) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "No results found");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "No results found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -267,12 +266,12 @@ export async function archiveSearch(
|
|||
}
|
||||
} catch (e) {
|
||||
if (e instanceof SearchError) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, e.message);
|
||||
void pluginData.state.common.sendErrorMessage(msg, e.message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e instanceof InvalidRegexError) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, e.message);
|
||||
void pluginData.state.common.sendErrorMessage(msg, e.message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -280,7 +279,7 @@ export async function archiveSearch(
|
|||
}
|
||||
|
||||
if (results.totalResults === 0) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "No results found");
|
||||
void pluginData.state.common.sendErrorMessage(msg, "No results found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
import { GuildArchives } from "../../data/GuildArchives";
|
||||
|
@ -6,6 +6,7 @@ import { GuildCases } from "../../data/GuildCases";
|
|||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
import { Supporters } from "../../data/Supporters";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin";
|
||||
|
||||
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>;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue