- What's your exact discord.js
npm list discord.jsand nodenode -vversion? - Not a discord.js issue? Check out #1081585952654360687.
- 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!
#Discord.js bot not pinging roles
28 messages · Page 1 of 1 (latest)
module.exports = {
name: "csgo",
description: "ci siete per csgo?",
callback: async (client, interaction) => {
try {
// ID del ruolo menzionato nel campo "INVITATI"
const roleId = "1045027767982506059";
// Ottenere il ruolo dal suo ID
const role = interaction.guild.roles.cache.get(roleId);
if (!role) {
console.error("Ruolo non trovato.");
return interaction.reply("Errore durante la ricerca del ruolo.");
}
// Costruire il messaggio contenente solo il ruolo menzionato
const roleMessage = `Ruolo menzionato: <@&${roleId}>`;
// Invia il messaggio contenente solo il ruolo menzionato
await interaction.channel.send(roleMessage);
const embed = new EmbedBuilder()
.setImage(
"//no link for privacy"
)
.setThumbnail(
"//no link for privacy"
)
.setColor("FF0000")
.setTitle("**AVVISO CSGO**")
.addFields(
{
name: "**ORARIO**",
value: "organizzatevi (di norma dopo che tutti hanno mangiato)",
},
{
name: "**INVITATI**",
value: "tutti quelli col ruolo <@&1045027767982506059>",
}
)
.setFooter({
text: "made by freedmaaan",
iconURL: "//no link for privacy",
});
// Invia l'embed
await interaction.channel.send({ embeds: [embed] }).then(message => {
// Aggiungi le reazioni all'embed
message.react("✔");
message.react("❌");
});
} catch (error) {
console.error("Si è verificato un errore:", error);
interaction.reply(
"Si è verificato un errore durante l'esecuzione del comando."
);
}
},
};
p.s. english is not my first language, hope you can understand
p.p.s. i used chatgpt for some help, so if something looks strange thats the reason
You can control which entities receive notifications via the allowedMentions option. You can:
- Set a default on the client
- Set for a specific message
- Use the
repliedUserkey to disable in-line reply mentions
{ ..., allowedMentions: { parse: ["users", "roles"] } }
tried but still not working
as i said, i think the problem is the function interaction.channel.send that is the only one i can use to ping a role but im not 100% sure
Show what you tried
embeds don't ping
they just mention the role but it won't be a ping
if you want to ping, add it on the content
oh yeah if any sort of mentioning is inside an embed it will not ping
users, roles etc
it doesn’t seem like that’s the case here though
oh yeah now that I see it they're sending it directly apart from the embed
what does your allowedMentions look like?
// Costruire il messaggio contenente solo il ruolo menzionato
const roleMessage = `Ruolo menzionato: <@&${roleId}>`;
// Invia il messaggio contenente solo il ruolo menzionato
await interaction.channel.send(roleMessage);```
also, don’t rely on chatgpt for code. its helpful for if you’re stuck and need inspiration for what to add next in your bot but doesn’t always give the most correct or code that actually works
take the time to actually learn js/djs and important concepts
i know that pinging in a embed wont actually ping (with the yellow higlight), thats why i've added a message that is sent before the embed so it can ping the role and then add the embed
thats what i've added with the help of chatGPT but it doesnt work
allowedMentions: {
repliedUser: true, // L'utente menzionato nella risposta verrà notificato
parse: ["roles"], // Consentito pingare solo i ruoli
},
});```
can you be more specific when you say it’s not working
like it sends the message but doesn’t ping?
so when i use interaction.reply() (with or without the allowMentions code) it does this. i need that purple role to be a real ping (with the yellow highlight).
To do that i can use the interaction.channel.send() function and, even if it works correctly it gives me an error and its kinda annoying
does the bot have perms to ping that role
it has the highest role in the server with all perms activated