Skip to content

Commit

Permalink
refactor(Song): Song#id is mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
skick1234 committed Jun 11, 2024
1 parent aa10cc3 commit 9085236
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/core/manager/DisTubeVoiceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { VoiceBasedChannel } from "discord.js";
export class DisTubeVoiceManager extends GuildIdManager<DisTubeVoice> {
/**
* Create a {@link DisTubeVoice} instance
* @param channel - A voice channel to join
* @param channel - A voice chann el to join
*/
create(channel: VoiceBasedChannel): DisTubeVoice {
const existing = this.get(channel.guildId);
Expand Down
8 changes: 3 additions & 5 deletions src/core/manager/QueueManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@ export class QueueManager extends GuildIdManager<Queue> {
* @param queue - Queue
*/
#emitPlaySong(queue: Queue): boolean {
return (
!this.options.emitNewSongOnly ||
(queue.repeatMode === RepeatMode.SONG && queue._next) ||
(queue.repeatMode !== RepeatMode.SONG && queue.songs[0]?.id !== queue.songs[1]?.id)
);
if (!this.options.emitNewSongOnly) return true;
if (queue.repeatMode === RepeatMode.SONG) return queue._next || queue._prev;
return queue.songs[0].id !== queue.songs[1].id;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/struct/Song.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Song<T = unknown> {
/**
* Song ID.
*/
id?: string;
id: string;
/**
* Song name.
*/
Expand Down
3 changes: 1 addition & 2 deletions src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ export interface SongInfo {
plugin: DisTubePlugin | null;
source: string;
playFromSource: boolean;
streamURL?: string;
id?: string;
id: string;
name?: string;
isLive?: boolean;
duration?: number;
Expand Down

0 comments on commit 9085236

Please sign in to comment.