Vote Member détection : Command slash
Hello, I hope I'm in the right place!
Code informations
- Djs v14.14.1
- Node js 20
What I need
I would like to make a system to detect when a user makes a slash command and give him 1 point.
A 6h cooldown is set up.
The problem is that I would like to make a detection either of slash command or of the contents of the embed but I don't know if it is possible to simply detect the mention.
9 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!Pastebin
const { Client, GatewayIntentBits, MessageType } = require('discord...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
You definitely can detect the content of the embed using
<Message>.embeds
. You may be able to get some information regarding the command using <Message>.interactionMetadata
but I can't find a commandName property there.Okay, so how can I do it? An example of code with my example that I gave!
You can either use
<Message>.interaction.commandName
and compare that with the name of the command - note that this is deprecated and may be removed.
Or you can compare <Message>.embeds[0].description
with the description present inside the embed.
You seem to be already doing the second one in your code though.I see, But how will the bot know that it is this user who is voting?
You mean which user is voting? You can either parse the mention or use
<Message>.interactionactionMetadata.user
.What I want is that when a person votes it is detected via the slash command or simply detected via the content of the embed in question. I would really like my bot to detect it and say it by specifying the user who voted.
Yes, that's possible using the ways I just mentioned above.
- Listen for messages
- Use either the embeds or interaction property to check whether it's the message you're looking for
- Get the user who voted by using the interactionMetadata property or parse the mention insode of the embed
- Do whatever you want with that user (e. g. send a message mentioning that user).