久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

未檢測(cè)到 Discord js 反應(yīng)

Discord js reaction not detected(未檢測(cè)到 Discord js 反應(yīng))
本文介紹了未檢測(cè)到 Discord js 反應(yīng)的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

discordjs 有一些我不明白的地方.我想制作一個(gè)機(jī)器人,在人們對(duì)消息做出反應(yīng)時(shí)列出他們.它部分有效,當(dāng)輸入命令的人(或之前輸入過命令的人)對(duì)機(jī)器人的消息做出反應(yīng)時(shí),消息會(huì)立即編輯.但是當(dāng)它是從未輸入過命令的人時(shí),它并沒有更新.

There's something I don't understand with discordjs. I want to make a bot which lists people when they react on a message. It partially works, when the guy who enter the commands (or who has enter a command before) reacts to the bot's message, the message edits immediately. But when it's someone who has never entered command, it didn't update.

const Discord = require('discord.js');
const client = new Discord.Client();
var auth = require('./auth.json');

const regexTime = new RegExp('^(0[0-9]|1[0-9]|2[0-3]|[0-9])([:|h])([0-5][0-9])?$');

var messageBot = "";
var time;
var timer;
var commandeValide=false;
var date = new Date;
var heureMs;

client.on('ready', () => {
    console.log(client.guilds.fetch())
});

client.on('message', msg => {
    
    if (msg.content.substring(0,1) === '!') {

        var args = msg.content.substring(1).split(' ');
        var cmd = args[0];

        switch(cmd){
            case 'amongus':

                dateGame = args[1];
                time = args[2];
                messageBot = '@everyone Est-ce que des personne veulent faire un Among us à '+ time + ' le '+ dateGame;

                if ( dateGame != undefined && time != undefined ){

                    var heure = time.split('h')[0] * 3600000;
                    var minute = time.split('h')[1] * 60000;
                    var temps = heure + minute;
                    heureMs = date.getHours() * 3600000 + date.getMinutes() * 60000;

                    if(regexTime.test(time) && isDate(dateGame)){

                        if(temps>heureMs){

                            commandeValide=true;
                            msg.channel.send(messageBot).then(sendMessage => {
                                sendMessage.react('?')
                            });
                            timer = temps - heureMs;
                        }
                    }else{
                        msg.reply("Veuillez rentrer une heure ou une date valide!");
                        commandeValide=false;
                    }
                }else{
                    msg.reply("Veuillez rentrer une heure et/ou une date s'il vous pla?t! (exemple: !amongus 19/04 20h)");
                    commandeValide=false;
                } 
        }
    }

    if(commandeValide){

        const filter = (reaction, user) => {
            console.log(client.users.cache);
            //return ['?'].includes(reaction.emoji.name);
            return reaction.emoji.name === '?' && user.id !== msg.author.id;
        };
    
        const collector = msg.createReactionCollector(filter, { dispose: true, time: timer }); //dispose: true permet d'utiliser remove
    
        collector.on('collect', (reaction, user) => {
            reaction.users.fetch().then((user) => {
                updateMessage(user.array(),msg);
            });
        });
    
        collector.on('remove', (reaction, user) => {
            reaction.users.fetch().then((user) => {
                updateMessage(user.array(),msg);
            });
        });
    
        collector.on('end', collected => {
            console.log(`Collected ${collected.size} items`);
        });

    }
    

});

function updateMessage(tab, msg){
    var listparticipant = "";
    tab.forEach(user => {
        if(user.id !== auth.server_id){
            listparticipant += "- " + user.username + "
";
        }
    })
    msg.edit(messageBot + "
" + listparticipant);
    console.log(listparticipant);
}
client.login(auth.token);

推薦答案

Discord 改變了它們發(fā)出事件的數(shù)量,請(qǐng)確保將正確的意圖放在您的機(jī)器人上,然后重試!

Discord changed how much they emit events, make sure to put he proper intents on your bot and try again!

const client = new Discord.Client({
    ws : {
        intents: [
            'GUILD_MEMBERS', 
            'GUILD_MESSAGES',
            'GUILD_MESSAGE_REACTIONS' //<--- the intent you need to detect reactions on messages in a guild
        ]
    }
});

這篇關(guān)于未檢測(cè)到 Discord js 反應(yīng)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Using discord.js to detect image and respond(使用 discord.js 檢測(cè)圖像并響應(yīng))
Check if user ID exists in Discord server(檢查 Discord 服務(wù)器中是否存在用戶 ID)
Guild Member Add does not work (discordjs)(公會(huì)成員添加不起作用(discordjs))
Creating my first bot using REPLIT but always error Discord.JS(使用 REPLIT 創(chuàng)建我的第一個(gè)機(jī)器人,但總是錯(cuò)誤 Discord.JS)
How do I code event/command handlers for my Discord.js bot?(如何為我的 Discord.js 機(jī)器人編寫事件/命令處理程序?)
How to find a User ID from a Username in Discord.js?(如何從 Discord.js 中的用戶名中查找用戶 ID?)
主站蜘蛛池模板: 免费午夜剧场 | 久久精品青青大伊人av | 久久网一区二区 | 欧美一区二区三区在线播放 | 久久久2o19精品 | 日韩三级在线 | 欧美亚洲国产一区二区三区 | av在线免费观看网站 | xnxx 日本免费| 久久久久欧美 | 中文字幕在线观看 | 7777精品伊人久久精品影视 | 97视频人人澡人人爽 | 欧美中文字幕一区二区 | 日日干天天操 | 国产日韩欧美在线 | 日韩精品视频在线免费观看 | www.99热这里只有精品 | 国产免费观看久久黄av片涩av | 午夜午夜精品一区二区三区文 | 成人在线免费观看视频 | 日韩日b视频 | 日韩欧美精品一区 | 成人三区四区 | 国产亚洲欧美另类一区二区三区 | 久久av一区二区三区 | 国产精品久久久久久久久久久久久久 | 亚洲国产精品久久久久秋霞不卡 | 欧美一级网站 | 精品久久久久久久久久久下田 | 国产精品久久久久久一区二区三区 | 欧美激情五月 | 久久久久久免费毛片精品 | 日本一区二区三区免费观看 | 婷婷开心激情综合五月天 | 91成人午夜性a一级毛片 | 91人人澡人人爽 | 欧美日韩在线视频一区二区 | 亚洲精品888 | 欧美成人一级 | 中文久久 |