Skip to content

Commit 1b3082b

Browse files
committed
Update Utils.ts
- Fix and closed appujet#776
1 parent ad783e2 commit 1b3082b

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/utils/Utils.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
ButtonBuilder,
55
ButtonStyle,
66
CommandInteraction,
7+
Message,
78
type TextChannel,
89
} from 'discord.js';
910
import type { Context, Lavamusic } from '../structures/index';
@@ -58,7 +59,7 @@ export class Utils {
5859
}
5960

6061
public static parseTime(string: string): number {
61-
const time = string.match(/([0-9]+[d,h,m,s])/g);
62+
const time = string.match(/(\d+[dhms])/g);
6263
if (!time) return 0;
6364
let ms = 0;
6465
for (const t of time) {
@@ -125,17 +126,25 @@ export class Utils {
125126
};
126127

127128
const msgOptions = getButton(0);
128-
const msg = ctx.isInteraction
129-
? await (ctx.deferred
130-
? ctx.interaction!.followUp({
131-
...msgOptions,
132-
fetchReply: true as boolean,
133-
})
134-
: ctx.interaction!.reply({ ...msgOptions, fetchReply: true }))
135-
: await (ctx.channel as TextChannel).send({
129+
let msg: Message;
130+
if (ctx.isInteraction) {
131+
if (ctx.deferred) {
132+
msg = await ctx.interaction!.followUp({
136133
...msgOptions,
137134
fetchReply: true,
138135
});
136+
} else {
137+
msg = (await ctx.interaction!.reply({
138+
...msgOptions,
139+
fetchReply: true,
140+
})) as unknown as Message;
141+
}
142+
} else {
143+
msg = await (ctx.channel as TextChannel).send({
144+
...msgOptions,
145+
fetchReply: true,
146+
});
147+
}
139148

140149
const author = ctx instanceof CommandInteraction ? ctx.user : ctx.author;
141150

0 commit comments

Comments
 (0)