#Discord.js bot not pinging roles

28 messages · Page 1 of 1 (latest)

hollow gladeBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • 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!
shut heath
#

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

barren widgetBOT
shut heath
#

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

round hawk
twin whale
#

they just mention the role but it won't be a ping

#

if you want to ping, add it on the content

round hawk
#

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

twin whale
#

oh yeah now that I see it they're sending it directly apart from the embed

#

what does your allowedMentions look like?

round hawk
#
// 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

shut heath
#

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
        },
      });```
round hawk
#

can you be more specific when you say it’s not working

#

like it sends the message but doesn’t ping?

shut heath
#

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

round hawk
#

does the bot have perms to ping that role

shut heath
#

it has the highest role in the server with all perms activated

round hawk
#

iirc there was a thing with mentions not working if they’re in response to an interaction

#

Not too sure

shut heath
#

thats what im thinking, because with the .reply() function it doesnt work

#

using the interaction.channel.send() function works but the error kinda annoys me, so if it is fixable cool, if not i suppose im gonna keep my bot like this