Add activity type enum

(cherry picked from commit c72d5c1f1b)
merge-requests/9/merge
Bsian 2020-04-17 03:27:46 +00:00
parent 65b5cedb4e
commit b126486a0a
1 changed files with 11 additions and 3 deletions

View File

@ -1,7 +1,15 @@
/* eslint-disable prefer-destructuring */ /* eslint-disable prefer-destructuring */
import { Activity, Member, Message, PrivateChannel, GroupChannel } from 'eris'; import { Activity, Member, Message } from 'eris';
import { Client, Command, RichEmbed } from '../class'; import { Client, Command, RichEmbed } from '../class';
enum ActivityType {
PLAYING = 0,
STREAMING = 1,
LISTENING = 2,
WATCHING = 3,
CUSTOM_STATUS = 4
}
export default class Game extends Command { export default class Game extends Command {
constructor(client: Client) { constructor(client: Client) {
super(client); super(client);
@ -27,14 +35,14 @@ export default class Game extends Command {
if (member.activities.length <= 0) return message.channel.createMessage(`***${this.client.util.emojis.ERROR} Cannot find a game for this member.***`); if (member.activities.length <= 0) return message.channel.createMessage(`***${this.client.util.emojis.ERROR} Cannot find a game for this member.***`);
const embed = new RichEmbed(); const embed = new RichEmbed();
let mainStatus: Activity; let mainStatus: Activity;
if (member.activities[0].type === 4) { if (member.activities[0].type === ActivityType.CUSTOM_STATUS) {
mainStatus = member.activities[1]; mainStatus = member.activities[1];
embed.setDescription(`*${member.activities[0].state}*`); embed.setDescription(`*${member.activities[0].state}*`);
} else { } else {
mainStatus = member.activities[0]; mainStatus = member.activities[0];
} }
embed.setAuthor(member.user.username, member.user.avatarURL); embed.setAuthor(member.user.username, member.user.avatarURL);
if (mainStatus.type === 4) { if (mainStatus.type === ActivityType.LISTENING) {
embed.setTitle('Spotify'); embed.setTitle('Spotify');
embed.setColor('#1ed760'); embed.setColor('#1ed760');
embed.addField('Song', mainStatus.details, true); embed.addField('Song', mainStatus.details, true);