TypeScript GuildText Channel Type help

I am attempting to fetch a channel to send a welcome message in my guildMemberAdd event. However, I am getting this type error:
Property 'send' does not exist on type 'GuildBasedChannel'.
Property 'send' does not exist on type 'CategoryChannel'.ts(2339)
Property 'send' does not exist on type 'GuildBasedChannel'.
Property 'send' does not exist on type 'CategoryChannel'.ts(2339)
Here is my event:
import { Events, GuildMember, EmbedBuilder } from "discord.js";
import { Event } from "../interfaces";

const event: Event = {
name: Events.GuildMemberAdd,
execute: async (client, member: GuildMember) => {
if (!member || member == null) return;

const embed = new EmbedBuilder()
.setTitle('New Member Joined')
.addFields(
{ name: 'Member', value: member.user.username, inline: true },
{ name: 'Member ID', value: member.id, inline: true })
.setColor("Green")
.setFooter({ text: `${client.user?.username}` })

const channel = member.guild.channels.cache.get("1060224954035081276");
if (channel) {
channel.send({ embeds: [embed] })
}
}
}
import { Events, GuildMember, EmbedBuilder } from "discord.js";
import { Event } from "../interfaces";

const event: Event = {
name: Events.GuildMemberAdd,
execute: async (client, member: GuildMember) => {
if (!member || member == null) return;

const embed = new EmbedBuilder()
.setTitle('New Member Joined')
.addFields(
{ name: 'Member', value: member.user.username, inline: true },
{ name: 'Member ID', value: member.id, inline: true })
.setColor("Green")
.setFooter({ text: `${client.user?.username}` })

const channel = member.guild.channels.cache.get("1060224954035081276");
if (channel) {
channel.send({ embeds: [embed] })
}
}
}
2 Replies
d.js toolkit
d.js toolkit•13mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
ShompiFlen
ShompiFlen•13mo ago
you have to type that channel as TextChannel or check it at run time with channel.type === ChannelType.GuildText since you have the id and you probably know the type this channel is then use the first suggestion
Want results from more Discord servers?
Add your server