Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

172
Vistas
Player Login/ Logout Feed for Discord

I'm currently working on a Discord Bot for my game server and I would like to implement a Player Login/Logout feed. I have set up a SQL database where it stores information about a player, I have created a Table name called 'users' and in this table I have a column called 'presence' this has a default value called 'offline' and switches to 'online' when a player has joined the server.

My goal here is to have the Bot send a message only when the column 'presence' changes from 'offline' to 'online' and also from 'online' to 'offline'. enter image description here

So far I'm able to get the bot to send a message when the bot starts about a players presence, my question is how to make it 'listen' for when a player presence has changed and then send a message?.

I hope this makes sense and thanks in advance.

main.js

setInterval(() => {
    PlayerFeed.publish(client);
  }, 30000);
});

PlayerFeed.js

const { Users } = require("../dbObjects");
const { Sequelize } = require("sequelize");
const { codeBlock } = require("@discordjs/builders");

module.exports = {
    publish: (client) => {
        const channel = client.guilds.cache.get(Config.guildId).channels.cache.get(Config.PlayerFeedChannel)
        Users.findAll({where: {presence: 'online'}, order: ['presenceUpdatedAt']}).then(users => {
            users.forEach(Users => {
                
             let presence = Users.presence;
                if(presence == 'online')
                channel.send(codeBlock("diff",
                `+Login ID:${Users.steamId64} ID:${Users.ign}`));
                
                else if 
                (presence == 'offline')
                channel.send(codeBlock("diff",
                `-Logout ID:${Users.steamId64} ID:${Users.ign}`));
              })
            })
          }
        }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

So, if I understand well, "presence" is set to "online" when user join your guild and it set to "offline" if he leaves it right?

If so, you should use Discord Events to manage this.

on guildMemberAdd => add user to db with presence online => send message in your feed

on guildMemberRemove => set presence to offline => send message in your feed

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda