discord-vatron
Version:
Módulo para facilitar la interacción con la API de Discord
58 lines (55 loc) • 1.98 kB
JavaScript
module.exports = class Presencia {
constructor(datos, bot) {
this._datos = datos;
this._bot = bot;
}
get juego() {
const emoji = this._datos.game.emoji ? {
nombre: this._datos.game.emoji.name,
id: this._datos.game.emoji.id || null,
animado: this._datos.game.emoji.animated || false
} : null;
return {
estado: this._datos.game.state || '',
emoji: emoji || {},
nombre: this._datos.game.name || '',
id: this._datos.game.id || '',
creacion: this._datos.game.created_at || Date.now()
};
}
get actividades() {
return this._datos.activities.filter(x => x.type == 0 || x.type == 3 || x.type == 4).map(a => {
if(a.type == 0) {
return {
nombre: a.name,
id: a.id,
detalles: a.details,
creacion: a.created_at,
idAplicacion: a.application_id
};
} else if(a.type == 3) {
return {
nombre: a.name,
id: a.id,
creacion: a.created_at
};
} else if(a.type == 4) {
const emoji = a.emoji ? {
nombre: a.emoji.name,
id: a.emoji.id || null,
animado: a.emoji.animated || false
} : null;
return {
estado: a.state || '',
emoji: emoji || {},
nombre: a.name || '',
id: a.id || '',
creacion: a.created_at || Date.now()
};
};
});
}
get usuario() {
return this._bot.usuarios.has(this._datos.user.id) ? this._bot.usuarios.get(this._datos.user.id) : {};
}
}