Node.js 无法将Readline与Discord.js一起使用
在使用Discord bot时,我尝试使用readline for Node.js来简化输入处理,但是无论我对代码做了什么,它总是只运行bot事件,而不运行reader事件。我不确定这是为什么,我真的希望能够使用这两种方法来更轻松地输出消息 我的机器人:Node.js 无法将Readline与Discord.js一起使用,node.js,discord,discord.js,Node.js,Discord,Discord.js,在使用Discord bot时,我尝试使用readline for Node.js来简化输入处理,但是无论我对代码做了什么,它总是只运行bot事件,而不运行reader事件。我不确定这是为什么,我真的希望能够使用这两种方法来更轻松地输出消息 我的机器人: 'use strict'; const Discord = require('discord.js'); const Chalk = require('chalk'); const Readline = require('readli
'use strict';
const Discord = require('discord.js');
const Chalk = require('chalk');
const Readline = require('readline');
const Token;
const Script = require('./data.js');
const rl = Readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question(Chalk.yellow("Enter guild representative's ID: ", (answer) => {
rep = answer;
console.log(Chalk.green("ID Recorded: " + rep));
}));
rl.question(Chalk.magenta("Enter embed color: ", (answer) => {
color = answer;
console.log(Chalk.green("Color recorded: " + color));
}));
rl.question(Chalk.blueBright("Enter guild description: ", (answer) => {
color = answer;
console.log(Chalk.green("Color recorded: " + color));
}));
const bot = new Discord.Client();
bot.on("ready", () => {
console.log("Bot is ready!");
});
bot.on("message", (message) => {
if (message.content == ":addPartner") {
message.guild.channels.find("name", "affiliates").send({ embed });
message.channel.send(":white_check_mark: Affiliate message sent in #affiliates!");
*/
}
});
现在还不清楚你想要完成什么。你在处理什么输入?谁的?这怎么会更容易呢?我想他正在尝试预先用一些node/cmdline的东西初始化bot,我认为这里的问题是异步流。这不是因为您使用的是
discord.js
,