Impementing loop
This commit is contained in:
1 parent
79fb6b98da
commit
89383e23c7
3 files changed
+21
-17
No files matched your search
+3
-1
@@ -363,4 +363,6 @@ MigrationBackup/
|
||||
FodyWeavers.xsd
|
||||
|
||||
# typescript restrictions
|
||||
dist/
|
||||
dist/
|
||||
*.js
|
||||
*.js.map
|
||||
+16
-14
@@ -2,11 +2,12 @@ import { design } from "../../config";
|
||||
|
||||
import { ColorResolvable, CommandInteraction, MessageEmbed } from "discord.js";
|
||||
import { MyClient } from "../../types/Client";
|
||||
import { loopOption } from "../../types/Types";
|
||||
|
||||
|
||||
|
||||
export async function run(client: MyClient, ctx: CommandInteraction) {
|
||||
const query = ctx.options.getString("position");
|
||||
const query = ctx.options.getString("option");
|
||||
|
||||
if (ctx.guild === null || query === null)
|
||||
return;
|
||||
@@ -19,22 +20,23 @@ export async function run(client: MyClient, ctx: CommandInteraction) {
|
||||
|
||||
await ctx.deferReply();
|
||||
|
||||
let state: boolean;
|
||||
|
||||
if (!isNaN(Number(query))) {
|
||||
state = await player.jump(Number(query) - 1);
|
||||
} else {
|
||||
state = await player.jump(query);
|
||||
}
|
||||
player.repeat(query as loopOption);
|
||||
|
||||
let embed = new MessageEmbed()
|
||||
.setColor(design.color as ColorResolvable)
|
||||
.setTitle("Could not find track specified.");
|
||||
.setColor(design.color as ColorResolvable);
|
||||
|
||||
if (state) {
|
||||
embed = new MessageEmbed()
|
||||
.setColor(design.color as ColorResolvable)
|
||||
.setTitle("Jumped.");
|
||||
switch (query as loopOption) {
|
||||
case "LOOP": {
|
||||
embed.setTitle("Now looping queue.");
|
||||
break;
|
||||
}
|
||||
case "SONG": {
|
||||
embed.setTitle("Now looping current song.");
|
||||
break;
|
||||
}
|
||||
case "NONE": {
|
||||
embed.setTitle("After queue end player will be destroyed.")
|
||||
}
|
||||
}
|
||||
|
||||
await ctx.editReply({ embeds: [embed] });
|
||||
|
||||
+2
-2
@@ -204,7 +204,7 @@ export class Player {
|
||||
|
||||
async remove(query: number | string): Promise<boolean> {
|
||||
if (typeof query === "number" && query < this.queue.length && query >= 0) {
|
||||
this.queue.splice(query);
|
||||
this.queue.splice(query, 1);
|
||||
if (query === this.queuePosition)
|
||||
await this.play();
|
||||
return true;
|
||||
@@ -213,7 +213,7 @@ export class Player {
|
||||
for (let i = 0; i < this.queue.length; i++) {
|
||||
const track = this.queue[i];
|
||||
if (track.title.toLowerCase().includes(String(query).toLowerCase())) {
|
||||
this.queue.splice(i);
|
||||
this.queue.splice(i, 1);
|
||||
if (i === this.queuePosition)
|
||||
await this.play();
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user