1

I am trying to set my first discord bot. I got the bot running from VSC and online with Heroku which is also auto-updating with my Github.

I need support because it seems my bot is not responding to any of my messages.

Here is my index file code, which I named "bot.js"

require("dotenv").config();

const Discord = require("discord.js");
client = new Discord.Client({ intents: 32767 });

client.on("ready", () => {
  console.log("Our bot is ready to go");
});

client.on("message", async (message) => {
  if (message.content === "ping") {
    message.reply("pong");
  }
});

client.login(process.env.BOT_TOKEN);

The bot is online and on the server I want it to, with admin permissions as well. I am sure the intents are right, so there should be no issue.

Thank you!

Zordas X
  • 17
  • 4
  • Please check this post and make sure you have the privileged intent enabled on discord.dev, also unless you need all intent (which 32767 is no longer all intents, 131071 is) you should really specify what intents you need. https://stackoverflow.com/questions/73036854/message-content-doesnt-have-any-value-in-discord-js-v14 – Kaspr Sep 08 '22 at 19:47

1 Answers1

0

The error seems to be the way you declare your intents. The intents you put in your code was the way to declare all intents in V13, however in V14 the way to declare all intents is 131071. However for just sending messages I would recommend you only use the intents required, therefore your code could look something like:

// Alternativly you could do "intents: 131071" for all intents
const client = new Discord.Client({ intents: ["GuildMessages", "MessageContent"] });

client.on("ready", () => {
  console.log("Our bot is ready to go");
});
abisammy
  • 554
  • 4
  • 12
  • So, I changed the code as recommended, first using 131071 and then using the second recommendation declaring my intent. My messages are still not sending, and I do have the intent allowed on the discord dev portal. Any other ideas? – Zordas X Sep 08 '22 at 20:52
  • Try chaniging "message" in `client.on` to "messageCreate" – abisammy Sep 08 '22 at 20:55
  • I changed the "message" to messageCreate. But it is still giving me no input. The NPM runs fine. It is really weird. – Zordas X Sep 08 '22 at 22:03
  • Here is what I would do to debug it: change intents like in code above, change to message create, add a console log before the if statement to make sure the code is running, tripple make sure you have message content intents on in the dasboard (the last one) – abisammy Sep 08 '22 at 22:13
  • Its working now, it seems I had to 100% add the "Guilds" as part of my intent. It all seems smooth! Thank you so much! – Zordas X Sep 08 '22 at 22:37