I want to get a Users ID from a mention. I am making a user info command so the author of the message will not always be them so I cannot do message.author.id
. I have used substrings to split the command into the command itself and the mention but I cannot turn the mention into an ID.
I am aware that discords mentions are actually <@USERID>
, which is another way I could get the ID. Please tell me if I am able to get rid of the <@>
so I am left with the ID, or turn the mention itself into an one using another method. I have looked through the docs and I am not aware of anything that could help me.
You can do that in two ways: if you want to use the mention as an argument, you can remove the mention characters with regex, like this: yourstring.replace(/[\\<>@#&!]/g, "");
.
The other way to do that is to get the first mention in the message and then the user's id: message.mentions.users.first().id
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With