Bruh Gpt
Bruh Gpt

Reputation: 33

discord.js v13 how to send message in a channel in another server

i'm using discord.js v13 and i was trying to send a message in another server's channel from where the slash commands was used

const channel = interaction.guild.channels.cache.get("id")
channel.send({
            content: "<@&890249127907172407>",
            embeds: [Embed],
            components: [row]
})

but i get TypeError: Cannot read properties of undefined (reading 'send')

Upvotes: 1

Views: 1176

Answers (1)

MrMythical
MrMythical

Reputation: 9041

You are using Guild#channels, which only holds the channels from that guild. You may instead want to use Client#channels, which holds all the channels in all the guilds the bot is in, as long as you have GUILDS intent.

const channel = client.channels.cache.get(id)
channel.send({
  content: "...",
  embeds: [Embed],
  components: [row]
})

Upvotes: 2

Related Questions