Ad

Discord.js Welcome Message Only Choosing One Random Message Per Restart

- 1 answer

i need my bot to choose more than one welcome message per restart as of now i have multiple choices and the bot only picks one how would i get the bot to refresh choices per person joining?

    var welcometext = [
        "Welcome to Hogwarts!",
        "Welcome to Diagon Alley.",
        "Welcome to the server.",
        "Welcome to a new year at Hogwarts! Before we begin our banquet, I would like to say a few words. And here they are: Nitwit! Blubber! Oddment! Tweak!",
        "Welcome to the server, From ViridianZe",
        "VELCOM TO MY LEIR AH AH AH AH AHHHH",
        "Welcome to Hogwarts, STAY OUT OF THE HIDDEN FOREST!",
        "Welcome to CK2 Wizarding World",
        "WHAT HOW DID YOU FIND US? Welcome"


    ]

        var wtl = Math.floor(Math.random() * welcometext.length);

    client.on("guildMemberAdd", (member) => {
          member.send("Welcome our new users!\n");
          client.channels.get('711633590445670421').send(' ' + welcometext[wtl])

Ad

Answer

Placing var wtl = Math.floor(Math.random() * welcometext.length);

Inside your client.on should do it. Thus the random would be regenerated every time.

Kind Regards BloodSKreaper

Ad
source: stackoverflow.com
Ad