#Guild member add listerner send message
1 messages · Page 1 of 1 (latest)
If you use the @ApplyOptions decorator you don’t use the constructor too. Put all the options in there

- Don't use
wsemitter, you won't get DiscordJS-ified data but raw data. It's not worth using. - Use the
Eventsconstant for event names, i.e.Events.GuildMemberAdd runparameters match those found on the discord.js documentation for client -> events -> guild member add
but SapphireEvents does not exist
apologies it's just called Events
np but how can i send at Events.GuildMemberAdd a message?
Like I said, check the discordjs docs. The event gets a GuildMember, you can work your way to a channel from there. https://old.discordjs.dev/#/docs/discord.js/main/class/Client?scrollTo=e-guildMemberAdd. You'll have to write the code yourself. We're not here to spoonfeed whole listeners for you.
FWIW the reason I (and anyone else ) wont spoonfeed all the answers and code is because at that point we may as well be writing your bot for you (which would cost you anyway). We expect at least some proactiveness and self incentive from developers. Questions like the ones you're leaning towards asking you can also very easily find the answers to by just trying and if it doesn't work try something else and again and again, that's a far far far better way to learn than gettting all the answers on a silver plater.
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
import { Listener, Events } from '@sapphire/framework';
import { GuildMember } from 'discord.js';
import { AutoRole } from '../prisma';
export class UserEvent extends Listener {
private autoRole: AutoRole;
public constructor(context: Listener.Context, options: Listener.Options) {
super(context, {
...options,
event: Events.GuildMemberAdd
});
this.autoRole = new AutoRole();
}
public override async run(member: GuildMember) {
console.log(await this.autoRole.get(member.guild.id));
}
}
so i made this but it wont log
make sure you go over all the basics
- rebuild ts
- validate files in dist
- remove stale files from dist
- validate other listeners and commands work
- validate the folder structure is correct
etc
okay ima try
and where is this particular file?
autorole.ts
that's not under the listeners folder best I can tell
ready and autorole are in listerers folder