Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
feat!: Moved source into /src folder
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusbegby committed Jul 16, 2023
1 parent 6d182c6 commit ee274fe
Show file tree
Hide file tree
Showing 20 changed files with 63 additions and 37 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
/config.json
/.env
/app-*.log
/logs
/logs/app-*.log
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node ./index.js",
"start-pretty": "node ./index.js | pino-pretty",
"deploy": "node ./deploy-commands.js && node ./deploy-system-commands.js",
"deploy-pretty": "node ./deploy-commands.js | pino-pretty && node ./deploy-system-commands.js | pino-pretty",
"start": "node ./src/index.js",
"start-pretty": "node ./src/index.js | pino-pretty",
"deploy": "node ./src/deploy-commands.js && node ./src/deploy-system-commands.js",
"deploy-pretty": "node ./src/deploy-commands.js | pino-pretty && node ./src/deploy-system-commands.js | pino-pretty",
"eslint": "eslint ./"
},
"dependencies": {
Expand Down
3 changes: 2 additions & 1 deletion commands/filters.js → src/commands/filters.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const path = require('path');
const { SlashCommandBuilder } = require('@discordjs/builders');
const { useQueue } = require('discord-player');
const {
Expand All @@ -12,7 +13,7 @@ const {
embedIcons,
filterList,
filterThreadAmount
} = require('../config.json');
} = require(path.resolve('./config.json'));

module.exports = {
data: new SlashCommandBuilder()
Expand Down
3 changes: 2 additions & 1 deletion commands/help.js → src/commands/help.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path');
const { SlashCommandBuilder } = require('@discordjs/builders');
const { EmbedBuilder } = require('discord.js');
const { embedColors, embedIcons, botInfo } = require('../config.json');
const { embedColors, embedIcons, botInfo } = require(path.resolve('./config.json'));

module.exports = {
data: new SlashCommandBuilder()
Expand Down
3 changes: 2 additions & 1 deletion commands/leave.js → src/commands/leave.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const path = require('path');
const { SlashCommandBuilder } = require('@discordjs/builders');
const { useQueue } = require('discord-player');
const { EmbedBuilder } = require('discord.js');
const { embedColors, embedIcons } = require('../config.json');
const { embedColors, embedIcons } = require(path.resolve('./config.json'));

module.exports = {
data: new SlashCommandBuilder()
Expand Down
3 changes: 2 additions & 1 deletion commands/loop.js → src/commands/loop.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const path = require('path');
const { SlashCommandBuilder } = require('@discordjs/builders');
const { useQueue } = require('discord-player');
const { EmbedBuilder } = require('discord.js');
const { embedColors, embedIcons, botInfo } = require('../config.json');
const { embedColors, embedIcons, botInfo } = require(path.resolve('./config.json'));

module.exports = {
data: new SlashCommandBuilder()
Expand Down
3 changes: 2 additions & 1 deletion commands/nowplaying.js → src/commands/nowplaying.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const path = require('path');
const { SlashCommandBuilder } = require('@discordjs/builders');
const { useQueue } = require('discord-player');
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder } = require('discord.js');
const {
embedColors,
embedIcons,
progressBarOptions
} = require('../config.json');
} = require(path.resolve('./config.json'));

module.exports = {
data: new SlashCommandBuilder()
Expand Down
3 changes: 2 additions & 1 deletion commands/pause.js → src/commands/pause.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const path = require('path');
const { SlashCommandBuilder } = require('@discordjs/builders');
const { useQueue } = require('discord-player');
const { EmbedBuilder } = require('discord.js');
const { embedColors, embedIcons } = require('../config.json');
const { embedColors, embedIcons } = require(path.resolve('./config.json'));

module.exports = {
data: new SlashCommandBuilder()
Expand Down
3 changes: 2 additions & 1 deletion commands/play.js → src/commands/play.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const path = require('path');
const { SlashCommandBuilder } = require('@discordjs/builders');
const { useMainPlayer, useQueue } = require('discord-player');
const { EmbedBuilder } = require('discord.js');
Expand All @@ -6,7 +7,7 @@ const {
embedIcons,
playerOptions,
botInfo
} = require('../config.json');
} = require(path.resolve('./config.json'));

module.exports = {
data: new SlashCommandBuilder()
Expand Down
3 changes: 2 additions & 1 deletion commands/queue.js → src/commands/queue.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const path = require('path');
const { SlashCommandBuilder } = require('@discordjs/builders');
const { useQueue } = require('discord-player');
const { EmbedBuilder } = require('discord.js');
const {
embedColors,
embedIcons,
progressBarOptions
} = require('../config.json');
} = require(path.resolve('./config.json'));

module.exports = {
data: new SlashCommandBuilder()
Expand Down
3 changes: 2 additions & 1 deletion commands/remove.js → src/commands/remove.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const path = require('path');
const { SlashCommandBuilder } = require('@discordjs/builders');
const { useQueue } = require('discord-player');
const { EmbedBuilder } = require('discord.js');
const { embedColors, embedIcons } = require('../config.json');
const { embedColors, embedIcons } = require(path.resolve('./config.json'));

module.exports = {
data: new SlashCommandBuilder()
Expand Down
3 changes: 2 additions & 1 deletion commands/seek.js → src/commands/seek.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const path = require('path');
const { SlashCommandBuilder } = require('@discordjs/builders');
const { useQueue } = require('discord-player');
const { EmbedBuilder } = require('discord.js');
const { embedColors, embedIcons } = require('../config.json');
const { embedColors, embedIcons } = require(path.resolve('./config.json'));

module.exports = {
data: new SlashCommandBuilder()
Expand Down
3 changes: 2 additions & 1 deletion commands/skip.js → src/commands/skip.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const path = require('path');
const { SlashCommandBuilder } = require('@discordjs/builders');
const { useQueue } = require('discord-player');
const { EmbedBuilder } = require('discord.js');
const { embedColors, embedIcons } = require('../config.json');
const { embedColors, embedIcons } = require(path.resolve('./config.json'));

module.exports = {
data: new SlashCommandBuilder()
Expand Down
3 changes: 2 additions & 1 deletion commands/volume.js → src/commands/volume.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const path = require('path');
const { SlashCommandBuilder } = require('@discordjs/builders');
const { useQueue } = require('discord-player');
const { EmbedBuilder } = require('discord.js');
const { embedColors, embedIcons } = require('../config.json');
const { embedColors, embedIcons } = require(path.resolve('./config.json'));

module.exports = {
data: new SlashCommandBuilder()
Expand Down
7 changes: 4 additions & 3 deletions deploy-commands.js → src/deploy-commands.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
const path = require('path');
const fs = require('node:fs');
const logger = require('./services/logger.js');
const logger = require(path.resolve('./src/services/logger.js'));
const { REST, Routes } = require('discord.js');
require('dotenv').config();

const commands = [];
const commandFiles = fs
.readdirSync('./commands')
.readdirSync(path.resolve('./src/commands'))
.filter((file) => file.endsWith('.js'));

for (const file of commandFiles) {
const command = require(`./commands/${file}`);
const command = require(path.resolve(`./src/commands/${file}`));
commands.push(command.data.toJSON());
}

Expand Down
9 changes: 5 additions & 4 deletions deploy-system-commands.js → src/deploy-system-commands.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
const path = require('path');
const fs = require('node:fs');
const logger = require('./services/logger.js');
const logger = require(path.resolve('./src/services/logger.js'));
const { REST, Routes } = require('discord.js');
const { systemServerGuildIds } = require('./config.json');
const { systemServerGuildIds } = require(path.resolve('./config.json'));
require('dotenv').config();

const systemCommands = [];
const systemCommandFiles = fs
.readdirSync('./system-commands')
.readdirSync(path.resolve('./src/system-commands'))
.filter((file) => file.endsWith('.js'));

for (const file of systemCommandFiles) {
const systemCommand = require(`./system-commands/${file}`);
const systemCommand = require(path.resolve(`./src/system-commands/${file}`));
systemCommands.push(systemCommand.data.toJSON());
}

Expand Down
21 changes: 13 additions & 8 deletions index.js → src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
const fs = require('node:fs');
const path = require('path');
const Discord = require('discord.js');
const logger = require('./services/logger.js');
const logger = require(path.resolve('./src/services/logger.js'));
const { EmbedBuilder } = require('discord.js');
const { Player, onBeforeCreateStream } = require('discord-player');
const { stream } = require('yt-stream');
const { embedColors, embedIcons, botInfo } = require('./config.json');
const { embedColors, embedIcons, botInfo } = require(path.resolve(
'./config.json'
));
require('dotenv').config();

// Setup required permissions for the bot to work
Expand All @@ -19,18 +22,20 @@ const client = new Discord.Client({
// todo: extract this logic to a separate file
client.commands = new Discord.Collection();
const commandFiles = fs
.readdirSync('./commands')
.readdirSync(path.resolve('./src/commands'))
.filter((file) => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
const command = require(path.resolve(`./src/commands/${file}`));
client.commands.set(command.data.name, command);
}

const systemCommandFiles = fs
.readdirSync('./system-commands')
.readdirSync(path.resolve('./src/system-commands'))
.filter((file) => file.endsWith('.js'));
for (const file of systemCommandFiles) {
const systemCommand = require(`./system-commands/${file}`);
const systemCommand = require(path.resolve(
`./src/system-commands/${file}`
));
client.commands.set(systemCommand.data.name, systemCommand);
}

Expand Down Expand Up @@ -64,11 +69,11 @@ onBeforeCreateStream(async (track) => {

if (process.env.NODE_ENV === 'development') {
player.on('debug', (message) => {
logger.debug(`player debug event: ${message}`);
logger.debug(message);
});

player.events.on('debug', (message) => {
logger.trace(`player queue debug event: ${message}`);
logger.trace(message);
});
}

Expand Down
9 changes: 6 additions & 3 deletions services/logger.js → src/services/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const transport = pino.transport({
target: 'pino/file',
level: process.env.MINIMUM_LOG_LEVEL,
options: {
destination: './app-all.log',
destination: './logs/app-all.log',
mkdir: true,
sync: false,
minLength: 4096
}
Expand All @@ -16,7 +17,8 @@ const transport = pino.transport({
target: 'pino/file',
level: 'info',
options: {
destination: './app-info.log',
destination: './logs/app-info.log',
mkdir: true,
sync: false,
minLength: 4096
}
Expand All @@ -25,7 +27,8 @@ const transport = pino.transport({
target: 'pino/file',
level: 'error',
options: {
destination: './app-error.log',
destination: './logs/app-error.log',
mkdir: true,
sync: false
}
},
Expand Down
3 changes: 2 additions & 1 deletion system-commands/guilds.js → src/system-commands/guilds.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const path = require('path');
const { SlashCommandBuilder } = require('@discordjs/builders');
const { EmbedBuilder } = require('discord.js');
const {
embedColors,
embedIcons,
systemServerGuildIds
} = require('../config.json');
} = require(path.resolve('./config.json'));

module.exports = {
data: new SlashCommandBuilder()
Expand Down
5 changes: 3 additions & 2 deletions system-commands/status.js → src/system-commands/status.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const path = require('path');
const { SlashCommandBuilder } = require('@discordjs/builders');
const { EmbedBuilder } = require('discord.js');
const { useQueue } = require('discord-player');
const {
embedColors,
embedIcons,
systemServerGuildIds
} = require('../config.json');
} = require(path.resolve('./config.json'));
const osu = require('node-os-utils');
const packageJson = require('../package.json');
const packageJson = require(path.resolve('./package.json'));

module.exports = {
data: new SlashCommandBuilder()
Expand Down

0 comments on commit ee274fe

Please sign in to comment.