Why is my number of emoji inaccurate?

im trying to count the number of emoji on my server
async function checkIfServerHasFreeEmojiSlots (guild) {
const premiumTier = guild.premiumTier;
const totalEmojiSlots = EMOJI_SLOTS_PER_TIER[premiumTier];
const usedEmojiSlots = (await guild.emojis.fetch()).size;
const freeEmojiSlots = totalEmojiSlots - usedEmojiSlots;
console.log('server has',freeEmojiSlots,'free emoji slots', {premiumTier, totalEmojiSlots, usedEmojiSlots});

if (freeEmojiSlots > 0) return;
throw new Error('The server currently has no free emoji slots.');
}
async function checkIfServerHasFreeEmojiSlots (guild) {
const premiumTier = guild.premiumTier;
const totalEmojiSlots = EMOJI_SLOTS_PER_TIER[premiumTier];
const usedEmojiSlots = (await guild.emojis.fetch()).size;
const freeEmojiSlots = totalEmojiSlots - usedEmojiSlots;
console.log('server has',freeEmojiSlots,'free emoji slots', {premiumTier, totalEmojiSlots, usedEmojiSlots});

if (freeEmojiSlots > 0) return;
throw new Error('The server currently has no free emoji slots.');
}
its telling me i have 49. but looking at my server settings, the emoji says theres 3 empty slots, so there's 47 emoji. why do these numbers not match. I looked everywhere but it seems this is the only way to get the number of empty emoji slots from the API (and unforuntately it doesn't seem to work)
No description
4 Replies
d.js toolkit
d.js toolkit8mo 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! - Marked as resolved by OP
skeddles
skeddlesOP8mo ago
[email protected] node v16.17.0 server has 1 free emoji slots { premiumTier: 0, totalEmojiSlots: 50, usedEmojiSlots: 49 } yeah it's triggering from a command, using await checkIfServerHasFreeEmojiSlots(interaction.guild); oh that might be it, lemme see
skeddles
skeddlesOP8mo ago
yup you got it. I'll have to filter those out
No description
skeddles
skeddlesOP8mo ago
thanks!

Did you find this page helpful?