TypeError: Cannot read properties of undefined (reading 'channels')
I am trying to automate the welcome messages through the use of a bot and have a functioning listener for the guildMemberAdd event but when trying to get the id of the channel I want to send the message to I get this error. My code is the following
import { Listener } from "@sapphire/framework";import { Client, TextChannel } from "discord.js";export class GuildMemberAddGreeting extends Listener { public constructor(context: Listener.Context, options: Listener.Options) { super(context, { ...options, event: 'guildMemberAdd', once: false }); } public override async run(client: Client) { //CHANGE ONCE MOVED TO ACM SERVER const channel = client.channels.cache.get('1115435350060445817'); }}
import { Listener } from "@sapphire/framework";import { Client, TextChannel } from "discord.js";export class GuildMemberAddGreeting extends Listener { public constructor(context: Listener.Context, options: Listener.Options) { super(context, { ...options, event: 'guildMemberAdd', once: false }); } public override async run(client: Client) { //CHANGE ONCE MOVED TO ACM SERVER const channel = client.channels.cache.get('1115435350060445817'); }}
I have at this point quintuple checked that this is the correct channel and correct id for the channel. Does this have something to do with the nature of the client object being passed in. Any help appreciated.
Recent Announcements
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community
S-IaF
Sapphire - Imagine a Framework
Sapphire is a next-gen object-oriented Discord.js bot framework.