feat!: Updated configuration and moved config location

This commit is contained in:
Marius Begby committed 2023-07-18 13:11:15 +02:00
1 parent 2d0df79dac
commit dd4b56ae67
40 files changed
+468 -482

No files matched your search

+11 -14
View File
@@ -1,20 +1,17 @@
const path = require('node:path');
const fs = require('node:fs');
const logger = require(path.resolve('./src/services/logger.js'));
const { REST, Routes } = require('discord.js');
const { systemServerGuildIds } = require(path.resolve('./config.json'));
require('dotenv').config();
const logger = require('../services/logger');
const fs = require('node:fs');
const { REST, Routes } = require('discord.js');
const { systemOptions } = require('../config');
const slashCommands = [];
const systemCommands = [];
const commandFolders = fs.readdirSync(path.resolve('./src/commands'));
const commandFolders = fs.readdirSync('./src/commands');
for (const folder of commandFolders) {
const commandFiles = fs
.readdirSync(path.resolve(`./src/commands/${folder}`))
.filter((file) => file.endsWith('.js'));
const commandFiles = fs.readdirSync(`./src/commands/${folder}`).filter((file) => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(path.resolve(`./src/commands/${folder}/${file}`));
const command = require(`../commands/${folder}/${file}`);
command.isSystemCommand
? systemCommands.push(command.data.toJSON())
: slashCommands.push(command.data.toJSON());
@@ -34,7 +31,7 @@ const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_BOT_TOKEN)
);
logger.info('Started refreshing application (/) bot commands.');
await rest.put(Routes.applicationCommands(process.env.DISCORD_CLIENT_ID), {
await rest.put(Routes.applicationCommands(process.env.DISCORD_APPLICATION_ID), {
body: slashCommands
});
@@ -53,9 +50,9 @@ const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_BOT_TOKEN)
);
logger.info('Started refreshing application (/) system commands.');
for (const systemServerGuildId of systemServerGuildIds) {
logger.info(`Refreshing system commands for guild id ${systemServerGuildId}.`);
await rest.put(Routes.applicationGuildCommands(process.env.DISCORD_CLIENT_ID, systemServerGuildId), {
for (const systemGuildId of systemOptions.systemGuildIds) {
logger.info(`Refreshing system commands for guild id ${systemGuildId}.`);
await rest.put(Routes.applicationGuildCommands(process.env.DISCORD_APPLICATION_ID, systemGuildId), {
body: systemCommands
});
}
+7 -9
View File
@@ -1,7 +1,5 @@
const path = require('node:path');
const logger = require(path.resolve('./src/services/logger.js'));
const logger = require('../services/logger');
const https = require('node:https');
require('dotenv').config();
exports.postBotStats = (client) => {
try {
@@ -11,42 +9,42 @@ exports.postBotStats = (client) => {
const sites = [
{
hostname: 'top.gg',
path: `/api/bots/${process.env.DISCORD_CLIENT_ID}/stats`,
path: `/api/bots/${process.env.DISCORD_APPLICATION_ID}/stats`,
method: 'POST',
body: { server_count: guildCount },
token: process.env.BOTLIST_TOP_GG_API_TOKEN
},
{
hostname: 'discordbotlist.com',
path: `/api/v1/bots/${process.env.DISCORD_CLIENT_ID}/stats`,
path: `/api/v1/bots/${process.env.DISCORD_APPLICATION_ID}/stats`,
method: 'POST',
body: { guilds: guildCount },
token: process.env.BOTLIST_DISCORD_BOT_LIST_COM_API_TOKEN
},
{
hostname: 'discords.com',
path: `/bots/api/bot/${process.env.DISCORD_CLIENT_ID}`,
path: `/bots/api/bot/${process.env.DISCORD_APPLICATION_ID}`,
method: 'POST',
body: { server_count: guildCount },
token: process.env.BOTLIST_DISCORDS_COM_API_TOKEN
},
{
hostname: 'discord.bots.gg',
path: `/api/v1/bots/${process.env.DISCORD_CLIENT_ID}/stats`,
path: `/api/v1/bots/${process.env.DISCORD_APPLICATION_ID}/stats`,
method: 'POST',
body: { guildCount: guildCount },
token: process.env.BOTLIST_DISCORD_BOTS_GG_API_TOKEN
},
{
hostname: 'api.botlist.me',
path: `/api/v1/bots/${process.env.DISCORD_CLIENT_ID}/stats`,
path: `/api/v1/bots/${process.env.DISCORD_APPLICATION_ID}/stats`,
method: 'POST',
body: { server_count: guildCount },
token: process.env.BOTLIST_BOTLIST_ME_API_TOKEN
},
{
hostname: 'api.discordlist.gg',
path: `/v0/bots/${process.env.DISCORD_CLIENT_ID}/guilds?count=${guildCount}`,
path: `/v0/bots/${process.env.DISCORD_APPLICATION_ID}/guilds?count=${guildCount}`,
method: 'PUT',
body: {},
token: `Bearer ${process.env.BOTLIST_DISCORDLIST_GG_API_TOKEN}`
+4 -8
View File
@@ -1,17 +1,13 @@
const logger = require('../services/logger');
const fs = require('node:fs');
const path = require('node:path');
const logger = require(path.resolve('./src/services/logger.js'));
require('dotenv').config();
exports.registerEventListeners = (client, player) => {
const eventFolders = fs.readdirSync(path.resolve('./src/events'));
const eventFolders = fs.readdirSync('./src/events');
for (const folder of eventFolders) {
const eventFiles = fs
.readdirSync(path.resolve(`./src/events/${folder}`))
.filter((file) => file.endsWith('.js'));
const eventFiles = fs.readdirSync(`./src/events/${folder}`).filter((file) => file.endsWith('.js'));
for (const file of eventFiles) {
const event = require(path.resolve(`./src/events/${folder}/${file}`));
const event = require(`../events/${folder}/${file}`);
switch (folder) {
case 'client':
if (event.once) {