aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2022-12-02 22:05:20 -0500
committerAndrew Lee <alee14498@protonmail.com>2022-12-02 22:05:20 -0500
commitc576ed4e454fe6b4974e7ad873670e3adc9d0a96 (patch)
treeae6f06f8f21f78d5023019b64772f484f5377fb7
parente0fe64b06c0eb8b92578ae1bf5a166f8d633c9b3 (diff)
downloadDLAP-c576ed4e454fe6b4974e7ad873670e3adc9d0a96.tar.gz
DLAP-c576ed4e454fe6b4974e7ad873670e3adc9d0a96.tar.bz2
DLAP-c576ed4e454fe6b4974e7ad873670e3adc9d0a96.zip
Fixes to various things
-rw-r--r--backend/AudioControl.js2
-rw-r--r--backend/PlayAudio.js11
-rw-r--r--backend/Shutdown.js2
-rw-r--r--backend/VoiceInitialization.js4
-rw-r--r--bot.js7
-rw-r--r--commands/about.js2
-rw-r--r--commands/list.js2
-rw-r--r--commands/play.js2
8 files changed, 19 insertions, 13 deletions
diff --git a/backend/AudioControl.js b/backend/AudioControl.js
index 216d610..71952c1 100644
--- a/backend/AudioControl.js
+++ b/backend/AudioControl.js
@@ -55,7 +55,7 @@ export async function previousAudio(bot, interaction) {
}
export function toggleAudioState() {
- if (isAudioStatePaused === true) {
+ if (isAudioStatePaused) {
audioState(0);
} else {
audioState(1);
diff --git a/backend/PlayAudio.js b/backend/PlayAudio.js
index 9b4a83b..3ae2b91 100644
--- a/backend/PlayAudio.js
+++ b/backend/PlayAudio.js
@@ -28,14 +28,17 @@ import { integer } from '../commands/play.js';
const { statusChannel, txtFile } = JSON.parse(readFileSync('./config.json', 'utf-8'));
let fileData;
+
export let audio;
-export let duration;
-export let metadataEmpty = false;
+export let currentTrack;
+
+export let metadataEmpty;
+
export let audioTitle;
export let audioArtist;
export let audioYear;
export let audioAlbum;
-export let currentTrack;
+export let duration;
const inputFiles = readdirSync('music');
export async function playAudio(bot) {
@@ -66,7 +69,7 @@ export async function playAudio(bot) {
audio = audio.split('.').slice(0, -1).join('.');
- if (txtFile === true) {
+ if (txtFile) {
fileData = 'Now Playing: ' + audio;
writeFile('./now-playing.txt', fileData, (err) => {
if (err) { console.log(err); }
diff --git a/backend/Shutdown.js b/backend/Shutdown.js
index 641ca1e..e1c1d26 100644
--- a/backend/Shutdown.js
+++ b/backend/Shutdown.js
@@ -28,7 +28,7 @@ const { statusChannel, txtFile } = JSON.parse(readFileSync('./config.json', 'utf
let fileData;
export async function destroyAudio(interaction) {
- if (txtFile === true) {
+ if (txtFile) {
fileData = 'Now Playing: Nothing';
writeFile('now-playing.txt', fileData, (err) => {
if (err) { console.log(err); }
diff --git a/backend/VoiceInitialization.js b/backend/VoiceInitialization.js
index 61d4734..d95bfa6 100644
--- a/backend/VoiceInitialization.js
+++ b/backend/VoiceInitialization.js
@@ -33,6 +33,10 @@ export async function voiceInit(bot) {
adapterCreator: channel.guild.voiceAdapterCreator
});
+ connection.on(VoiceConnectionStatus.Connecting, () => {
+ console.log(`Connecting to ${channel.name}...`);
+ });
+
connection.on(VoiceConnectionStatus.Ready, async() => {
console.log('Ready to blast some beats!');
return (shuffle === true) ? await shufflePlaylist(bot) : await orderPlaylist(bot);
diff --git a/bot.js b/bot.js
index 988ebb3..c53d40f 100644
--- a/bot.js
+++ b/bot.js
@@ -22,8 +22,7 @@ import { Client, GatewayIntentBits, EmbedBuilder, Collection, version, Interacti
import { voiceInit } from './backend/VoiceInitialization.js';
import { readdirSync, readFileSync } from 'node:fs';
// import config from './config.json' assert { type: 'json' } Not supported by ESLint yet
-const { token, statusChannel, voiceChannel, shuffle } = JSON.parse(readFileSync('./config.json', 'utf-8'));
-
+const { token, statusChannel, voiceChannel, shuffle, presenceActivity } = JSON.parse(readFileSync('./config.json', 'utf-8'));
const bot = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildVoiceStates] });
bot.login(token);
@@ -49,12 +48,12 @@ bot.once('ready', async() => {
console.log(`Running on Discord.JS ${version}`);
console.log(`Voice Channel: ${voiceChannel}`);
console.log(`Status Channel: ${statusChannel}`);
- console.log(`Shuffle enabled: ${shuffle}`);
+ console.log(`Shuffle Enabled: ${shuffle}`);
// Set bots' presence
bot.user.setPresence({
activities: [{
- name: 'some beats',
+ name: presenceActivity,
type: 'LISTENING'
}],
status: 'online'
diff --git a/commands/about.js b/commands/about.js
index e102a3e..23c750e 100644
--- a/commands/about.js
+++ b/commands/about.js
@@ -22,7 +22,7 @@
import { EmbedBuilder, version, ActionRowBuilder, ButtonBuilder, ButtonStyle, SlashCommandBuilder } from 'discord.js';
// import npmPackage from '../package.json' assert { type:'json' }
import { readFileSync } from 'node:fs';
-const npmPackage = JSON.parse(readFileSync('./package.json'));
+const npmPackage = JSON.parse(readFileSync('./package.json', 'utf-8'));
export default {
data: new SlashCommandBuilder()
diff --git a/commands/list.js b/commands/list.js
index 05d40c6..8eddcda 100644
--- a/commands/list.js
+++ b/commands/list.js
@@ -20,7 +20,7 @@
***************************************************************************/
import { SlashCommandBuilder } from 'discord.js';
-import { readdirSync, readdir } from 'fs';
+import { readdirSync, readdir } from 'node:fs';
const musicFolder = './music';
diff --git a/commands/play.js b/commands/play.js
index 3b226ec..4c95ab8 100644
--- a/commands/play.js
+++ b/commands/play.js
@@ -48,7 +48,7 @@ export default {
return await interaction.reply({ content: 'Number is too big, choose a number that\'s less than ' + files.length + '.', ephemeral: true });
}
}
- if (isAudioStatePaused === true) {
+ if (isAudioStatePaused) {
toggleAudioState();
return await interaction.reply({ content: 'Resuming music', ephemeral: true });
} else {