简体   繁体   中英

Discord.js messaging errors

I've been recently working on my second Discord.JS bot. I coded some basics and tested it. However, when I use the .verify command, it didn't make any reactions. Please help!

const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
const { token } = require('./config.json');
const prefix = "."

client.on("ready", () => { console.log(`Logged in as ${client.user.tag}!`) })

client.on('message', message => {
    if (message.content.startsWith(`${prefix}verify`)) {
        message.channel.send('SUCCESFULLY VERIFIED');
    }
})

client.login(token);
  1. You should add the GUILD_MESSAGES intent.
  2. In discord.js v13 they changed client.on('message') to client.on('messageCreate').

https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-message

I hope this answers your question

maybe after message.channel.send('SUCCESFULLY VERIFIED') put .catch(console.error)

const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
const { token } = require('./config.json');
const prefix = "."

client.on("ready", () => { console.log(`Logged in as ${client.user.tag}!`) })

client.on('message', message => {
    if (message.content.startsWith(`${prefix}verify`)) {
        message.channel.send('SUCCESFULLY VERIFIED').catch(console.error)
    }
})

client.login(token);

actually we can't do anythink because you don't send the error

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM