#client.channels.cache.get or client.channels.fetch doesn't have send function

31 messages · Page 1 of 1 (latest)

pure echo
#

Available Channel Things:
Attachment

Code:

import client from "../..";
import { Event } from "../../structures/lib/Event";

export default new Event({
  name: "ready",
  once: true,
  async run() {

    const channel = await client.channels.fetch(client.config.ntx.welcome);
    channel.send("Name")
  },
});

#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

scarlet heath
#

you need to check if channel is text-based .isTextBased()
because you can send messages only in text-based channels

pure echo
#

this will return boolean

#

i tried

stable crow
#

Lol

#

What exactly did you try?

pure echo
stable crow
pure echo
#

nope

#

from the example in discordjs.guide

stable crow
#

"nope" is not an answer to "What exactly did you try?"

stable crow
pure echo
#

using typescript anyway

undone bison
#
channel // Channel
if (!channel.isTextBased()) return …
channel // TextBasedChannel```
pure echo
undone bison
robust whale
night steppe
pure echo
pure echo
#
i.channel // Channel
if (!i.channel?.isTextBased()) return …
i.channel // Channel
#

it is bug?

#

wait nvm

#

i think its code bug

#
 const collector = options.createMessageComponentCollector({
        time: 30_000,
        componentType: ComponentType.StringSelect,
      })

      collector.on("collect", (i) => {
        interaction.editReply({
          content: `**Creating Ticket**... (1-3s)`,
          components: [],
        });

        const channel = client.channels.cache.get(client.config.ticket.channel);
        if(!channel?.isTextBased()) return;
        channel?.isTextBased()
      });