我正在努力做到这一点,因此,无论在我的艺术聊天发送的任何东西也被发送到一个不和谐的频道通过我的机器人。它得到的信息在游戏中,但不会张贴到不和谐的渠道。(我是JavaScript新手)
const Discord = require('discord.js');
const mineflayer = require('mineflayer');
const client = new Discord.Client();
var bot = mineflayer.createBot({
host: "localhost",
port: 62146,
username: "email",
password: "password",
});
client.on('ready', () => {
console.log(`Connected!`)
console.log(`Username: ${client.user.tag}`);
});
bot.on('chat', function(username, message) {
if (username === bot.username) return;
bot.chat(message)
});
client.on("message", function(message) {
client.channels.get()("500693869684326430").send(message)
});
client.login('');我希望这发送的信息是由用户发送到这样发送到一个不和谐的渠道定义。
发布于 2018-11-05 01:36:24
我在这里看到了一些你可以改进的东西,但我知道的第一件事(也许)是:
在您的代码中有client.channels.get()("500693869684326430").send(message),当我非常确定它应该是client.channels.get("500693869684326430").send(message)时,因为函数get()是您要给出的通道ID的参数。为了清楚起见,这将把message发送到ID 500693869684326430的不和谐通道。
我也看到了,当你说你想把来自“我的世界”聊天的信息发送到不和谐的频道时,你似乎在把“我的世界”的聊天信息发送回与bot.chat(message)的聊天中?我相信你打算在这里使用前面提到的client.channels.get("500693869684326430").send(message)。
为了澄清我的意思,我会把完整的代码放在下面。
const Discord = require('discord.js');
const mineflayer = require('mineflayer');
const client = new Discord.Client();
var bot = mineflayer.createBot({
host: "localhost",
port: 62146,
username: "email",
password: "password",
});
client.on('ready', () => {
console.log(`Connected!`)
console.log(`Username: ${client.user.tag}`);
});
bot.on('chat', function(username, message) {
if (username === bot.username) return;
client.channels.get("500693869684326430").send(message)
});
client.on("message", function(message) {
// you don't really need this but maybe that's what you want, i don't know
//client.channels.get()("500693869684326430").send(message)
});
client.login('');说句公道话,我以前从来没有用过雷鸟,但我想我也许能帮上忙。如果你需要我澄清任何事就评论吧。
发布于 2021-02-22 08:28:28
也许你可以这样做
在雷炸机上有一个叫做“讯息”的事件。
bot.on("message", message => {
let channel = client.channels.cache.get("CHID")
if (!channel) return;
channel.send(`From Server Chat >> ${message}`)
})https://stackoverflow.com/questions/53146494
复制相似问题