Found fix?
This commit is contained in:
parent
29c03cb93c
commit
f2216b0dcf
2 changed files with 11 additions and 32 deletions
|
|
@ -1,15 +1,8 @@
|
|||
import { findByProps } from "@vendetta/metro";
|
||||
import { url } from "@vendetta/metro/common";
|
||||
import { validateChannelForCommand } from "../utils/messages";
|
||||
|
||||
const APIUtils = findByProps("getAPIBaseURL", "get");
|
||||
const MessageActions = findByProps("sendMessage");
|
||||
const messageUtil = findByProps("sendBotMessage", "sendMessage", "receiveMessage");
|
||||
|
||||
// Generate consistent nonce
|
||||
const generateNonce = () => {
|
||||
return (BigInt(Date.now()) * BigInt(4194304) + BigInt(Math.floor(Math.random() * 4194304))).toString();
|
||||
};
|
||||
|
||||
// Helper functions for fetching messages
|
||||
const getFirstGuildMessage = async (
|
||||
|
|
@ -71,20 +64,6 @@ export const firstMessageCommand = {
|
|||
},
|
||||
],
|
||||
execute: async (args: any, ctx: any) => {
|
||||
// Special handling for threads/forum channels
|
||||
if (ctx.channel.type >= 10 && ctx.channel.type <= 15) {
|
||||
return {
|
||||
type: 4,
|
||||
data: {
|
||||
content: "FirstMessage command doesn't work in thread or forum channels.",
|
||||
flags: 64
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const channelValidation = validateChannelForCommand(ctx);
|
||||
if (channelValidation) return channelValidation;
|
||||
|
||||
try {
|
||||
const options = new Map(args.map((option: any) => [option.name, option]));
|
||||
const user = options.get("user")?.value;
|
||||
|
|
@ -132,12 +111,12 @@ export const firstMessageCommand = {
|
|||
}
|
||||
|
||||
if (send) {
|
||||
const nonce = generateNonce();
|
||||
const fixNonce = Date.now().toString();
|
||||
MessageActions.sendMessage(
|
||||
ctx.channel.id,
|
||||
{ content: result },
|
||||
void 0,
|
||||
{ nonce }
|
||||
{ nonce: fixNonce }
|
||||
);
|
||||
return { type: 4 };
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ const addonAuthors = (authors: any) => {
|
|||
if (!authors) return "Unknown";
|
||||
if (!Array.isArray(authors)) return "Unknown";
|
||||
if (authors.length === 0) return "Unknown";
|
||||
|
||||
|
||||
return authors
|
||||
.filter(author => author && (typeof author === 'string' || (typeof author === 'object' && author.name)))
|
||||
.map(author => typeof author === 'string' ? author : (author.name || "Unknown"))
|
||||
|
|
@ -61,7 +61,7 @@ const getListLength = (list: string[]) => formatList(list).length;
|
|||
const sendList = async (channelID: string, list: string[]) => {
|
||||
// Use consistent nonce generation
|
||||
const nonce = (BigInt(Date.now()) * BigInt(4194304) + BigInt(Math.floor(Math.random() * 4194304))).toString();
|
||||
|
||||
|
||||
await MessageActions.sendMessage(channelID, {
|
||||
content: formatList(list)
|
||||
}, void 0, { nonce });
|
||||
|
|
@ -88,7 +88,7 @@ export async function themeList(args: any[], ctx: CommandContext) {
|
|||
}
|
||||
|
||||
const objectValues = Object.values(themes);
|
||||
|
||||
|
||||
const channelID: string = ctx.channel.id;
|
||||
|
||||
const themeList = baseListHeader('Theme', Object.keys(themes).length);
|
||||
|
|
@ -96,14 +96,14 @@ export async function themeList(args: any[], ctx: CommandContext) {
|
|||
if (objectValues.length) {
|
||||
for (const theme of objectValues) {
|
||||
if (!theme || typeof theme !== 'object') continue;
|
||||
|
||||
|
||||
const { selected, data, id } = theme;
|
||||
|
||||
|
||||
// Safe destructuring with fallbacks
|
||||
const name = data?.name || "Unknown Theme";
|
||||
const description = data?.description || "No description";
|
||||
const authors = data?.authors;
|
||||
|
||||
|
||||
if (detailed || alwaysDetailed)
|
||||
themeList.push(
|
||||
`> **Name**: ${name}`,
|
||||
|
|
@ -133,7 +133,7 @@ export async function themeList(args: any[], ctx: CommandContext) {
|
|||
cancelText: ALERT.CANCEL,
|
||||
onConfirm: async () => await sendList(channelID, themeList)
|
||||
});
|
||||
|
||||
|
||||
await sendList(channelID, themeList);
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
@ -162,9 +162,9 @@ export async function pluginList(args: any[], ctx: CommandContext) {
|
|||
|
||||
for (const plugin of Object.values(plugins)) {
|
||||
if (!plugin || typeof plugin !== 'object') continue;
|
||||
|
||||
|
||||
const { enabled, manifest, id } = plugin;
|
||||
|
||||
|
||||
// Safe destructuring with fallbacks
|
||||
const name = manifest?.name || "Unknown Plugin";
|
||||
const description = manifest?.description || "No description";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue