使用 discord.io 将消息发送到特定频道

Send message to specific channel with discord.io

使用 Discord.io 我正在尝试将消息发送到与发送消息不同的频道,但经过大量谷歌搜索和试验后,我似乎仍然找不到办法所以。

我尝试简单地将 channelID 更改为我希望它发送到的频道,并将 channelID 覆盖到我想要它发送到的频道,但没有成功

例如:


bot.on('message', function (user, userID, channelID, message, evt) {
    if (message.substring(0, 1) == '!') {
        var args = message.substring(1).split(' ');
        var cmd = args[0].toLowerCase();

        args = args.splice(1);
        switch(cmd) {
            case 'test':
                bot.sendMessage({
                    to: // channel id here,
                    message: 'If all went well this got sent in another channel'
                });
                break;
            default:
                bot.sendMessage({
                    to: channelID,
                    message: 'I wasn\'t able to understand this command, please try again...'
                });
                break;
        }
    }
});

希望你能帮助我。 如果有什么不明白的,欢迎提问。

提前致谢。

所以我发现了为什么它不起作用,在文档中它说 channelID 是 Snowflake。我不知道的是,这看起来很像普通字符串。因此,当我尝试用字符串覆盖 channelID 时,它似乎起作用了。像这样:

bot.on('message', function (user, userID, channelID, message, evt) {
    if (message.substring(0, 1) == '!') {
        var args = message.substring(1).split(' ');
        var cmd = args[0].toLowerCase();

        args = args.splice(1);
        switch(cmd) {
            case 'test':
                bot.sendMessage({
                    to: 'your channel id here',
                    message: 'If all went well this got sent in another channel'
                });
                break;
            default:
                bot.sendMessage({
                    to: channelID,
                    message: 'I wasn\'t able to understand this command, please try again...'
                });
                break;
        }
    }
});