Skip to content

Commit

Permalink
add: doxygen info to loop and shuffle;update: README.md
Browse files Browse the repository at this point in the history
This commit adds doxygen information to loop and shuffle functions and updates README.md to follow our newest coding style.
  • Loading branch information
ThePedroo committed Jan 14, 2024
1 parent 91bb6d0 commit 0b19504
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ client.on('messageCreate', async (message) => {
const commandName = message.content.split(' ')[0].toLowerCase().substring(prefix.length)
const args = message.content.split(' ').slice(1).join(' ')

if (commandName == 'decodetrack') {
if (commandName === 'decodetrack') {
const player = new FastLink.player.Player(message.guild.id)

if (player.playerCreated() === false) {
Expand All @@ -83,10 +83,10 @@ client.on('messageCreate', async (message) => {
return;
}

if (commandName == 'record') {
if (commandName === 'record') {
const player = new FastLink.player.Player(message.guild.id)

if (player.playerCreated() == false) {
if (player.playerCreated() === false) {
message.channel.send('No player found.')

return;
Expand All @@ -105,10 +105,10 @@ client.on('messageCreate', async (message) => {
message.channel.send('Started recording. Be aware: This will record everything you say in the voice channel, even if the bot is deaf. Server deaf the bot if you don\'t want to be recorded by any chances.')
}

if (commandName == 'stoprecord') {
if (commandName === 'stoprecord') {
const player = new FastLink.player.Player(message.guild.id)

if (player.playerCreated() == false) {
if (player.playerCreated() === false) {
message.channel.send('No player found.')

return;
Expand All @@ -119,7 +119,7 @@ client.on('messageCreate', async (message) => {
message.channel.send('Stopped recording.')
}

if (commandName == 'play') {
if (commandName === 'play') {
if (!message.member.voice.channel) {
message.channel.send('You must be in a voice channel.')

Expand Down Expand Up @@ -178,7 +178,7 @@ client.on('messageCreate', async (message) => {
return;
}

if (track.loadType == 'search') {
if (track.loadType === 'search') {
player.update({
track: {
encoded: track.data[0].encoded
Expand All @@ -191,7 +191,7 @@ client.on('messageCreate', async (message) => {
}
}

if (commandName == 'volume') {
if (commandName === 'volume') {
const player = new FastLink.player.Player(message.guild.id)

if (player.playerCreated() === false) {
Expand All @@ -209,7 +209,7 @@ client.on('messageCreate', async (message) => {
return;
}

if (commandName == 'pause') {
if (commandName === 'pause') {
const player = new FastLink.player.Player(message.guild.id)

if (player.playerCreated() === false) {
Expand All @@ -225,7 +225,7 @@ client.on('messageCreate', async (message) => {
return;
}

if (commandName == 'resume') {
if (commandName === 'resume') {
const player = new FastLink.player.Player(message.guild.id)

if (player.playerCreated() === false) {
Expand All @@ -241,7 +241,7 @@ client.on('messageCreate', async (message) => {
return;
}

if (commandName == 'skip') {
if (commandName === 'skip') {
const player = new FastLink.player.Player(message.guild.id)

if (player.playerCreated() === false) {
Expand All @@ -258,7 +258,7 @@ client.on('messageCreate', async (message) => {
return;
}

if (commandName == 'stop') {
if (commandName === 'stop') {
const player = new FastLink.player.Player(message.guild.id)

if (player.playerCreated() === false) {
Expand Down
25 changes: 16 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,27 +348,34 @@ class Player {
return Players[this.guildId].queue
}

loop() {
/**
* Sets the loop state of the player.
*
* @param loop The loop state to set.
* @return The loop state of the player.
*/
loop(loop) {
if (!Config.queue) throw new Error('Queue is disabled.')

let loop = null
switch (Players[this.guildId].loop){
case 'track': loop = 'track'; break;
case 'queue': loop = 'queue'; break;
case 'off': loop = 'off'; break;
default: throw new Error('Invalid option. Available options: track, queue, off')
}
if (![ 'track', 'queue', null ].includes(loop))
throw new Error('Loop must be track, queue, or null.')

return Players[this.guildId].loop = loop
}

/**
* Shuffles the queue of tracks.
*
* @return The shuffled queue of tracks, or false if there are less than 3 tracks in the queue.
* @throws Error If the queue is disabled.
*/
shuffle() {
if (!Config.queue) throw new Error('Queue is disabled.')

if (Players[this.guildId].queue.length < 3)
return false

PLayers[this.guild].queue.forEach((_, i) => {
Players[this.guildId].queue.forEach((_, i) => {
const j = Math.floor(Math.random() * (i + 1))
const temp = Players[this.guildId].queue[i]
Players[this.guildId].queue[i] = Players[this.guildId].queue[j]
Expand Down

0 comments on commit 0b19504

Please sign in to comment.