diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2022-03-30 22:01:18 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2022-03-30 22:01:18 -0400 |
| commit | daf3c1735513bb252614a0047116088e242f7984 (patch) | |
| tree | c72d573c342b76580d24ca19888150dca94b62bc /AudioBackend.js | |
| parent | 3f81f1086f46b8e1882ed0827483a22929330be3 (diff) | |
| download | DLAP-daf3c1735513bb252614a0047116088e242f7984.tar.gz DLAP-daf3c1735513bb252614a0047116088e242f7984.tar.bz2 DLAP-daf3c1735513bb252614a0047116088e242f7984.zip | |
Fixed list command; Fixed name on some files
Diffstat (limited to 'AudioBackend.js')
| -rw-r--r-- | AudioBackend.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/AudioBackend.js b/AudioBackend.js index d7b6852..53acc61 100644 --- a/AudioBackend.js +++ b/AudioBackend.js @@ -28,11 +28,11 @@ import { } from '@discordjs/voice' import { MessageEmbed } from 'discord.js' import config from './config.json' assert {type: 'json'} -import fs from 'fs' +import { readdirSync, writeFile } from 'node:fs' export const player = createAudioPlayer(); export let audio; -export let files = fs.readdirSync('music'); +export let files = readdirSync('music'); let fileData; export async function voiceInit(bot) { @@ -52,13 +52,13 @@ export async function voiceInit(bot) { }); player.on('idle', () => { - console.log("Music has finished playing, shuffling the beats...") + console.log("Beat has finished playing, shuffling the beats...") searchAudio(bot); }) await searchAudio(bot); return connection.subscribe(player); - }).catch(e => { console.error("The voice channel does not exist!\\n(Have you looked at your configuration?)") }) + }).catch(e => { console.error(e) }) } export async function searchAudio(bot){ @@ -78,12 +78,13 @@ export async function playAudio(bot) { await player.play(resource); - audio = audio.split('.').slice(0, -1).join('.'); console.log('Now playing: ' + audio); + audio = audio.split('.').slice(0, -1).join('.'); + if (config.txtFile === true) { fileData = "Now Playing: " + audio; - fs.writeFile("./now-playing.txt", fileData, (err) => { + writeFile("./now-playing.txt", fileData, (err) => { if (err) console.log(err); }); @@ -102,7 +103,7 @@ export async function playAudio(bot) { export function destroyAudio(interaction) { if (config.txtFile === true) { fileData = "Now Playing: Nothing"; - fs.writeFile("now-playing.txt", fileData, (err) => { + writeFile("now-playing.txt", fileData, (err) => { if (err) console.log(err); }); |
