Hello ,I need some Help about listeners in sapphire framework
any one have a working example of ("guildMemberAdd") , a bot that welcome user when they join the server .
The problem is like it can't detect that event , i do not know way
Solution:Jump to solution
you're assigning the event GUILD_MEMBER_AVAILABLE, that's a different event from guildMemberAdd https://discord.js.org/docs/packages/discord.js/14.14.1/Client:Class#guildMemberAdd
9 Replies
Solution
you're assigning the event GUILD_MEMBER_AVAILABLE, that's a different event from guildMemberAdd https://discord.js.org/docs/packages/discord.js/14.14.1/Client:Class#guildMemberAdd
Also please do not post in multiple channels ( #framework-development and here and DMing me)
Sorry for the multiple post ,
Yeah i changed it to (Events.Events.GuildMemberAdd) and it worked !
But it worked until i added , this in the index.ts :
I am not sure why ?! but when i did it worked , and all the other listeners worked fine
That shouldn't matter. You must've changed something else as well. Either way, there is no reason to add that because you can just add a reay listener to the listeners directory.
Also I have no idea how you're importing sapphire but it should be
Events.GuildMemberAdd
, not Events.Events.GuildMemberAdd
. Assuming you write import { Events } from '@sapphire/framework'
What do you mean by
can you show me an example
Ops i was meaning Events.GuildMemberAdd not Events.Events.GuildMemberAdd haha
Add a listener file and call it ready.ts or specify event: Events.ClientReady. Also explained here https://sapphirejs.dev/docs/Guide/listeners/what-are-listeners-and-how-do-they-work
Sapphire Framework
What are listeners and how do they work? | Sapphire
Listeners are classes that contain logic that will be ran whenever a given event occurs.
Oh ! yeah i did it ,
ready event works fine ,
but other events do not work , until i add an empty function in the index.tx : like this:
Well that isn't necessary at all. No idea what you have in your setup that it is. I can't see your code unless you share it. Look at the guide for examples / generate a bot template with the CLI and copy over work so far / look at open source bots (/tag bots with @Spinel )
Okey thanks for the help.
I will generate the template using the cli . And then I will see if the problem is solved