DISCORD JS v13 createReactionCollector quot;collectquot; doesn#39;t work(DISCORD JS v13 createReactionCollector “收集不工作)
问题描述
介绍
我想在
我可以解决这个问题.
<块引用>与代码无关,忘记添加 GUILD_MESSAGE_REACTIONS 意图.
createReactionCollector 在 discord.js 中不起作用
const client = new Discord.Client({意图:['GUILD_VOICE_STATES','GUILD_MESSAGES','GUILDS','GUILD_MESSAGE_REACTIONS'],});
Introduce
I want to use page generation from discord.js-pagination in discord.js v13.
The source code use createReactionCollector
but collect
doesn't work.
In Detail
The two reaction buttons are displayed correctly. It also runs the timeout correctly and the two buttons are removed after 12000ms.
The problem is that there is no response when I press the reaction button. "collect" doesn't work.
I can't believe that "end" is executed, but "collect" is not. Could anyone give me a clue?
Source code
static async paginationEmbed(msg: Message, pages:MessageEmbed[], emojiList = ['⏪', '⏩'], timeout = 12000)
{
if (!pages) throw new Error('Pages are not given.');
if (emojiList.length !== 2) throw new Error('Need two emojis.');
let page = pages.length - 1;
const curPage = await msg.channel.send({ embeds: [pages[page].setFooter(`Page ${page + 1} / ${pages.length}`)]});
for (const emoji of emojiList) await curPage.react(emoji);
const filter = (reaction:MessageReaction, user:User) => {
return true;
}
const reactionCollector = curPage.createReactionCollector({ filter, time: timeout });
reactionCollector.on('collect', (reaction, user) => {
console.log("I want to show this!!")
reaction.users.remove(msg.author);
switch (reaction.emoji.name) {
case emojiList[0]:
page = page > 0 ? --page : pages.length - 1;
break;
case emojiList[1]:
page = page + 1 < pages.length ? ++page : 0;
break;
default:
break;
}
curPage.edit({ embeds: [pages[page].setFooter(`Page ${page + 1} / ${pages.length}`)]});
});
reactionCollector.on('end', () => {
if (!curPage.deleted) {
curPage.reactions.removeAll()
}
});
return curPage;
}
Enviroment
discord.js@13.1.0
(get by npm ls
)
Addition
My Client is following:
const client = new Discord.Client({
intents: ['GUILD_VOICE_STATES', 'GUILD_MESSAGES', 'GUILD_MEMBERS', 'GUILDS']
});
createReactionCollector not triggering
I can solve this problem.
Was unrelated to code, forgot to add the GUILD_MESSAGE_REACTIONS intent.
createReactionCollector not working in discord.js
const client = new Discord.Client({
intents: ['GUILD_VOICE_STATES', 'GUILD_MESSAGES', 'GUILDS', 'GUILD_MESSAGE_REACTIONS'],
});
这篇关于DISCORD JS v13 createReactionCollector “收集"不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:DISCORD JS v13 createReactionCollector “收集"不工作


基础教程推荐
- Chart.js 在线性图表上拖动点 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 直接将值设置为滑块 2022-01-01