#Guild member add listerner send message

1 messages · Page 1 of 1 (latest)

pale crescentBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

spiral tiger
#

If you use the @ApplyOptions decorator you don’t use the constructor too. Put all the options in there

worn mesa
#
  1. ThisPoint
  2. Don't use ws emitter, you won't get DiscordJS-ified data but raw data. It's not worth using.
  3. Use the Events constant for event names, i.e.Events.GuildMemberAdd
  4. run parameters match those found on the discord.js documentation for client -> events -> guild member add
discord.js

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.

forest elm
worn mesa
#

apologies it's just called Events

forest elm
#

np but how can i send at Events.GuildMemberAdd a message?

worn mesa
#

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.

forest elm
#
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

worn mesa
#

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
forest elm
#

okay ima try

forest elm
#

it woudnt do anything

#

thats bad

#

my folder structure

worn mesa
#

and where is this particular file?

forest elm
#

autorole.ts

worn mesa
#

that's not under the listeners folder best I can tell

forest elm
#

ready and autorole are in listerers folder

worn mesa
#

oh I got confused by autorole vs auto-role

#

idk then man

#

check all your stuff

#

should just work

#

check your intents as well

#

idk

forest elm
#

okay

#

worked it was cause of the intent s