aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2024-02-15 17:18:15 -0500
committerAndrew Lee <alee14498@protonmail.com>2024-02-15 17:20:59 -0500
commitd98937b34bbb7582f4c13e0d18bcc30febe1d174 (patch)
tree04133cf911474c50674084b58a65361bf8990a35
parent16b7fb29fb5bd01f346749020dc43fa24a16993f (diff)
downloadDLAP-d98937b34bbb7582f4c13e0d18bcc30febe1d174.tar.gz
DLAP-d98937b34bbb7582f4c13e0d18bcc30febe1d174.tar.bz2
DLAP-d98937b34bbb7582f4c13e0d18bcc30febe1d174.zip
Finally fixed some issues
- Voting should work properly? - Now the bot tells the user if they are already in vc - Thumbnails will be null when switching tracks
-rw-r--r--AudioBackend/PlayAudio.js1
-rw-r--r--Commands/join.js5
-rw-r--r--Commands/leave.js2
-rw-r--r--Commands/pause.js14
-rw-r--r--Commands/play.js16
-rw-r--r--Locales/en/translation.json3
-rw-r--r--Utilities/Voting.js2
7 files changed, 31 insertions, 12 deletions
diff --git a/AudioBackend/PlayAudio.js b/AudioBackend/PlayAudio.js
index a0cfb39..d671e5a 100644
--- a/AudioBackend/PlayAudio.js
+++ b/AudioBackend/PlayAudio.js
@@ -52,6 +52,7 @@ export async function playAudio(bot) {
console.log(t('nowPlayingFile', { audio }));
audioState(0);
+ audioPicture = null;
const audioFile = audio;
diff --git a/Commands/join.js b/Commands/join.js
index 2f513cf..dd49969 100644
--- a/Commands/join.js
+++ b/Commands/join.js
@@ -23,6 +23,7 @@ import { SlashCommandBuilder } from 'discord.js';
import { voiceInit } from '../AudioBackend/VoiceInitialization.js';
import { PermissionFlagsBits } from 'discord-api-types/v10';
import { readFileSync } from 'node:fs';
+import { getVoiceConnection } from '@discordjs/voice';
import i18next from '../Utilities/i18n.js';
const { djRole, ownerID } = JSON.parse(readFileSync('./config.json', 'utf-8'));
const t = i18next.t;
@@ -34,6 +35,10 @@ export default {
if (!interaction.member.voice.channel) return await interaction.reply({ content: t('voicePermission'), ephemeral: true });
if (!interaction.member.roles.cache.has(djRole) && interaction.user.id !== ownerID && !interaction.memberPermissions.has(PermissionFlagsBits.ManageGuild)) return interaction.reply({ content: t('rolePermission'), ephemeral: true });
+ const connection = getVoiceConnection(interaction.guild.id);
+ if (connection) {
+ return await interaction.reply({ content: t('alreadyJoin'), ephemeral: true });
+ }
await interaction.reply({ content: t('joinVoice'), ephemeral: true });
return await voiceInit(bot);
}
diff --git a/Commands/leave.js b/Commands/leave.js
index e6559ca..c78cfe0 100644
--- a/Commands/leave.js
+++ b/Commands/leave.js
@@ -24,6 +24,7 @@ import { destroyAudio } from '../AudioBackend/Shutdown.js';
import { PermissionFlagsBits } from 'discord-api-types/v10';
import { readFileSync } from 'node:fs';
import i18next from '../Utilities/i18n.js';
+import { playerStatus } from '../AudioBackend/AudioControl.js';
const { djRole, ownerID } = JSON.parse(readFileSync('./config.json', 'utf-8'));
const t = i18next.t;
export default {
@@ -33,6 +34,7 @@ export default {
async execute(interaction, bot) {
if (!interaction.member.voice.channel) return await interaction.reply({ content: t('voicePermission'), ephemeral: true });
if (!interaction.member.roles.cache.has(djRole) && interaction.user.id !== ownerID && !interaction.memberPermissions.has(PermissionFlagsBits.ManageGuild)) return interaction.reply({ content: t('rolePermission'), ephemeral: true });
+ if (playerStatus === 2) return await interaction.reply({ content: t('alreadyLeave'), ephemeral: true });
console.log(t('leaveVoice'));
await destroyAudio(interaction);
diff --git a/Commands/pause.js b/Commands/pause.js
index bc649a6..1d04404 100644
--- a/Commands/pause.js
+++ b/Commands/pause.js
@@ -20,7 +20,7 @@
***************************************************************************/
import { SlashCommandBuilder } from 'discord.js';
-import { toggleAudioState, isAudioStatePaused } from '../AudioBackend/AudioControl.js';
+import { toggleAudioState, isAudioStatePaused, playerStatus } from '../AudioBackend/AudioControl.js';
import { PermissionFlagsBits } from 'discord-api-types/v10';
import { readFileSync } from 'node:fs';
import i18next from '../Utilities/i18n.js';
@@ -34,11 +34,15 @@ export default {
if (!interaction.member.voice.channel) return await interaction.reply({ content: t('voicePermission'), ephemeral: true });
if (!interaction.member.roles.cache.has(djRole) && interaction.user.id !== ownerID && !interaction.memberPermissions.has(PermissionFlagsBits.ManageGuild)) return interaction.reply({ content: t('rolePermission'), ephemeral: true });
- if (!isAudioStatePaused) {
- toggleAudioState();
- return await interaction.reply({ content: t('pausingMusic'), ephemeral: true });
+ if (playerStatus === 2) {
+ return await interaction.reply({ content: t('alreadyLeave'), ephemeral: true });
} else {
- return await interaction.reply({ content: t('pausedAlready'), ephemeral: true });
+ if (!isAudioStatePaused) {
+ toggleAudioState();
+ return await interaction.reply({ content: t('pausingMusic'), ephemeral: true });
+ } else {
+ return await interaction.reply({ content: t('pausedAlready'), ephemeral: true });
+ }
}
}
};
diff --git a/Commands/play.js b/Commands/play.js
index 7cfe36b..d514cfe 100644
--- a/Commands/play.js
+++ b/Commands/play.js
@@ -21,7 +21,7 @@
import { SlashCommandBuilder } from 'discord.js';
import { inputAudio } from '../AudioBackend/QueueSystem.js';
-import { files, isAudioStatePaused, toggleAudioState } from '../AudioBackend/AudioControl.js';
+import { files, isAudioStatePaused, playerStatus, toggleAudioState } from '../AudioBackend/AudioControl.js';
import { audio } from '../AudioBackend/PlayAudio.js';
import { PermissionFlagsBits } from 'discord-api-types/v10';
import { readFileSync } from 'node:fs';
@@ -51,16 +51,20 @@ export default {
if (integer < files.length) {
await inputAudio(bot, integer);
await votes.clear();
- return await interaction.reply({ content: t('nowPlayingFile', audio), ephemeral: true });
+ return await interaction.reply({ content: t('nowPlayingFile', { audio }), ephemeral: true });
} else {
return await interaction.reply({ content: t('numBig', { files: files.length }), ephemeral: true });
}
}
- if (isAudioStatePaused) {
- toggleAudioState();
- return await interaction.reply({ content: t('resumingMusic'), ephemeral: true });
+ if (playerStatus === 2) {
+ return await interaction.reply({ content: t('statusStopped'), ephemeral: true });
} else {
- return await interaction.reply({ content: t('resumedAlready'), ephemeral: true });
+ if (isAudioStatePaused) {
+ toggleAudioState();
+ return await interaction.reply({ content: t('resumingMusic'), ephemeral: true });
+ } else {
+ return await interaction.reply({ content: t('resumedAlready'), ephemeral: true });
+ }
}
}
};
diff --git a/Locales/en/translation.json b/Locales/en/translation.json
index 04b6acc..aa42b78 100644
--- a/Locales/en/translation.json
+++ b/Locales/en/translation.json
@@ -62,6 +62,9 @@
"numBig": "Number is too big, choose a number that's less than {{files}}.",
"resumingMusic": "Resuming music",
"resumedAlready": "Music is already playing",
+ "statusStopped": "Music is currently not playing",
+ "alreadyLeave": "Already left the voice chat",
+ "alreadyJoin": "Already joined the voice chat",
"reshufflePlaylist": "Reshuffling the playlist...",
"reshuffleDisabled": "Shuffle mode is disabled, enable it in the configuration file to access this command.",
"playlistDone": "Playlist Finished",
diff --git a/Utilities/Voting.js b/Utilities/Voting.js
index 5bea29c..0d986b8 100644
--- a/Utilities/Voting.js
+++ b/Utilities/Voting.js
@@ -60,7 +60,7 @@ export async function voteSkip(interaction, bot) {
const members = voiceChannel.members.filter(m => !votes.has(m.id));
// Calculate the number of votes required to skip the audio track
- const votesRequired = Math.ceil((members.size - votes.size) / 2);
+ const votesRequired = Math.ceil(members.size / 2);
// Check if the message author has already voted
if (votes.has(interaction.user.id)) {