Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discord mention parsing is greedy #21

Closed
DanielRX opened this issue May 28, 2021 · 3 comments
Closed

Discord mention parsing is greedy #21

DanielRX opened this issue May 28, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@DanielRX
Copy link

Context:
Within a discord server that has a member with username 13#XXXX

If I do $remind discordUser in 30s Hello and their discord id is: 13XXXXXXXXXXXXXXXX, when the command resolves, it will ping the 13#XXXX user, not the user I targeted with $remind (the discordUser)

@Supinic
Copy link
Owner

Supinic commented May 30, 2021

If I understand this correctly, this is the sequence of steps you're describing:

  1. user A discord ID is e.g. 13xxx
  2. user B's discord name is 13#tag
  3. $remind (user A) hello
  4. When the reminder is received, the mention in that reminder does not target user A, but rather user B - seemingly because of the mimatch between the name and the ID

If this is correct, I would appreciate if both those users would join my Discord server, so I can simulate this behaviour

@Supinic
Copy link
Owner

Supinic commented Jun 1, 2021

After a brief demonstration by @DanielRX on Discord, I figured out what is wrong:

const regex = new RegExp(`@${sb.Utils.escapeRegExp(name)}`, "gi");

Fired reminders will attempt to ping a user by establishing a mention in the <@(user-id)> format inside of their message string. When attempting to send the message however, the abovementioned regex replaces the internals of the mention - by not checking for a preceding < character.

@Supinic Supinic self-assigned this Jun 1, 2021
@Supinic Supinic added the bug Something isn't working label Jun 1, 2021
@Supinic
Copy link
Owner

Supinic commented Jun 8, 2021

Fixed in c678672 - forgot to link commit with this issue

@Supinic Supinic closed this as completed Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants