第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Discord.JS 反應(yīng)

Discord.JS 反應(yīng)

慕姐4208626 2023-07-06 11:00:08
我正在開(kāi)發(fā)一個(gè)票證機(jī)器人,我希望它能夠讓您對(duì)消息做出反應(yīng)以創(chuàng)建票證。我可以發(fā)送消息,但當(dāng)我使用時(shí),bot.on('messageReactionAdd')如果我的機(jī)器人重新啟動(dòng),它不會(huì)檢測(cè)到已添加反應(yīng),除非您發(fā)送新消息并對(duì)自機(jī)器人上線以來(lái)創(chuàng)建的消息做出反應(yīng)。這對(duì)我來(lái)說(shuō)是一個(gè)問(wèn)題,我知道它是可以解決的。我嘗試過(guò)谷歌搜索,但無(wú)法解決問(wèn)題。這里有人可以幫助我嗎?
查看完整描述

2 回答

?
梵蒂岡之花

TA貢獻(xiàn)1900條經(jīng)驗(yàn) 獲得超5個(gè)贊

從 Discord.js v12 開(kāi)始,您可以在機(jī)器人上啟用部分功能,允許其發(fā)送未獲取消息的事件,但代價(jià)是您必須在處理程序開(kāi)始時(shí)自己獲取消息:

const Discord = require('discord.js');

// Make sure you instantiate the client with the correct settings

const client = new Discord.Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });

client.on('messageReactionAdd', async (reaction, user) => {

? ? // When we receive a reaction we check if the reaction is partial or not

? ? if (reaction.partial) {

? ? ? ? // If the message this reaction belongs to was removed the fetching might result in an API error, which we need to handle

? ? ? ? try {

? ? ? ? ? ? await reaction.fetch();

? ? ? ? } catch (error) {

? ? ? ? ? ? console.error('Something went wrong when fetching the message: ', error);

? ? ? ? ? ? // Return as `reaction.message.author` may be undefined/null

? ? ? ? ? ? return;

? ? ? ? }

? ? }

? ? // Now the message has been cached and is fully available

? ? console.log(`${reaction.message.author}'s message "${reaction.message.content}" gained a reaction!`);

? ? // The reaction is now also fully available and the properties will be reflected accurately:

? ? console.log(`${reaction.count} user(s) have given the same reaction to this message!`);

});


查看完整回答
反對(duì) 回復(fù) 2023-07-06
?
ibeautiful

TA貢獻(xiàn)1993條經(jīng)驗(yàn) 獲得超6個(gè)贊

您可以根據(jù)需要使用它,但這里有一個(gè)示例:


message.channel.send("React test!").then(messageReaction => {

    messageReaction.react("?");

    messageReaction.react("?");

  });


查看完整回答
反對(duì) 回復(fù) 2023-07-06
  • 2 回答
  • 0 關(guān)注
  • 161 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)