client.on('guildMemberUpdate', (oldMember, newMember) => { // Fire if user has a role if (newMember.roles.cache.some(r => r.name === "TEST_ROLE")) { try { // stuff } catch(err) { // stuff } }})
client.on('guildMemberUpdate', (oldMember, newMember) => { // Fire if user has a role if (newMember.roles.cache.some(r => r.name === "TEST_ROLE")) { try { // stuff } catch(err) { // stuff } }})
DiscordJS is telling me they provide it as well. But how to access it in sapphire ? The run() function in a listener has only the client available.
export class GuildMemberUpdateListener extends Listener { public constructor(context: Listener.Context, options: Listener.Options) { super(context, { ...options, emitter: container.client.ws, event: 'GUILD_MEMBER_UPDATE' }); } public async run(client: Client) { }}
export class GuildMemberUpdateListener extends Listener { public constructor(context: Listener.Context, options: Listener.Options) { super(context, { ...options, emitter: container.client.ws, event: 'GUILD_MEMBER_UPDATE' }); } public async run(client: Client) { }}
Solution
Not sure. Check your intents I guess. Haven't dealt with this event in a long time. Regardless, it's more of a DJS question because sapphire literally does absolutely nothing for events. We don't for example proxy forward them or anything, we also just use client.on(...) essentially.