-1

So I am a very beginner coder and I want to learn more, I searched for some time how to do this and didn't find so I need some help.

I just want to make a bot when someone opens a game for exemple osu!, the bot to send a message to a text channel saying "*Persons name * joined osu!", and when they leave to say "*Persons name * left osu!".

I did this but it doesn't work.

const Discord = require('discord.js');

const client = new Discord.Client();



client.once('ready', () => {
    console.log('ConnectionLogs is online!');
});


client.on("presenceUpdate", (oldMember, newMember) => {
    if(newMember.id === '406742915352756235') {
        if(newMember.presence.game.name === 'osu!') { 
            console.log('osu! detected!');
            client.channels.get('573671522116304901').send('**Joining Game:**', {
                files: [
                    
                    ]
                });
            }
        }
    });
    


client.login('MY TOKEN')
futur
  • 1,673
  • 5
  • 20
  • 2
    Be sure not to show your bot token in your code sample. I'd recommend going and regenerating it. – futur Jun 21 '21 at 13:00

1 Answers1

0

Since you haven't mentioned it, I would suggest you haven't turned on the intents? Long story short - you don't get those events by default, as an effort to decrease traffic. You should go to your Discord Application (in developer portal) > Bot > enable the intents.


A bit more explanation can be found here: https://stackoverflow.com/a/64559391/2065080

Andrey Popov
  • 7,362
  • 4
  • 38
  • 58