简体   繁体   English

Discord.js 消息错误

[英]Discord.js messaging errors

I've been recently working on my second Discord.JS bot.我最近一直在研究我的第二个 Discord.JS 机器人。 I coded some basics and tested it.我编写了一些基础知识并对其进行了测试。 However, when I use the .verify command, it didn't make any reactions.但是,当我使用.verify命令时,它没有任何反应。 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.您应该添加 GUILD_MESSAGES 意图。
  2. In discord.js v13 they changed client.on('message') to client.on('messageCreate').在 discord.js v13 中,他们将 client.on('message') 更改为 client.on('messageCreate')。

https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-message 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)也许在message.channel.send('SUCCESFULLY VERIFIED')之后放置.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实际上我们无能为力因为你没有发送错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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