【发布时间】:2020-01-16 07:17:41
【问题描述】:
我这里有这段代码:
var Kahoot = require("kahoot.js-updated");
var client = new Kahoot;
console.log("Joining kahoot...");
client.join(9802345 /* Or any other kahoot game pin */, "kahoot.js");
client.on("joined", () => {
console.log("I joined the Kahoot!");
});
client.on("quizStart", quiz => {
console.log("The quiz has started! The quiz's name is:", quiz.name);
});
client.on("questionStart", question => {
console.log("A new question has started, answering the first answer.");
question.answer(0);
});
client.on("quizEnd", () => {
console.log("The quiz has ended.");
});
我想知道如何让机器人多次加入 kahoot。
我已经尝试添加client.setMaxListeners(Number.POSITIVE_INFINITY),它解决了太多听众的错误。我尝试使用setInterval()
对于 join 命令,但它只是说 Joining kahoot... 并且从不连接。
如何让 kahootbot 多次加入所说的 kahoot? (大概100次左右)
【问题讨论】:
-
对于这个库,每个播放器需要一个客户端。
-
谢谢你的回答,我确实得到了一个赞成票,但没有回答大声笑
-
为了将来参考,如果您使用非官方库来指定您在问题中使用的库,这对我们来说会容易得多。
-
我可以做类似 var num = 0; 的事情吗?数++; setInterval(function() { var (client + num) = new Kahoot; }, 30) 什么的
-
听起来你想动态生成变量。 Check this out。正如该答案所暗示的那样,您几乎不需要创建实际变量(例如 client1、client2 等),因为您可以使用数组。
标签: javascript node.js package node-modules