Clartye
Clartye
SIASapphire - Imagine a framework
Created by Clartye on 7/28/2023 in #sapphire-support
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.
7 replies
SIASapphire - Imagine a framework
Created by Clartye on 7/28/2023 in #sapphire-support
GuildMemberAdd Event LIstener
I am trying to create an event listener using sapphire ts and discord js. I am trying to find a way to test the event without having to create and ban accounts repeatedly. I tried using the node.js event emitter like so
const emitter = new EventEmitter();
emitter.emit("GUILD_MEMBER_ADD, GuildMember)
const emitter = new EventEmitter();
emitter.emit("GUILD_MEMBER_ADD, GuildMember)
I tried using Client.emit() as a couple stack overflow but I got an error telling me that there was no method for client named emit. Any help is appreciated.
4 replies