-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqueue.ts
76 lines (68 loc) · 2.49 KB
/
queue.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { Command } from 'discord-akairo';
import { FieldsEmbed } from 'discord-paginationembed';
import { Message } from 'discord.js';
import { Song } from '../../../typings';
import prettifyMs from '../../util/prettifyMs';
const NOTHING: Song = {
track: null,
info: {
title: 'Nothing to play here',
uri: 'http://erosdev.thegzm.space',
author: 'Ramiel',
length: 817000,
identifier: null,
isSeekable: false,
isStream: false,
position: 0
}
};
export default class QueueCommand extends Command {
constructor () {
super('queue', {
aliases: [ 'queue', 'q', 'nowplaying', 'np' ],
description: { content: 'Shows you the current queue and the current song being played.' },
ratelimit: 1,
channel: 'guild',
args: [
{
id: 'page',
type: 'integer',
default: 1
},
]
});
}
public async exec (message: Message, { page }: { page: number }) {
const myQueue = await this.client.getQueue(message.guild.id);
const currentSong = this.client.music.lavalink.get(message.guild.id);
if (!myQueue.current && !myQueue.tracks.length) {
await this.client.deleteQueue(message.guild.id, false);
return message.util.reply(this.client.dialog('I got nothing on queue, baby\~\~ nothing on queue, baby\~!'));
}
const isCurrentNothing = myQueue.current ? myQueue.current : NOTHING;
const areTracksNothing = myQueue.tracks.length ? myQueue.tracks : [ NOTHING ];
const Pagination = new FieldsEmbed<Song>()
.setArray(areTracksNothing)
.setAuthorizedUsers([ message.author.id ])
.setChannel(message.channel)
.setElementsPerPage(5)
.setPage(page)
.setPageIndicator(true)
.formatField(
'# - Song',
t =>
// tslint:disable-next-line:max-line-length
`**${areTracksNothing.indexOf(t) + 1}** - [**${t.info.title}**](${t.info.uri}) by ${t.info.author} (${prettifyMs(t.info.length)})`
);
Pagination.embed
.setTitle('Now Playing...')
.setDescription([
`[**${isCurrentNothing.info.title}**](${isCurrentNothing.info.uri}) by **${isCurrentNothing.info.author}**`,
// tslint:disable-next-line:max-line-length
`${currentSong ? prettifyMs((currentSong.state as any).position) : 'Not Playing'} / ${prettifyMs(isCurrentNothing.info.length)}`,
`To skip to a song, say \`${this.client.config.prefix}skip <song number>\``,
])
.setColor(0xFE9257);
return Pagination.build();
}
}