#Having issues with intents

8 messages · Page 1 of 1 (latest)

outer pewter
#

How do i layout intents? This clearly doesn't work but idk what does (im new to discord.js)

const scheduleJob = require('node-schedule');

const client = new Discord.Client()

client.intents.add([
  Discord.Intents.GUILDS,
  Discord.Intents.GUILD_MESSAGES
]);

// replace '<DISCORD_BOT_TOKEN>' with your bot's token
client.login('CENSORED');

// an array to store the IDs of the channels to send the message to
const channels = [];

// create a schedule to send the message every hour
const sendMessageJob = scheduleJob('0 * * * *', () => {
  // replace '<MESSAGE>' with the message you want to send
  const message = 'https://soggycateveryhourbot.files.wordpress.com/2022/07/thesoggycat.jpg';

  channels.forEach(channelId => {
    const channel = client.channels.get(channelId);
    if (channel) {
      channel.send(message);
    }
  });
});

client.on('message', message => {
  // only handle commands that start with '!addchannel' or '!removechannel'
  if (message.content.startsWith('!addchannel') || message.content.startsWith('!removechannel')) {
    // use the 'Message#command' method to parse the command and its arguments
    const [command, channelId] = message.command();

    if (command === 'addchannel' && channelId) {
      // add the channel ID to the list of channels to send the message to
      channels.push(channelId);
    } else if (command === 'removechannel' && channelId) {
      // remove the channel ID from the list of channels to send the message to
      const index = channels.indexOf(channelId);
      if (index >= 0) {
        channels.splice(index, 1);
      }
    }
  }
});
south river
#

• 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.

naive summitBOT
#

• Websocket intents limit events and decrease memory usage: learn more
• See what intents you need here

whole canyon
#

That's v12 code

naive summitBOT
#

Version 14 has released! Please update at your earliest convenience.
• Update: npm rm discord.js npm i discord.js
Update guide (use CTRL + F to search for the old method or property)

outer pewter
outer pewter
#

after adapting, i now get a "Error [DisallowedIntents]: Privileged intent provided is not enabled or whitelisted." error. This prevents my bot from running even though it isn't even in a server (so isn't missing perms, unless im missing something?)