如何解决登录多个令牌并执行操作
我正在创建一个同时连接多个机器人的命令,但我遇到了一个问题,当所有机器人都调用时,我希望该问题在控制台中只出现一次,询问此人想要做什么,当他们回答脚本时,它会保存他们的答案,并会在所有机器人上运行。
const Discord = require('discord.js')
const auth = require('./token.json')
const readline = require('readline')
const fs = require('fs');
const rl = readline.createInterface({
input: process.stdin,output: process.stdout
});
rl.question("Choose between 1 or 2. ",name => {
if(name === "1") {
rl.question("Teste? ",info1 => {
console.log(info1)
rl.close();
});
} else if(name === "2") {
rl.question("Teste2? ",info2 => {
console.log(info2)
rl.close();
})}
;
});
for (const token of auth.token) {
const client = new Discord.Client()
client.on('ready',() => {
//---------> How to see / execute what was chosen in line 12 appear here <---------\\
})
client.login(token).catch(e => {
const index = auth.token.indexOf(token);
if (index > -1) {
auth.token.splice(index,1)
}
fs.writeFile ("token.json",JSON.stringify(auth),function(err) {
if (err) throw err;
})
});
}```
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。