Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion AudioBackend/AudioControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ import { shufflePlaylist, orderPlaylist } from './QueueSystem.js';
import { playAudio, currentTrack, updatePlaylist } from './PlayAudio.js';
import { player } from './VoiceInitialization.js';
import i18next from '../Utilities/i18n.js';
import { resolve, extname, basename } from 'node:path'
const t = i18next.t;

const audioFileExt = ['.mp3', '.flac'];
const { shuffle, repeat } = JSON.parse(readFileSync('./config.json', 'utf-8'));
export const files = readdirSync('music');
export const files = readdirSync('music', { withFileTypes: true, recursive: true })
.filter(file => file.isFile() && audioFileExt.includes(extname(file.name).toLowerCase()))
.map(file => resolve(file.path, file.name));
export let playerState;
export let playerStatus;
export let isAudioStatePaused;
Expand Down
13 changes: 9 additions & 4 deletions AudioBackend/PlayAudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { player } from './VoiceInitialization.js';
import { audioState, files } from './AudioControl.js';
import { integer } from '../Commands/play.js';
import i18next from '../Utilities/i18n.js';
import { resolve, extname, basename } from 'node:path';

const { statusChannel, txtFile } = JSON.parse(readFileSync('./config.json', 'utf-8'));
const t = i18next.t;
Expand All @@ -44,20 +45,24 @@ export let audioAlbum;
export let audioPicture;
export let duration;

const inputFiles = readdirSync('music');
const audioFileExt = ['.mp3', '.flac'];
const inputFiles = await readdirSync('music', { withFileTypes: true, recursive: true })
.filter(file => file.isFile() && audioFileExt.includes(extname(file.name.toLowerCase())))
.map(file => resolve(file.path, file.name));

export async function playAudio(bot) {
const resource = createAudioResource('music/' + audio);
const resource = createAudioResource(audio);
player.play(resource);

console.log(t('nowPlayingFile', { audio }));

audioState(0);
audioPicture = null;

const audioFile = audio;
const audioFile = basename(audio);

try {
const { common, format } = await parseFile('music/' + audio);
const { common, format } = await parseFile(audio);
metadataEmpty = false;
if (common.title && common.artist && common.year && common.album) {
audioTitle = common.title;
Expand Down
2 changes: 1 addition & 1 deletion Commands/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default {
{ name: t('aboutInfo'), value: t('aboutInfoValue') },
{ name: t('aboutBotVersion'), value: `DLAP ${npmPackage.version}` },
{ name: t('aboutCreator'), value: 'Andrew Lee (alee)' }, // Do not remove this since I created this :)
{ name: t('aboutContributors'), value: 'Victor Moraes (Vicktor#7232) (Improving README)\nParlance Translation Team' },
{ name: t('aboutContributors'), value: 'Victor Moraes (Vicktor#7232) (Improving README)\nParlance Translation Team\n\nAizuddin Akmal (AizuddinAkmal) (Improved Dockerfile & Music folder handling)' },
// { name: t('aboutForked'), value: '[your name] (username)' },
{ name: t('aboutFrameworks'), value: `Discord.JS ${version}\nmusic-metadata\ni18next` },
{ name: t('aboutLicense'), value: 'GNU General Public License v3.0' }
Expand Down
24 changes: 17 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
FROM node:alpine AS build
FROM node:latest AS build

WORKDIR /usr/src/bot

RUN apk add --update alpine-sdk libtool autoconf automake python3
RUN apt-get update && apt-get install -y build-essential libtool autoconf automake python3

COPY package.json ./

COPY yarn.lock ./

ENV NODE_ENV production

RUN yarn global add node-gyp

RUN yarn install
RUN yarn install --production

FROM node:21.7.2-bookworm-slim

ENV NODE_ENV production

FROM node:alpine
RUN apt-get update && apt-get install -y dumb-init

USER node

WORKDIR /usr/src/bot

COPY --from=build /usr/src/bot/node_modules ./node_modules
COPY --chown=node:node --from=build /usr/src/bot/node_modules ./node_modules

COPY --chown=node:node . ./

COPY . ./
ENTRYPOINT ["/usr/bin/dumb-init", "--"]

CMD ["node", "bot.js"]
CMD ["bash", "-c", "node deploy-command.js && exec node bot.js"]