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 toolkit2y 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
chewie2y ago
you are sending it twice right there not sure what answer you expect now to be honest
SuperPEKKA336
SuperPEKKA336OP2y ago
where
SuperPEKKA336
SuperPEKKA336OP2y ago
channel.send(rules) those are different
chewie
chewie2y ago
yeah but if you choose the same channel its gonna send it twice in that channel
SuperPEKKA336
SuperPEKKA336OP2y ago
yeah
chewie
chewie2y ago
yeah so whats the issue
SuperPEKKA336
SuperPEKKA336OP2y ago
sends the ruels embed then the successful sent one
chewie
chewie2y ago
You gonna need to be a bit more specific here preferrably with a screenshot of whats happening
SuperPEKKA336
SuperPEKKA336OP2y 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
Mark2y ago
get returns the element with that key or undefined
SuperPEKKA336
SuperPEKKA336OP2y ago
ah
Mark
Mark2y 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
SuperPEKKA336OP2y ago
well thats weird bc my reaction roels are all broken
Mark
Mark2y ago
that's expected behavior (how it behaves, not your stuff being broken) what is the customId of the interaction
SuperPEKKA336
SuperPEKKA336OP2y ago
"PRONOUNS_HEHIM": "814293352157282325", tahts the role id in the JSON file
Mark
Mark2y ago
not what i asked
SuperPEKKA336
SuperPEKKA336OP2y ago
.setCustomId('pronouns_heHim')
Mark
Mark2y ago
d.js caches are keyed by the id's pronouns_heHim is not a role id
SuperPEKKA336
SuperPEKKA336OP2y ago
wdym correct its getting the button that was clicked
Mark
Mark2y 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
SuperPEKKA336OP2y ago
the custom id of the button
Mark
Mark2y ago
in d.js' case, it's the element's id
SuperPEKKA336
SuperPEKKA336OP2y ago
which is "pronouns_heHim"
Mark
Mark2y ago
your custom id is not a role id get takes a key
SuperPEKKA336
SuperPEKKA336OP2y ago
and converts it to uppercase
Mark
Mark2y ago
ergo, your get will not work
Jayden
Jayden2y ago
@superpekka336 Don't know if this has been asked/answered.. are you maybe hosting the bot twice? By accident.
SuperPEKKA336
SuperPEKKA336OP2y ago
weird yeah i was running it on replit my old version forgot to turn it off
Jayden
Jayden2y ago
ooh, so that is fixed?
SuperPEKKA336
SuperPEKKA336OP2y ago
while testing yeah new problem
Jayden
Jayden2y ago
Ooh Sorry!
SuperPEKKA336
SuperPEKKA336OP2y ago
whack a mole allg ty so how would i fix it?
Mark
Mark2y ago
log your values, check the roles.cache collection and inspect it manually to see if the id is present there
SuperPEKKA336
SuperPEKKA336OP2y ago
k console.log(role); right? undefined i think i figured out whats wrong
SuperPEKKA336
SuperPEKKA336OP2y ago
SuperPEKKA336
SuperPEKKA336OP2y ago
PRONOUNS, DEPARTMENT, and OTHER
SuperPEKKA336
SuperPEKKA336OP2y ago
ok that killed the bot
SuperPEKKA336
SuperPEKKA336OP2y ago
nvm it fixed itself ¯\_(ツ)_/¯
Want results from more Discord servers?
Add your server