如何修复我的机器人忽略反应?

时间:2021-03-02 07:20:43

标签: javascript loops discord discord.js settimeout

var bigtextarr = ['?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?']
    let votenum
    let funci = 0
    var fetchedarr
    function emojiloop(){
        console.log(funci + bigtextarr[funci])
        message.channel.fetchMessage(fetchedarr[1]).then(msg => msg.react(bigtextarr[funci]))
        if(funci<votenum){
            funci++
            setTimeout(() => {
                emojiloop()
            }, 1000);
        }
    }

    if(msgcontent.startsWith(';투표 '))
    {
        votenum = deleteall(msgcontent,';투표 ') //gets a number next to ;
        message.channel.fetchMessages({
            limit: 2
        })
        .then(fetchedMessages => {
            fetchedarr = Array.from(fetchedMessages.keys())
            message.channel.fetchMessage(fetchedarr[0]).then(msg => msg.delete());
            emojiloop()
        });
    }

我想编写执行此操作的代码:如果我发送“;투표(数字)”,此 Discord 机器人会使用字母表的前 (number) 个字母对上述消息做出反应。

例如:

  • ";투표 3" -> 与 A,B,C 反应
  • ";투표 7" -> 与 A,B,C,D,E,F,G 反应

发送“;투표 5”时,此代码与 B,C,D,E,F 反应。它也记录

0?
1?
2?
3?
4?
5?

为什么第一反应 (A) 不起作用?

0 个答案:

没有答案
相关问题