my guild related listeners arent firing but my client ones are

pretty much just the title
Solution:
i just remembered that messageReactionAdd won't fire on uncached messages, unless u were to enable partials
Jump to solution
30 Replies
iaqi
iaqiOP2mo ago
im having a lot of random issues for some reason all my packages are up to date like everytime i run my bot it always says in the logs that it needs to updates the commands except typescript though because i know you cant have that up to date
Seren_Modz 21
Seren_Modz 212mo ago
based on what u have included in the title, it sounds like ur missing intents for your guild events
Seren_Modz 21
Seren_Modz 212mo ago
i recommend looking at https://discord.com/developers/docs/events/gateway#list-of-intents to see which intents are required for each event
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
iaqi
iaqiOP2mo ago
well the event that isnt working is the messagereactionadd event i have that intent enabled
Seren_Modz 21
Seren_Modz 212mo ago
could u clarify which intent is enabled?
iaqi
iaqiOP2mo ago
i have these enabled
iaqi
iaqiOP2mo ago
No description
Seren_Modz 21
Seren_Modz 212mo ago
could u also show the messageReactionAdd listener?
iaqi
iaqiOP2mo ago
import { Events, Listener } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";
import { EmbedBuilder, MessageReaction, User } from "discord.js";

@ApplyOptions<Listener.Options>({
event: Events.MessageReactionAdd,
})
export class MessageReactionAddListener extends Listener {
public async run(messageReaction: MessageReaction, user: User) {
this.container.logger.info("hello");
if (!messageReaction.message.guild || user.bot) return;

this.container.logger.info(messageReaction.emoji.name);

if (messageReaction.emoji.name === "⭐️") {
const starboard = await this.container.prisma.starboard.findUnique({
where: {
guildId: messageReaction.message.guild.id,
},
});

if (!starboard || !starboard.enabled || !starboard.channelId) return;

const starboardChannel = await messageReaction.message.guild.channels.fetch(starboard.channelId);

if (!starboardChannel) return;
this.container.logger.info("hello");

if (messageReaction.count >= starboard.starsRequired && !starboard.starredMessages.includes((messageReaction.message.id))) {
if (!starboardChannel.isSendable()) return;

this.container.logger.info("hello");

await starboardChannel.send({
embeds: [
new EmbedBuilder().setTitle("⭐️").setDescription(messageReaction.message.content).setColor("Gold").setFooter({ text: `⭐️ ${messageReaction.count}`})
]
});

await this.container.prisma.starboard.update({
where: {
guildId: messageReaction.message.guild.id,
},
data: {
starredMessages: {
push: messageReaction.message.id,
},
},
});
}
}
}
}
import { Events, Listener } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";
import { EmbedBuilder, MessageReaction, User } from "discord.js";

@ApplyOptions<Listener.Options>({
event: Events.MessageReactionAdd,
})
export class MessageReactionAddListener extends Listener {
public async run(messageReaction: MessageReaction, user: User) {
this.container.logger.info("hello");
if (!messageReaction.message.guild || user.bot) return;

this.container.logger.info(messageReaction.emoji.name);

if (messageReaction.emoji.name === "⭐️") {
const starboard = await this.container.prisma.starboard.findUnique({
where: {
guildId: messageReaction.message.guild.id,
},
});

if (!starboard || !starboard.enabled || !starboard.channelId) return;

const starboardChannel = await messageReaction.message.guild.channels.fetch(starboard.channelId);

if (!starboardChannel) return;
this.container.logger.info("hello");

if (messageReaction.count >= starboard.starsRequired && !starboard.starredMessages.includes((messageReaction.message.id))) {
if (!starboardChannel.isSendable()) return;

this.container.logger.info("hello");

await starboardChannel.send({
embeds: [
new EmbedBuilder().setTitle("⭐️").setDescription(messageReaction.message.content).setColor("Gold").setFooter({ text: `⭐️ ${messageReaction.count}`})
]
});

await this.container.prisma.starboard.update({
where: {
guildId: messageReaction.message.guild.id,
},
data: {
starredMessages: {
push: messageReaction.message.id,
},
},
});
}
}
}
}
Seren_Modz 21
Seren_Modz 212mo ago
your other listeners are working so that would suggest that your package.json main is correct if u would like to see more logs and get a better idea what is going on, u could change your logger level from debug to trace
iaqi
iaqiOP2mo ago
okay ill see
iaqi
iaqiOP2mo ago
No description
iaqi
iaqiOP2mo ago
idk why it keeps saying its updating the command data when i havent changed anything and that its found differences
Seren_Modz 21
Seren_Modz 212mo ago
that will be differences with what has been deployed to the discord api
iaqi
iaqiOP2mo ago
but i have not changed anything in the commands
Seren_Modz 21
Seren_Modz 212mo ago
focusing back on the problem with your messageReactionAdd listener, have u managed to update your logger to log traces and see what is happening with listeners?
iaqi
iaqiOP2mo ago
well its getting loaded and inserted
Seren_Modz 21
Seren_Modz 212mo ago
and nothing at all is happening when u add a reaction in a server that the bot is in? not even the logs show?
iaqi
iaqiOP2mo ago
nothing happens
Seren_Modz 21
Seren_Modz 212mo ago
may i ask what your package.json main is set to?
iaqi
iaqiOP2mo ago
./dist/index.js
iaqi
iaqiOP2mo ago
No description
iaqi
iaqiOP2mo ago
this is what it looks like
Seren_Modz 21
Seren_Modz 212mo ago
could u try deleting the dist folder and trying with a fresh build?
iaqi
iaqiOP2mo ago
yeah same issue still applies
iaqi
iaqiOP2mo ago
also for some reason it says it took 41 seconds to intialise
No description
Solution
Seren_Modz 21
Seren_Modz 212mo ago
i just remembered that messageReactionAdd won't fire on uncached messages, unless u were to enable partials
Seren_Modz 21
Seren_Modz 212mo ago
have u tried sending a new message after the bot has started and reacting to that?
iaqi
iaqiOP2mo ago
let me see using partials fixed it but im still concerned about the other issue
Favna
Favna2mo ago
Seeing as this is a starboard you can pretty much just look at the code of @Gemboard https://github.com/sapphiredev/gemboard
GitHub
GitHub - sapphiredev/gemboard: A private starboard bot for the Sapp...
A private starboard bot for the Sapphire server. Contribute to sapphiredev/gemboard development by creating an account on GitHub.

Did you find this page helpful?