messagereactionsadd with old messages

i need to remove new reactions but this work just with messages that i send after running the bot
4 Replies
d.js toolkit
d.js toolkit14mo ago
- 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!
HARRY
HARRYOP14mo ago
require('dotenv').config();

const { Client, IntentsBitField, Partials} = require('discord.js');
const colors = require('../modules/colors');

const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
IntentsBitField.Flags.GuildMessageReactions,
],
partials: [Partials.MESSAGE, Partials.CHANNEL, Partials.REACTION],
messageCacheMaxSize: 100,
});

client.on('ready', (c) => {
console.log(`${colors.whiteBackground} ${c.user.tag} is ready haha${colors.resetBackground}`);
})

client.on("messageReactionAdd", async (reaction, user) => {
// Ensure "test" is logged for every reaction
console.log('test');

// Fetch the message if it's a partial
if (reaction.partial) {
try {
await reaction.fetch();
} catch (error) {
console.error('Something went wrong when fetching the message: ', error);
return;
}
}

// Your reaction handling logic here
reaction.remove();
});



client.login(process.env.TOKEN);
require('dotenv').config();

const { Client, IntentsBitField, Partials} = require('discord.js');
const colors = require('../modules/colors');

const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
IntentsBitField.Flags.GuildMessageReactions,
],
partials: [Partials.MESSAGE, Partials.CHANNEL, Partials.REACTION],
messageCacheMaxSize: 100,
});

client.on('ready', (c) => {
console.log(`${colors.whiteBackground} ${c.user.tag} is ready haha${colors.resetBackground}`);
})

client.on("messageReactionAdd", async (reaction, user) => {
// Ensure "test" is logged for every reaction
console.log('test');

// Fetch the message if it's a partial
if (reaction.partial) {
try {
await reaction.fetch();
} catch (error) {
console.error('Something went wrong when fetching the message: ', error);
return;
}
}

// Your reaction handling logic here
reaction.remove();
});



client.login(process.env.TOKEN);
simple version of my code
kin.ts
kin.ts14mo ago
d.js v14 uses PascalCase Partials.REACTION -> Partials.Reaction
HARRY
HARRYOP14mo ago
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
but still don't work with old messages
Want results from more Discord servers?
Add your server