Skip to content

Commit

Permalink
Fix null members bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kira0x1 committed Nov 15, 2021
1 parent 8e88ab8 commit d53cde6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/commands/admin/players.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ export const command: Command = {
const queueLength = player.queue.songs.length;
const vc = player.guild.me.voice.channel;

const members = vc?.members;
let membersCount = 0;

if (members) {
membersCount = members.size;
}

let totalDuration = 0;
player.getSongs().map(s => (totalDuration += s.duration.totalSeconds));
totalDuration *= 1000;
Expand All @@ -30,7 +37,7 @@ export const command: Command = {

let field = `server: ${player.guild?.name}\n`;
field += `channel: ${vc?.name}\n`;
field += `members: ${vc.members?.size}\n`;
field += `members: ${membersCount}\n`;
field += `queue: ${queueLength}\n`;
field += `current: ${player.currentlyPlaying?.title}\n`;
field += `duration: ${player.getDurationPretty()}\n`;
Expand Down

0 comments on commit d53cde6

Please sign in to comment.