diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2022-12-02 22:05:20 -0500 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2022-12-02 22:05:20 -0500 |
| commit | c576ed4e454fe6b4974e7ad873670e3adc9d0a96 (patch) | |
| tree | ae6f06f8f21f78d5023019b64772f484f5377fb7 | |
| parent | e0fe64b06c0eb8b92578ae1bf5a166f8d633c9b3 (diff) | |
| download | DLAP-c576ed4e454fe6b4974e7ad873670e3adc9d0a96.tar.gz DLAP-c576ed4e454fe6b4974e7ad873670e3adc9d0a96.tar.bz2 DLAP-c576ed4e454fe6b4974e7ad873670e3adc9d0a96.zip | |
Fixes to various things
| -rw-r--r-- | backend/AudioControl.js | 2 | ||||
| -rw-r--r-- | backend/PlayAudio.js | 11 | ||||
| -rw-r--r-- | backend/Shutdown.js | 2 | ||||
| -rw-r--r-- | backend/VoiceInitialization.js | 4 | ||||
| -rw-r--r-- | bot.js | 7 | ||||
| -rw-r--r-- | commands/about.js | 2 | ||||
| -rw-r--r-- | commands/list.js | 2 | ||||
| -rw-r--r-- | commands/play.js | 2 |
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); @@ -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 { |
