question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`TextChannel.send` function has wrong types for the `components` parameter

See original GitHub issue

Which package is this bug report for?

builders

Issue description

Seems like the types are wrong and send doesn’t accept ActionRowBuilder as a component. I know that the docs are outdated at the moment, maybe I’m doing something wrong? If I cast row to any, the code actually compiles and works as intended.

Steps to reproduce:

  1. Run the sample code through tsc
  2. Get the compilation error

Code sample

function test(channel: TextChannel) {
  const row = new ActionRowBuilder().addComponents(
    new ButtonBuilder()
      .setCustomId('approve')
      .setLabel('Approve')
      .setStyle(ButtonStyle.Success)
  )

  return channel.send({
    content: 'sample',
    components: [row],
  })
}

Package version

14.0.3

Node.js version

17.3.0

Operating system

linux, mac os

Priority this issue should have

Medium (should be fixed soon)

Which partials do you have configured?

Channel

Which gateway intents are you subscribing to?

GuildMessages

I have tested this issue on a development release

96b62b6.0

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
suneettipirnenicommented, Jul 21, 2022

This can be remedied with a factory function instead of using the class constructor ie createActionRow<T>(). Dunno if the maintainers would want to include that in the library though.

1reaction
imranbarbhuiyacommented, Jul 21, 2022

https://github.com/discordjs/discord.js/pull/8271 but it was closed without specifying any reason.

Read more comments on GitHub >

github_iconTop Results From Across the Web

channel.send is not a function discord.js - Stack Overflow
PS: Your first error was TypeError: channel.send is not a function , so it seems that it was not a text channel.
Read more >
ChannelManager has wrong type parameter #6935 - GitHub
You can't send messages to voice channels nor categories. The issue is that the Cache Manager doesn't hold / yield instances of the...
Read more >
Updating from v12 to v13 - discord.js Guide
Channel types are now uppercase and align with Discord's naming conventions. - if(channel.type === 'text') channel.send('Content'); ...
Read more >
API Reference - Discord.py
This class is used to interact with the Discord WebSocket and API. ... Control how the client handles mentions by default on every...
Read more >
TextChannel | Eris 0.17.1 - Abal.moe
The type of component - If 1, it is a collection and a components array (nested) is required; if 2, it is a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found