Skip to content

Commit 7f8b762

Browse files
committed
fix: change regex to make more accurate
1 parent 8d4af38 commit 7f8b762

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,11 @@ const resolveMessage = async (
289289
resolvable: string
290290
) => {
291291
const match = resolvable.match(
292-
/https:\/\/(ptb\.|canary\.)?discord\.com\/channels\/(\d+)\/(\d+)\/(\d+)/
292+
/^(?:https:\/\/)?(?:ptb\.|canary\.)?discord(?:app)?\.com\/channels\/(?:\d{17,20}|@me)\/(?<channelId>\d{17,20})\/(?<messageId>\d{17,20})$/
293293
)
294294

295-
if (match) {
296-
const [, , , channelId, messageId] = match
295+
if (match && match.groups) {
296+
const { channelId, messageId } = match.groups
297297
const channel = interaction.guild?.channels.cache.get(channelId) as
298298
| TextBasedChannel
299299
| undefined
@@ -335,7 +335,7 @@ const resolveEmoji = async (
335335
return emoji
336336
}
337337

338-
return resolvable.match(/[\d]+/)
338+
return resolvable.match(/^\d{17,20}$/)
339339
? interaction.client.emojis.cache.get(resolvable) ?? null
340340
: null
341341
}

0 commit comments

Comments
 (0)