Reaction Roles

How can I make Reactions that give you roles when you click it is there a simple way to do this most I've seen are long and complex
16 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Syjalo
Syjalo2y ago
Listen to messageReactionAdd and messageReactionRemove. Add and remove roles there.
Fractyl
FractylOP2y ago
Do you have an example
d.js docs
d.js docs2y ago
guide Popular Topics: Listening for reactions on old messages read more
Fractyl
FractylOP2y ago
That looks rather complex
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Fractyl
FractylOP2y ago
How would you respond after listening
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Fractyl
FractylOP2y ago
Oof im a bit stupid so you may need to clarify further
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Fractyl
FractylOP2y ago
do i need to make a whole new client in my slashcommand file ;/
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Fractyl
FractylOP2y ago
So i could just do interaction.reaction.member => add role for example god im confused
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs2y ago
event (event) Client#messageReactionAdd Emitted whenever a reaction is added to a cached event (event) Client#messageReactionRemove Emitted whenever a reaction is removed from a cached message.
Dave Blunts
Dave Blunts2y ago
const { Client, Events, GatewayIntentBits, Partials } = require('discord.js');

const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMessageReactions],
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
});

client.on(Events.MessageReactionAdd, async (reaction, user) => {
if (reaction.partial) {
try {
await reaction.fetch();
} catch (error) {
console.error('Something went wrong when fetching the message:', error);
return;
}
}
console.log(`${reaction.message.author}'s message "${reaction.message.content}" gained a reaction!`);
console.log(`${reaction.count} user(s) have given the same reaction to this message!`);
});
const { Client, Events, GatewayIntentBits, Partials } = require('discord.js');

const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMessageReactions],
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
});

client.on(Events.MessageReactionAdd, async (reaction, user) => {
if (reaction.partial) {
try {
await reaction.fetch();
} catch (error) {
console.error('Something went wrong when fetching the message:', error);
return;
}
}
console.log(`${reaction.message.author}'s message "${reaction.message.content}" gained a reaction!`);
console.log(`${reaction.count} user(s) have given the same reaction to this message!`);
});
very complex i know
Want results from more Discord servers?
Add your server