Skip to content

Commit

Permalink
Update v0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
DouglasMarq committed May 1, 2021
1 parent 0122084 commit 713f893
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ export default class Events {
this.voice.skipCommand(message);
}

@Command('queue')
private showQueueCommand(message: CommandMessage){
this.voice.showQueueCommand(message);
}

@Command('shuffle')
private shuffleCommand(message: CommandMessage){
this.voice.shuffleCommand(message);
}


//-------------------------- MESSAGE --------------------------
Expand All @@ -85,7 +94,7 @@ export default class Events {
message.reply(`Comando não existente. Digite ${BOT_PREFIX}help`);
}

@Command('Cagaram')
@Command('cagaram')
private cagaramNoEstojoDoLeo(message: CommandMessage){
// message.reply(`Cagaram no estojo do <@243107174186876930> denovo? Q otario haha`);me marca
message.channel.send('Cagaram no estojo do <@243107174186876930> denovo? Q otario haha');
Expand Down
39 changes: 37 additions & 2 deletions src/events/voice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class Voice {

public clearQueueCommand(message: CommandMessage) {
if (!this.whitelist[message.channel.id]) return;
this.queue = [];
this.clearQueueTool();
message.reply('Lista de Música limpa.');
}

Expand Down Expand Up @@ -48,10 +48,30 @@ export default class Voice {
this.queue = this.queue.splice(1);
this.playMusic();
} else {
this.clearQueueTool();
message.member?.voice.channel?.leave();
}
}

public shuffleCommand(message: CommandMessage){
if (!this.whitelist[message.channel.id]) return;
this.queue = this.shuffle(this.queue);
}

public showQueueCommand(message: CommandMessage){
if (!this.whitelist[message.channel.id]) return;
if(this.queue.length < 1) message.reply('Não há itens na fila de musica.');
else {
let text = '';
for(const i in this.queue) {
let iAux = parseInt(i) + 1;
if(iAux === 1) text += `${iAux}. ${this.queue[i]} <---Now Playing\n`
else text += `${iAux}. ${this.queue[i]}\n`;
}
message.channel.send("```" + text + "```");
}
}

public pauseCommand(message: CommandMessage) {
if (!this.whitelist[message.channel.id]) return;
this.player?.dispatcher.pause();
Expand All @@ -66,7 +86,7 @@ export default class Voice {

public nowPlayingCommand(message: CommandMessage) {
if (!this.whitelist[message.channel.id]) return;
// this.dispatcher?.
// to@do
}

public volumeCommand(message: CommandMessage) {
Expand All @@ -79,8 +99,23 @@ export default class Voice {

public leaveVoiceCommand(message: CommandMessage) {
if (!this.whitelist[message.channel.id]) return;
this.clearQueueTool();
message.member?.voice.channel?.leave();
}

private shuffle(a: string[]) {
let aux = a.shift();
for (let i = a.length - 1; i > 0; i--) {
if(i === 0) continue;
const j = Math.floor(Math.random() * (i + 1));
[a[i], a[j]] = [a[j], a[i]];
}
if(aux) a.unshift(aux);
return a;
this.showQueueCommand()
}

private clearQueueTool() {
this.queue = [];
}
}

0 comments on commit 713f893

Please sign in to comment.