Skip to content

Commit 6c86208

Browse files
committed
fix: fix prompts
1 parent ac02580 commit 6c86208

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ creator.on('componentInteraction', async (ctx) => {
6666
if (ctx.customID === 'none') return ctx.acknowledge();
6767
else if (ctx.customID === 'delete') {
6868
const { t } = await getData(ctx);
69-
if (ctx.message.interactionMetadata!.userID !== ctx.user.id)
69+
if (ctx.message.interaction!.user.id !== ctx.user.id)
7070
return ctx.send({
7171
content: t(['interactions.delete_wrong_user', 'interactions.wrong_user']),
7272
ephemeral: true
@@ -77,7 +77,7 @@ creator.on('componentInteraction', async (ctx) => {
7777
} else if (ctx.customID.startsWith('prompt:')) return await handlePrompt(ctx);
7878
else if (ctx.customID.startsWith('action:')) {
7979
const { t } = await getData(ctx);
80-
if (ctx.message.interactionMetadata!.userID !== ctx.user.id)
80+
if (ctx.message.interaction!.user.id !== ctx.user.id)
8181
return ctx.send({
8282
content: t('interactions.wrong_user'),
8383
ephemeral: true

src/util/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,21 @@ export function flattenObject(data: any) {
8585
return result;
8686
}
8787

88-
export async function iterateFolder(folderPath: string, callback: (filePath: string) => void | Promise<void>, extension = '.js') {
88+
export async function iterateFolder(folderPath: string, callback: (filePath: string) => void | Promise<void>, extensions = ['.js', '.ts']) {
8989
const files = await fs.readdir(folderPath);
9090
await Promise.all(
9191
files.map(async (file) => {
9292
const filePath = path.join(folderPath, file);
9393
const stat = await fs.lstat(filePath);
9494
if (stat.isSymbolicLink()) {
9595
const realPath = await fs.readlink(filePath);
96-
if (stat.isFile() && file.endsWith(extension)) {
96+
if (stat.isFile() && extensions.find(e => realPath.endsWith(e))) {
9797
await callback(realPath);
9898
} else if (stat.isDirectory()) {
99-
await iterateFolder(realPath, callback, extension);
99+
await iterateFolder(realPath, callback, extensions);
100100
}
101-
} else if (stat.isFile() && file.endsWith(extension)) await callback(filePath);
102-
else if (stat.isDirectory()) await iterateFolder(filePath, callback, extension);
101+
} else if (stat.isFile() && extensions.find(e => file.endsWith(e))) await callback(filePath);
102+
else if (stat.isDirectory()) await iterateFolder(filePath, callback, extensions);
103103
})
104104
);
105105
}

src/util/prompt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export type Prompt = ListPrompt | QueryPrompt | SelectPrompt | AttachmentPrompt
135135
export async function handlePrompt(ctx: ComponentContext) {
136136
const { t, locale } = await getData(ctx);
137137

138-
if (ctx.message.interactionMetadata!.userID !== ctx.user.id)
138+
if (ctx.message.interaction!.user.id !== ctx.user.id)
139139
return ctx.send({
140140
content: t(['interactions.prompt_wrong_user', 'interactions.wrong_user']),
141141
ephemeral: true

0 commit comments

Comments
 (0)