From 6c862089a99cda4ce66051b74636d6ff13a1ba98 Mon Sep 17 00:00:00 2001 From: Snazzah Date: Thu, 5 Sep 2024 20:54:57 -0500 Subject: [PATCH] fix: fix prompts --- src/index.ts | 4 ++-- src/util/index.ts | 10 +++++----- src/util/prompt.ts | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index aa40f6b..0c612d9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -66,7 +66,7 @@ creator.on('componentInteraction', async (ctx) => { if (ctx.customID === 'none') return ctx.acknowledge(); else if (ctx.customID === 'delete') { const { t } = await getData(ctx); - if (ctx.message.interactionMetadata!.userID !== ctx.user.id) + if (ctx.message.interaction!.user.id !== ctx.user.id) return ctx.send({ content: t(['interactions.delete_wrong_user', 'interactions.wrong_user']), ephemeral: true @@ -77,7 +77,7 @@ creator.on('componentInteraction', async (ctx) => { } else if (ctx.customID.startsWith('prompt:')) return await handlePrompt(ctx); else if (ctx.customID.startsWith('action:')) { const { t } = await getData(ctx); - if (ctx.message.interactionMetadata!.userID !== ctx.user.id) + if (ctx.message.interaction!.user.id !== ctx.user.id) return ctx.send({ content: t('interactions.wrong_user'), ephemeral: true diff --git a/src/util/index.ts b/src/util/index.ts index cbcff32..499a8e5 100644 --- a/src/util/index.ts +++ b/src/util/index.ts @@ -85,7 +85,7 @@ export function flattenObject(data: any) { return result; } -export async function iterateFolder(folderPath: string, callback: (filePath: string) => void | Promise, extension = '.js') { +export async function iterateFolder(folderPath: string, callback: (filePath: string) => void | Promise, extensions = ['.js', '.ts']) { const files = await fs.readdir(folderPath); await Promise.all( files.map(async (file) => { @@ -93,13 +93,13 @@ export async function iterateFolder(folderPath: string, callback: (filePath: str const stat = await fs.lstat(filePath); if (stat.isSymbolicLink()) { const realPath = await fs.readlink(filePath); - if (stat.isFile() && file.endsWith(extension)) { + if (stat.isFile() && extensions.find(e => realPath.endsWith(e))) { await callback(realPath); } else if (stat.isDirectory()) { - await iterateFolder(realPath, callback, extension); + await iterateFolder(realPath, callback, extensions); } - } else if (stat.isFile() && file.endsWith(extension)) await callback(filePath); - else if (stat.isDirectory()) await iterateFolder(filePath, callback, extension); + } else if (stat.isFile() && extensions.find(e => file.endsWith(e))) await callback(filePath); + else if (stat.isDirectory()) await iterateFolder(filePath, callback, extensions); }) ); } diff --git a/src/util/prompt.ts b/src/util/prompt.ts index 74ec80c..c0c65d6 100644 --- a/src/util/prompt.ts +++ b/src/util/prompt.ts @@ -135,7 +135,7 @@ export type Prompt = ListPrompt | QueryPrompt | SelectPrompt | AttachmentPrompt export async function handlePrompt(ctx: ComponentContext) { const { t, locale } = await getData(ctx); - if (ctx.message.interactionMetadata!.userID !== ctx.user.id) + if (ctx.message.interaction!.user.id !== ctx.user.id) return ctx.send({ content: t(['interactions.prompt_wrong_user', 'interactions.wrong_user']), ephemeral: true