Error in text voice channels with a creating a collector
See original GitHub issueWhich package is this bug report for?
discord.js
Issue description
Discord seems to have rolled out a beta feature to some servers which seems to be a text channel connected to a voice channel. https://www.reddit.com/r/discordapp/comments/thuyy1/so_now_voice_channel_is_mixed_with_a_text_channel/
My bots create ButtonInteractions and attach a MessageComponentCollector to them to wait for a response. The first error I get is when the MessageComponentCollector is called on the channel I get an error saying the function doesn’t exist.
Which is fair enough and easy for me to ignore the error until the feature is fully supported.
The real problem is when someone clicks the button. I am getting a TypeError from the Discord.js library that is crashing the program. It seems to occur during the MessageComponentInteraction creation.
Because the issue is on the Discord.js side it makes it hard to deal with on my end. And while I understand the feature is experimental on Discord I cannot really have it crashing my bot every time someone clicks a button in those channels.
Code sample
let channel;
try
{
channel = await this.interaction.client.channels.fetch(this.interaction.channelId);
}
catch(error)
{
console.error(error);
return;
}
this.collector = channel.createMessageComponentCollector(
{
filter,
time: minToMilli(14)
});
// TypeError: channel.createMessageComponentCollector is not a function
Package version
discord.js@13.6.0
Node.js version
v18.0.0
Operating system
Debian 4.19.132-1 (2020-07-24) x86_64
Priority this issue should have
High (immediate attention needed)
Which partials do you have configured?
No Partials
Which gateway intents are you subscribing to?
Guilds, DirectMessages
I have tested this issue on a development release
No response
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Thanks for the info. Because of how many guilds the bots are in I will leave it at the current stable and they will just have to do without until v14. Thanks again.
Yeah, that’s most likely caused by TiV being a voice channel, and therefore the method not existing.
Because
VC#isText()
is false, https://github.com/discordjs/discord.js/blob/v13/src/client/actions/MessageCreate.js#L14 will return no message, which consequently will make discord.js not emit the message (since v13 has no way to handle it).Therefore, your error should not longer happen again.