Skip to content

Commit

Permalink
Merge pull request #23 from FAYStarNext/dev
Browse files Browse the repository at this point in the history
Remove lodash
  • Loading branch information
EvarinDev authored Aug 3, 2024
2 parents 2a98d41 + 5b86800 commit f3cb9f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sunday.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"version": "1.0.14-indev",
"version": "1.0.15-indev",
"description": "Sunday a lavalink wrapper",
"license": "MIT",
"author": "FAYStarNext",
Expand Down Expand Up @@ -48,4 +48,4 @@
"wrapper",
"api"
]
}
}
17 changes: 11 additions & 6 deletions src/structures/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Manager, SearchQuery, SearchResult } from "./Manager";
import { Node } from "./Node";
import { Queue } from "./Queue";
import { Sizes, State, Structure, TrackSourceName, TrackUtils, VoiceState } from "./Utils";
import * as _ from "lodash";
import playerCheck from "../utils/playerCheck";
import { ClientUser, Message, User } from "discord.js";

Expand Down Expand Up @@ -235,8 +234,8 @@ export class Player {
const finalOptions = playOptions
? playOptions
: ["startTime", "endTime", "noReplace"].every((v) => Object.keys(optionsOrTrack || {}).includes(v))
? (optionsOrTrack as PlayOptions)
: {};
? (optionsOrTrack as PlayOptions)
: {};

if (TrackUtils.isUnresolvedTrack(this.queue.current)) {
try {
Expand Down Expand Up @@ -343,7 +342,6 @@ export class Player {
this.manager.emit("PlayerStateUpdate", oldPlayer, this);
return this;
}

/**
* Sets the queue to repeat and shuffles the queue after each song.
* @param repeat "true" or "false".
Expand All @@ -364,10 +362,17 @@ export class Player {
this.trackRepeat = false;
this.queueRepeat = false;
this.dynamicRepeat = true;

function shuffleArray(array: Queue): Queue[] {
// Shuffle the array
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return [array];
}
this.dynamicLoopInterval = setInterval(() => {
if (!this.dynamicRepeat) return;
const shuffled = _.shuffle(this.queue);
const shuffled = shuffleArray(this.queue);
this.queue.clear();
shuffled.forEach((track) => {
this.queue.add(track);
Expand Down

0 comments on commit f3cb9f2

Please sign in to comment.