Skip to content

Commit

Permalink
fix: change regex to make more accurate
Browse files Browse the repository at this point in the history
  • Loading branch information
nethriis committed Jun 2, 2024
1 parent 8d4af38 commit 7f8b762
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,11 @@ const resolveMessage = async (
resolvable: string
) => {
const match = resolvable.match(
/https:\/\/(ptb\.|canary\.)?discord\.com\/channels\/(\d+)\/(\d+)\/(\d+)/
/^(?:https:\/\/)?(?:ptb\.|canary\.)?discord(?:app)?\.com\/channels\/(?:\d{17,20}|@me)\/(?<channelId>\d{17,20})\/(?<messageId>\d{17,20})$/
)

if (match) {
const [, , , channelId, messageId] = match
if (match && match.groups) {
const { channelId, messageId } = match.groups
const channel = interaction.guild?.channels.cache.get(channelId) as
| TextBasedChannel
| undefined
Expand Down Expand Up @@ -335,7 +335,7 @@ const resolveEmoji = async (
return emoji
}

return resolvable.match(/[\d]+/)
return resolvable.match(/^\d{17,20}$/)
? interaction.client.emojis.cache.get(resolvable) ?? null
: null
}
Expand Down

0 comments on commit 7f8b762

Please sign in to comment.