Skip to content

Commit

Permalink
fix: fix prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
Snazzah committed Sep 6, 2024
1 parent ac02580 commit 6c86208
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,21 @@ export function flattenObject(data: any) {
return result;
}

export async function iterateFolder(folderPath: string, callback: (filePath: string) => void | Promise<void>, extension = '.js') {
export async function iterateFolder(folderPath: string, callback: (filePath: string) => void | Promise<void>, extensions = ['.js', '.ts']) {
const files = await fs.readdir(folderPath);
await Promise.all(
files.map(async (file) => {
const filePath = path.join(folderPath, file);
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);
})
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6c86208

Please sign in to comment.