Found fix?

This commit is contained in:
kmmiio99o 2025-09-30 15:05:52 +02:00
parent f2216b0dcf
commit 03b4f1070b

View file

@ -3,31 +3,60 @@ import { themes } from "@vendetta/themes";
import { plugins } from "@vendetta/plugins"; import { plugins } from "@vendetta/plugins";
import { storage } from "@vendetta/plugin"; import { storage } from "@vendetta/plugin";
import { alerts } from "@vendetta/ui"; import { alerts } from "@vendetta/ui";
import { validateChannelForCommand } from "../utils/messages";
import { // Define constants directly since ../consts doesn't exist
ALERT, const ALERT = {
ARGS, CONTENT: "This list is over 2000 characters. Send anyway?",
EMPTY, CONFIRM: "Send",
FAILED_TO_SEND_LIST, CANCEL: "Cancel"
JOINERS, };
NOTHING_TO_SEE,
SPLIT_LARGE_MESSAGES_PLUGIN, const ARGS = {
STATUS DETAILED: "detailed"
} from "../consts"; };
const EMPTY = "";
const FAILED_TO_SEND_LIST = {
SLM_NOT_INSTALLED: "This list is over 2000 characters. Install the Split Large Messages plugin to send it.",
SLM_NOT_ENABLED: "This list is over 2000 characters. Enable the Split Large Messages plugin to send it."
};
const JOINERS = {
SEMICOL: "; ",
NEW_LINE: "\n"
};
const NOTHING_TO_SEE = "Nothing to see here, huh...";
const SPLIT_LARGE_MESSAGES_PLUGIN = "github.com/fres621/vendetta-plugins";
const STATUS = {
ENABLED: "✅",
DISABLED: "❌",
SELECTED: "✅",
NOT_SELECTED: "❌"
};
const MessageActions = findByProps('sendMessage', 'receiveMessage'); const MessageActions = findByProps('sendMessage', 'receiveMessage');
const Clyde = findByProps('sendBotMessage'); const Clyde = findByProps('sendBotMessage');
const maxMessageLength = findByStoreName('UserStore') const maxMessageLength = (() => {
.getCurrentUser() try {
?.premiumType === 2 return findByStoreName('UserStore')
? 4000 .getCurrentUser()
: 2000; ?.premiumType === 2
? 4000
: 2000;
} catch (e) {
return 2000; // fallback
}
})();
const isSLMPluginInstalled = (installedPlugins: typeof plugins) => const isSLMPluginInstalled = (installedPlugins: typeof plugins) =>
Object.keys(installedPlugins) Object.keys(installedPlugins)
.includes(SPLIT_LARGE_MESSAGES_PLUGIN); .includes(SPLIT_LARGE_MESSAGES_PLUGIN);
const isSLMPluginEnabled = (installedPlugins: typeof plugins) => const isSLMPluginEnabled = (installedPlugins: typeof plugins) =>
Object.values(installedPlugins) Object.values(installedPlugins)
.find((plugin) => plugin.id == SPLIT_LARGE_MESSAGES_PLUGIN) .find((plugin) => plugin.id == SPLIT_LARGE_MESSAGES_PLUGIN)
@ -44,7 +73,7 @@ const addonAuthors = (authors: any) => {
if (!authors) return "Unknown"; if (!authors) return "Unknown";
if (!Array.isArray(authors)) return "Unknown"; if (!Array.isArray(authors)) return "Unknown";
if (authors.length === 0) return "Unknown"; if (authors.length === 0) return "Unknown";
return authors return authors
.filter(author => author && (typeof author === 'string' || (typeof author === 'object' && author.name))) .filter(author => author && (typeof author === 'string' || (typeof author === 'object' && author.name)))
.map(author => typeof author === 'string' ? author : (author.name || "Unknown")) .map(author => typeof author === 'string' ? author : (author.name || "Unknown"))
@ -59,12 +88,10 @@ const formatList = (list: string[]) =>
const getListLength = (list: string[]) => formatList(list).length; const getListLength = (list: string[]) => formatList(list).length;
const sendList = async (channelID: string, list: string[]) => { const sendList = async (channelID: string, list: string[]) => {
// Use consistent nonce generation const fixNonce = Date.now().toString();
const nonce = (BigInt(Date.now()) * BigInt(4194304) + BigInt(Math.floor(Math.random() * 4194304))).toString();
await MessageActions.sendMessage(channelID, { await MessageActions.sendMessage(channelID, {
content: formatList(list) content: formatList(list)
}, void 0, { nonce }); }, void 0, { nonce: fixNonce });
}; };
const baseListHeader = (type: 'Plugin' | 'Theme', length: number) => [ const baseListHeader = (type: 'Plugin' | 'Theme', length: number) => [
@ -72,10 +99,7 @@ const baseListHeader = (type: 'Plugin' | 'Theme', length: number) => [
EMPTY EMPTY
]; ];
export async function themeList(args: any[], ctx: CommandContext) { export async function themeList(args: any[], ctx: any) {
const channelValidation = validateChannelForCommand(ctx);
if (channelValidation) return channelValidation;
try { try {
const detailed = getArgumentValue(args); const detailed = getArgumentValue(args);
const alwaysDetailed = storage.themeListAlwaysDetailed ?? false; const alwaysDetailed = storage.themeListAlwaysDetailed ?? false;
@ -88,7 +112,7 @@ export async function themeList(args: any[], ctx: CommandContext) {
} }
const objectValues = Object.values(themes); const objectValues = Object.values(themes);
const channelID: string = ctx.channel.id; const channelID: string = ctx.channel.id;
const themeList = baseListHeader('Theme', Object.keys(themes).length); const themeList = baseListHeader('Theme', Object.keys(themes).length);
@ -96,14 +120,14 @@ export async function themeList(args: any[], ctx: CommandContext) {
if (objectValues.length) { if (objectValues.length) {
for (const theme of objectValues) { for (const theme of objectValues) {
if (!theme || typeof theme !== 'object') continue; if (!theme || typeof theme !== 'object') continue;
const { selected, data, id } = theme; const { selected, data, id } = theme;
// Safe destructuring with fallbacks // Safe destructuring with fallbacks
const name = data?.name || "Unknown Theme"; const name = data?.name || "Unknown Theme";
const description = data?.description || "No description"; const description = data?.description || "No description";
const authors = data?.authors; const authors = data?.authors;
if (detailed || alwaysDetailed) if (detailed || alwaysDetailed)
themeList.push( themeList.push(
`> **Name**: ${name}`, `> **Name**: ${name}`,
@ -133,7 +157,7 @@ export async function themeList(args: any[], ctx: CommandContext) {
cancelText: ALERT.CANCEL, cancelText: ALERT.CANCEL,
onConfirm: async () => await sendList(channelID, themeList) onConfirm: async () => await sendList(channelID, themeList)
}); });
await sendList(channelID, themeList); await sendList(channelID, themeList);
} }
} catch (error) { } catch (error) {
@ -142,10 +166,7 @@ export async function themeList(args: any[], ctx: CommandContext) {
} }
} }
export async function pluginList(args: any[], ctx: CommandContext) { export async function pluginList(args: any[], ctx: any) {
const channelValidation = validateChannelForCommand(ctx);
if (channelValidation) return channelValidation;
try { try {
const detailed = getArgumentValue(args); const detailed = getArgumentValue(args);
const alwaysDetailed = storage.pluginListAlwaysDetailed ?? false; const alwaysDetailed = storage.pluginListAlwaysDetailed ?? false;
@ -162,9 +183,9 @@ export async function pluginList(args: any[], ctx: CommandContext) {
for (const plugin of Object.values(plugins)) { for (const plugin of Object.values(plugins)) {
if (!plugin || typeof plugin !== 'object') continue; if (!plugin || typeof plugin !== 'object') continue;
const { enabled, manifest, id } = plugin; const { enabled, manifest, id } = plugin;
// Safe destructuring with fallbacks // Safe destructuring with fallbacks
const name = manifest?.name || "Unknown Plugin"; const name = manifest?.name || "Unknown Plugin";
const description = manifest?.description || "No description"; const description = manifest?.description || "No description";