变量消息是字符串

Variable message is string

client.on("message", async (message) => {

});

可变消息是只有用户名的字符串。 message.content 之类的东西是未定义的。我需要的不仅仅是用户名。

我试过:

client.on("message", function (user, userID, channelID, message, evt)  {

});

但我需要消息的作者或发送消息的服务器等信息。

此函数之前的代码:

const Discord = require('discord.io');
var logger = require('winston');
var auth = require('./auth.json');

const Keyv = require('keyv');

var fs = require("fs");

const keyv = new Keyv();

// Configure logger settings
logger.remove(logger.transports.Console);
logger.add(new logger.transports.Console, {
    colorize: true
});
logger.level = 'debug';
// Initialize Discord Bot
var client = new Discord.Client({
    token: auth.token,
    autorun: true
});
client.on('ready', function (evt) {
    logger.info('Connected');
    logger.info('Logged in as: ');
    logger.info(client.username + ' - (' + client.id + ')');
});



process.on('uncaughtException', function (err) {
    console.log('Caught exception: ', err);
});

您应该使用 discord.js 而不是 discord.io。 discord.js 有一份很好的 API 文档,可以为您指明您可能需要的内容:

客户端消息事件:https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-message 消息类型属性和方法:https://discord.js.org/#/docs/main/stable/class/Message

discord.io 似乎是为了一些微不足道的功能劫持了 discord 名称。来自他们自己的网站:

Discord.io is the website that allows you to create custom, personal discord invites. A custom Discord invite is a powerful marketing tool when you use it carefully. It is not just an invite, but a medium between your member and your server. A custom Discord invite allows you to collect so much data about your members and their behaviors.