【发布时间】:2021-02-14 16:54:52
【问题描述】:
我想将错误消息从 dm 发送给用户。但我收到ReferenceError: error is not defined 错误。我该如何解决这个问题?
if (error) {
client.users.cache.get(message.author.id).send(error)
}
这是我的 index.js
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(`\x1b[33m${client.user.tag} \x1b[0mgiriş yaptı!`);
client.user.setActivity(`Online on ${client.guilds.cache.size} servers`, {type: 'WATCHING'})
});
client.on('message', message => {
const { channel } = message
if (channel.type === 'news') {
message.crosspost().catch(console.error)
console.log(`\x1b[31m${message.guild.name}\x1b[0m sunucusunda duyuru yapıldı! \x1b[33m(ID: ${message.guild.id})`)
}
if (error) {
client.users.cache.get(message.author.id).send(error)
}
});
【问题讨论】:
标签: javascript node.js discord.js