Here is the code for my reaction role:
module.exports = {
name: "rr",
desc: "create a reaction role --> <",
async run(message, client) {
const jsEmoji = "🍏";
const pythonEmoji = "🍍";
let embedMessage = await message.channel.send("React to get a role");
embedMessage.react(jsEmoji);
embedMessage.react(pythonEmoji);
client.on("messageReactionAdd", (user, reaction) => {
console.log("User reacted to message");
});
},
};
And here is the setup in my bot file:
const intents = new Discord.Intents(32767);
I created my client instance below:
const client = new Discord.Client({ intents: intents });
const fs = require("fs");
const commandFolders = fs.readdirSync("./Commands");
client.commands = new Discord.Collection();
commandFolders.forEach((folder) => {
const commandFiles = fs
.readdirSync(`./Commands/${folder}`)
.filter((file) => file.endsWith(".js"));
commandFiles.forEach((file) => {
const command = require(`./Commands/${folder}/${file}`);
client.commands.set(command.name, command);
});
});
client.on("messageCreate", (message) => {
if (message.author.bot || !message.content.startsWith(config.prefix)) return;
const [command, ...args] = message.content
.substring(config.prefix.length)
.split(/\s+/);
I attempted to access the client and pass it into the run function but encountered an issue.
client.commands.forEach((cmd) =>
command === cmd.name
? client.commands.get(cmd.name).run(message, args, client)
: null
);
});
client.login(config.token);
However, I encountered an error:
client.on("messageReactionAdd", (user, reaction) => {
^
TypeError: client.on is not a function
Does anyone have suggestions on another method to access my client?