Embeds being sent twice

async execute(interaction)
{
const type = interaction.options.getString('type');
const channel = interaction.options.getChannel('channel');

if(type === 'embed_rules')
{
channel.send(
{
embeds: [EMBEDS.RULES]
});

await interaction.reply(
{
embeds: [EMBEDS.SUCCESS],
ephemeral: true
});
}
}
async execute(interaction)
{
const type = interaction.options.getString('type');
const channel = interaction.options.getChannel('channel');

if(type === 'embed_rules')
{
channel.send(
{
embeds: [EMBEDS.RULES]
});

await interaction.reply(
{
embeds: [EMBEDS.SUCCESS],
ephemeral: true
});
}
}
40 Replies
d.js toolkit
d.js toolkit12mo 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.
chewie 🌈
chewie 🌈12mo ago
you are sending it twice right there not sure what answer you expect now to be honest
SuperPEKKA336
SuperPEKKA33612mo ago
where
SuperPEKKA336
SuperPEKKA33612mo ago
channel.send(rules) those are different
chewie 🌈
chewie 🌈12mo ago
yeah but if you choose the same channel its gonna send it twice in that channel
SuperPEKKA336
SuperPEKKA33612mo ago
yeah
chewie 🌈
chewie 🌈12mo ago
yeah so whats the issue
SuperPEKKA336
SuperPEKKA33612mo ago
sends the ruels embed then the successful sent one
chewie 🌈
chewie 🌈12mo ago
You gonna need to be a bit more specific here preferrably with a screenshot of whats happening
SuperPEKKA336
SuperPEKKA33612mo ago
wait nvm it was sending the rules embed twice w one command it send rules twice and teh success command as well weird srry quick question whats returned here
const role = interaction.guild.roles.cache.get(ROLE_IDS[interaction.customId.toUpperCase()]);
const role = interaction.guild.roles.cache.get(ROLE_IDS[interaction.customId.toUpperCase()]);
bc its treated as a boolean
if(!role)
return interaction.reply(
{
embeds: [EMBEDS.ROLE_ERROR],
ephemeral: true
});
if(!role)
return interaction.reply(
{
embeds: [EMBEDS.ROLE_ERROR],
ephemeral: true
});
Mark
Mark12mo ago
get returns the element with that key or undefined
SuperPEKKA336
SuperPEKKA33612mo ago
ah
Mark
Mark12mo ago
!role is coercing it to a boolean value. if all you want to do is check if it's present, use has instead of get
SuperPEKKA336
SuperPEKKA33612mo ago
well thats weird bc my reaction roels are all broken
Mark
Mark12mo ago
that's expected behavior (how it behaves, not your stuff being broken) what is the customId of the interaction
SuperPEKKA336
SuperPEKKA33612mo ago
"PRONOUNS_HEHIM": "814293352157282325", tahts the role id in the JSON file
Mark
Mark12mo ago
not what i asked
SuperPEKKA336
SuperPEKKA33612mo ago
.setCustomId('pronouns_heHim')
Mark
Mark12mo ago
d.js caches are keyed by the id's pronouns_heHim is not a role id
SuperPEKKA336
SuperPEKKA33612mo ago
wdym correct its getting the button that was clicked
Mark
Mark12mo ago
if you log a collection, you'll see something like
Map (1)...
'1003508368038603' => { ... }
Map (1)...
'1003508368038603' => { ... }
where the 109838603... is the key value
SuperPEKKA336
SuperPEKKA33612mo ago
the custom id of the button
Mark
Mark12mo ago
in d.js' case, it's the element's id
SuperPEKKA336
SuperPEKKA33612mo ago
which is "pronouns_heHim"
Mark
Mark12mo ago
your custom id is not a role id get takes a key
SuperPEKKA336
SuperPEKKA33612mo ago
and converts it to uppercase
Mark
Mark12mo ago
ergo, your get will not work
Jayden
Jayden12mo ago
@superpekka336 Don't know if this has been asked/answered.. are you maybe hosting the bot twice? By accident.
SuperPEKKA336
SuperPEKKA33612mo ago
weird yeah i was running it on replit my old version forgot to turn it off
Jayden
Jayden12mo ago
ooh, so that is fixed?
SuperPEKKA336
SuperPEKKA33612mo ago
while testing yeah new problem
Jayden
Jayden12mo ago
Ooh Sorry!
SuperPEKKA336
SuperPEKKA33612mo ago
whack a mole allg ty so how would i fix it?
Mark
Mark12mo ago
log your values, check the roles.cache collection and inspect it manually to see if the id is present there
SuperPEKKA336
SuperPEKKA33612mo ago
k console.log(role); right? undefined i think i figured out whats wrong
SuperPEKKA336
SuperPEKKA33612mo ago
SuperPEKKA336
SuperPEKKA33612mo ago
PRONOUNS, DEPARTMENT, and OTHER
SuperPEKKA336
SuperPEKKA33612mo ago
ok that killed the bot
SuperPEKKA336
SuperPEKKA33612mo ago
nvm it fixed itself ¯\_(ツ)_/¯
Want results from more Discord servers?
Add your server
More Posts