can't read the mentions of a webhook
I have a minor issue. So to give vote rewards, I have a webhook from top.gg that logs everytime a user votes. I usually get the userID of the user through the webhook but I just noticed if someone who is not a member of my support server votes the bot, somehow the mention of the user in the webhook disappears although in the message it is there.
I'm getting the user with this :-
User = message.mentions.users.first()
14 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by staffDiscord sends there only those who is actually pinged
You can parse mentions with a regex to get the id
MessageMentions.GlobalUsersPattern
I'm getting the message through a messageCreate event, do I need to get a parameter from the callback called 'MessageMentions'?
No, MessageMentions is a class and GlobalUsersPattern is its static property
You import it from discord.js
Can you like give me an example code? Assuming that message is the Message I get from the messageCreate event
I get that this will give me a regex, but what do I use it on? The webhook's content and description is coming empty when I log it
What do you mean empty?
Like quite literally it's empty
message.embeds Is an empty array and message.content doesn't log anything
Are you getting it through the webhook or messageCreate event? If later you need MessageContent intent
This is the webhook for reference. And I'm getting message that contains the webhook through the messageCreate event
I'm sorry if that's the wrong approach 💀
Can you tell me how I can do it in the correct way?
If that's the bot mentioned it should be able to get the content
But I think topgg give some kind of API for votes
It doesn't unfortunately
What do you need that for? I see there's a way to get last 1k votes or whether a user is voted or not
https://docs.top.gg/docs/API/bot#last-1000-votes
Bots | Top.gg Documentation
API resource for a bots or apps on a platform like Discord
Actually wait shit, is it because I don't have the message content intent enabled
I basically wanted an automated system that doesn't need any action from the users, basically they vote and automatically get the rewards by triggering the webhook
Ah dang this was the case all along!