discord-vatron
Version:
Módulo para facilitar la interacción con la API de Discord
38 lines (35 loc) • 1.01 kB
JavaScript
const Usuario = require("../clases/Usuario.js");
const tipos = {
'JUGANDO': 0,
'TRANSMITIENDO': 1,
'ESCUCHANDO': 2,
'VIENDO': 3
};
const estados = {
'enLinea': 'online',
'noMolestar': 'dnd',
'ausente': 'idle'
};
module.exports = class BotUsuario extends Usuario {
constructor(datos, bot, socket) {
super(datos, bot);
this._socket = socket;
}
estPresencia(opciones) {
if(!opciones) return this;
if(!opciones.juego) opciones.juego = {};
this._socket.send(JSON.stringify({
op: 3,
d: {
status: estados[opciones.estado] || opciones.estado || 'online',
game: {
name: opciones.juego.nombre || '',
type: tipos[opciones.juego.tipo] || tipos['JUGANDO']
},
since: new Date().valueOf(),
afk: false
}
}));
return this;
}
}