#Do prefix command bots no longer work?

28 messages · Page 1 of 1 (latest)

alpine sigil
#

We have a bot that is running on two servers (dev and production) and they not longer work on the servers but still work via DM.
I have read through the docs which indicated it needed to be removed and re-added it but it still does not work.

The bot parses commands with multiple parameters and will not be simple to convert to slash commands.

Are prefix command no longer supported or is this just a permissions issue?

latent badgeBOT
#

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

native wing
#

#discord-dev-news message

alpine sigil
latent badgeBOT
#

If you aren't getting content, embeds or attachments of a message, make sure you have the MessageContent intent enabled in the Developer Portal and provide it to your client:

const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
    intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});
deep frost
#

This?

hollow portal
#

Post the related error response

#

it probably is message content intent and the toggle for the privileged intent in your discord dev dashboard

#

if i did not misread, you still have to subscribe to the gateway intent and toggle it on regardless of verified status

alpine sigil
#

Thank all. It looks like it could be the intents. I'll try that.
This bot uses v12 so I assume that needs to be updated too.
Discord bots are not my prime focus so it was a bit confusing following what needs to be done.

hollow portal
#

you should brush up on things soon, since i think v12 support is not going to last much longer when discord starts deprecating and closing api versions

#

i'm not up to date on how urgent that concern is

versed oriole
#

v12 itself is long deprecated

#

so is API v6/v7 it uses

#

if not a change in the api ver decomission date, it would already not work

#

but, the date still exists and you should update regardless

alpine sigil
#

Bot is updated to v14. Changed the client to the snippet above (v13 threw error)

Had to change
bot.on('message', (msg) => { to bot.on('messageCreate', (msg) => {
Also had to update a check of guild.member(id) to use guild.members.cache.has(id)

The bot is able to receive a message from the discord server and reply, but not from a DM. Most of the interaction with a user takes place via DM to keep the channel clear.

Can a v14 bot be DM'd?

versed oriole
#

obviously, the API doesn't really care what library you're using when you get a DM

#

you just need to have respective intents, and a CHANNEL partial

alpine sigil
#

The DM is not even arriving at the bot even with Partials. The docs on partials is scarce and the examples are about reactions, not receive a new DM.

What do you mean by " need to have respective intents"?

versed oriole
#

you will not receive specific events if you don't enable specific intents

#

without GuildMessages you don't receive message events

#

there's another intent specifically for dms

alpine sigil
#

I was able to get the DM working using the following. Posting here in case anyone needs it.

const { Client, GatewayIntentBits, Partials } = require('discord.js');
const bot = new Client({
  intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.DirectMessages],
   partials: [Partials.Message, Partials.Channel, Partials.Reaction] 
});

Now for every reply another new request is sent because it creates a new message, duplicating the messages. I had to add a check for the message type in the bot to not reply to the reply.

bot.on('messageCreate', (msg) => {
  console.log('msg', msg);
  if (msg.type === 19 ) return null;
  checkMessageForCommand(msg);
}
);```

Thanks for all the help!
#

I really wish there was a guide for updating old bots without migrating to slash commands (to migrate at later time).

versed oriole
#

there kinda are