mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 06:28:53 +00:00
fix: Fixed most imports and some typescript changes
This commit is contained in:
1 parent
1a7f800ba2
commit
0d9f4bd404
60 files changed
+488
-265
No files matched your search
@@ -1,14 +1,15 @@
|
||||
require('dotenv').config();
|
||||
import 'dotenv/config';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
const { REST, Routes } = require('discord.js');
|
||||
import { REST, Routes } from 'discord.js';
|
||||
import config from 'config';
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import loggerModule from '../services/logger';
|
||||
const systemOptions = config.get('systemOptions');
|
||||
|
||||
const executionId = uuidv4();
|
||||
|
||||
const logger = require('../services/logger').child({
|
||||
const logger = loggerModule.child({
|
||||
source: 'deploySlashCommands.js',
|
||||
module: 'deploy',
|
||||
name: 'deploySlashCommands',
|
||||
@@ -24,6 +25,7 @@ for (const folder of commandFolders) {
|
||||
.filter((file) => file.endsWith('.js'));
|
||||
|
||||
for (const file of commandFiles) {
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const command = require(`../commands/${folder}/${file}`);
|
||||
command.isSystemCommand
|
||||
? systemCommands.push(command.data.toJSON())
|
||||
@@ -72,7 +74,7 @@ const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_BOT_TOKEN)
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
error,
|
||||
'Failed to refresh system slash commands. Make sure the bot is in the system guilds specified in \'systemOptions\'.'
|
||||
"Failed to refresh system slash commands. Make sure the bot is in the system guilds specified in 'systemOptions'."
|
||||
);
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import Discord from 'discord.js';
|
||||
import loggerModule from '../../services/logger';
|
||||
import { Client } from 'discord.js';
|
||||
|
||||
exports.createClient = async ({ executionId }) => {
|
||||
const logger = require('../../services/logger').child({
|
||||
export const createClient = async ({ executionId }: { executionId: string }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'createClient.js',
|
||||
module: 'utilFactory',
|
||||
name: 'createClient',
|
||||
@@ -12,7 +14,7 @@ exports.createClient = async ({ executionId }) => {
|
||||
try {
|
||||
logger.debug('Creating discord.js client...');
|
||||
|
||||
const client = new Discord.Client({
|
||||
const client: Client = new Discord.Client({
|
||||
intents: [Discord.GatewayIntentBits.Guilds, Discord.GatewayIntentBits.GuildVoiceStates],
|
||||
makeCache: Discord.Options.cacheWithLimits({
|
||||
...Discord.Options.DefaultMakeCacheSettings,
|
||||
@@ -22,7 +24,7 @@ exports.createClient = async ({ executionId }) => {
|
||||
ReactionManager: 0,
|
||||
GuildMemberManager: {
|
||||
maxSize: 50,
|
||||
keepOverLimit: (member) => member.id === client.user.id
|
||||
keepOverLimit: (member) => member.id === client.user?.id
|
||||
}
|
||||
}),
|
||||
sweepers: {
|
||||
@@ -33,7 +35,7 @@ exports.createClient = async ({ executionId }) => {
|
||||
},
|
||||
users: {
|
||||
interval: 3600,
|
||||
filter: () => (user) => user.id !== client.user.id
|
||||
filter: () => (user) => user.id !== client.user?.id
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
const { Player } = require('discord-player');
|
||||
import { Player } from 'discord-player';
|
||||
import loggerModule from '../../services/logger';
|
||||
import { CreatePlayerParams } from '../../types/playerTypes';
|
||||
|
||||
exports.createPlayer = async ({ client, executionId }) => {
|
||||
const logger = require('../../services/logger').child({
|
||||
export const createPlayer = async ({ client, executionId }: CreatePlayerParams) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'createPlayer.js',
|
||||
module: 'utilFactory',
|
||||
name: 'createPlayer',
|
||||
executionId: executionId,
|
||||
shardId: client.shard.ids[0]
|
||||
shardId: client.shard?.ids[0]
|
||||
});
|
||||
|
||||
try {
|
||||
@@ -27,6 +29,7 @@ exports.createPlayer = async ({ client, executionId }) => {
|
||||
|
||||
// make player accessible from anywhere in the application
|
||||
// primarily to be able to use it in broadcastEval and other sharding methods
|
||||
// @ts-ignore
|
||||
global.player = player;
|
||||
|
||||
await player.extractors.loadDefault();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const cookies = require(path.resolve('./cookies.json'));
|
||||
|
||||
try {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import https from 'node:https';
|
||||
import loggerModule from '../../services/logger';
|
||||
|
||||
exports.postBotStats = async ({ client, executionId }) => {
|
||||
const logger = require('../../services/logger').child({
|
||||
export const postBotStats = async ({ client, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'postBotStats.js',
|
||||
module: 'utilOther',
|
||||
name: 'postBotStats',
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import config from 'config';
|
||||
import loggerModule from '../../services/logger';
|
||||
const loadTestOptions = config.get('loadTestOptions');
|
||||
|
||||
exports.startLoadTest = async ({ client, executionId }) => {
|
||||
const logger = require('../../services/logger').child({
|
||||
export const startLoadTest = async ({ client, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'startLoadTest.js',
|
||||
module: 'utilOther',
|
||||
name: 'startLoadTest',
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
const { Collection } = require('discord.js');
|
||||
import { Collection } from 'discord.js';
|
||||
import loggerModule from '../services/logger';
|
||||
|
||||
exports.registerClientCommands = ({ client, executionId }) => {
|
||||
const logger = require('../services/logger').child({
|
||||
export const registerClientCommands = ({ client, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'registerClientCommands.js',
|
||||
module: 'register',
|
||||
name: 'registerClientCommands',
|
||||
@@ -27,6 +28,7 @@ exports.registerClientCommands = ({ client, executionId }) => {
|
||||
delete require.cache[require.resolve(`../commands/${folder}/${file}`)];
|
||||
|
||||
// register command
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const command = require(`../commands/${folder}/${file}`);
|
||||
client.commands.delete(command.data.name);
|
||||
client.commands.set(command.data.name, command);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import config from 'config';
|
||||
|
||||
import loggerModule from '../services/logger';
|
||||
const loggerOptions = config.get('loggerOptions');
|
||||
|
||||
exports.registerEventListeners = ({ client, player, executionId }) => {
|
||||
const logger = require('../services/logger').child({
|
||||
export const registerEventListeners = ({ client, player, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'registerEventListeners.js',
|
||||
module: 'register',
|
||||
name: 'registerEventListeners',
|
||||
@@ -24,6 +24,7 @@ exports.registerEventListeners = ({ client, player, executionId }) => {
|
||||
.filter((file) => file.endsWith('.js'));
|
||||
|
||||
for (const file of eventFiles) {
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const event = require(`../events/${folder}/${file}`);
|
||||
switch (folder) {
|
||||
case 'client':
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
exports.getUptimeFormatted = async ({ executionId }) => {
|
||||
const logger = require('../../services/logger').child({
|
||||
import loggerModule from '../../services/logger';
|
||||
|
||||
export const getUptimeFormatted = async ({ executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'getUptimeFormatted.js',
|
||||
module: 'utilSystem',
|
||||
name: 'getUptimeFormatted',
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import config from 'config';
|
||||
const embedOptions = config.get('embedOptions');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
import { EmbedOptions } from '../../types/configTypes';
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import loggerModule from '../../services/logger';
|
||||
|
||||
exports.cannotJoinVoiceOrTalk = async ({ interaction, executionId }) => {
|
||||
const logger = require('../../services/logger').child({
|
||||
export const cannotJoinVoiceOrTalk = async ({ interaction, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'permissionValidator.js',
|
||||
module: 'utilValidation',
|
||||
name: 'cannotJoinVoiceOrTalk',
|
||||
@@ -34,8 +36,8 @@ exports.cannotJoinVoiceOrTalk = async ({ interaction, executionId }) => {
|
||||
return false;
|
||||
};
|
||||
|
||||
exports.cannotSendMessageInChannel = async ({ interaction, executionId }) => {
|
||||
const logger = require('../../services/logger').child({
|
||||
export const cannotSendMessageInChannel = async ({ interaction, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'permissionValidator.js',
|
||||
module: 'utilValidation',
|
||||
name: 'cannotSendMessageInChannel',
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import config from 'config';
|
||||
const embedOptions = config.get('embedOptions');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
import { EmbedOptions } from '../../types/configTypes';
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import loggerModule from '../../services/logger';
|
||||
|
||||
exports.queueDoesNotExist = async ({ interaction, queue, executionId }) => {
|
||||
const logger = require('../../services/logger').child({
|
||||
export const queueDoesNotExist = async ({ interaction, queue, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'queueValidator.js',
|
||||
module: 'utilValidation',
|
||||
name: 'queueDoesNotExist',
|
||||
@@ -30,8 +32,8 @@ exports.queueDoesNotExist = async ({ interaction, queue, executionId }) => {
|
||||
return false;
|
||||
};
|
||||
|
||||
exports.queueNoCurrentTrack = async ({ interaction, queue, executionId }) => {
|
||||
const logger = require('../../services/logger').child({
|
||||
export const queueNoCurrentTrack = async ({ interaction, queue, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'queueValidator.js',
|
||||
module: 'utilValidation',
|
||||
name: 'queueNoCurrentTrack',
|
||||
@@ -58,8 +60,8 @@ exports.queueNoCurrentTrack = async ({ interaction, queue, executionId }) => {
|
||||
return false;
|
||||
};
|
||||
|
||||
exports.queueIsEmpty = async ({ interaction, queue, executionId }) => {
|
||||
const logger = require('../../services/logger').child({
|
||||
export const queueIsEmpty = async ({ interaction, queue, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'queueValidator.js',
|
||||
module: 'utilValidation',
|
||||
name: 'queueIsEmpty',
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
exports.transformQuery = async ({ query, executionId }) => {
|
||||
const logger = require('../../services/logger').child({
|
||||
import loggerModule from '../../services/logger';
|
||||
|
||||
export const transformQuery = async ({ query, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'searchQueryValidator.js',
|
||||
module: 'utilValidation',
|
||||
name: 'transformQuery',
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import config from 'config';
|
||||
const embedOptions = config.get('embedOptions');
|
||||
const systemOptions = config.get('systemOptions');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
import loggerModule from '../../services/logger';
|
||||
|
||||
exports.notValidGuildId = async ({ interaction, executionId }) => {
|
||||
const logger = require('../../services/logger').child({
|
||||
import config from 'config';
|
||||
import { EmbedOptions } from '../../types/configTypes';
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
const systemOptions = config.get('systemOptions');
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
|
||||
export const notValidGuildId = async ({ interaction, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'systemCommandValidator.js',
|
||||
module: 'utilValidation',
|
||||
name: 'notValidGuildId',
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { EmbedOptions } from '../../types/configTypes';
|
||||
import loggerModule from '../../services/logger';
|
||||
import config from 'config';
|
||||
const embedOptions = config.get('embedOptions');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const embedOptions: EmbedOptions = config.get('embedOptions');
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
|
||||
exports.notInVoiceChannel = async ({ interaction, executionId }) => {
|
||||
const logger = require('../../services/logger').child({
|
||||
export const notInVoiceChannel = async ({ interaction, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'voiceChannelValidator.js',
|
||||
module: 'validator',
|
||||
name: 'notInVoiceChannel',
|
||||
@@ -30,8 +32,8 @@ exports.notInVoiceChannel = async ({ interaction, executionId }) => {
|
||||
return false;
|
||||
};
|
||||
|
||||
exports.notInSameVoiceChannel = async ({ interaction, queue, executionId }) => {
|
||||
const logger = require('../../services/logger').child({
|
||||
export const notInSameVoiceChannel = async ({ interaction, queue, executionId }) => {
|
||||
const logger = loggerModule.child({
|
||||
source: 'voiceChannelValidator.js',
|
||||
module: 'utilValidation',
|
||||
name: 'notInSameVoiceChannel',
|
||||
|
||||
Reference in new issue
Block a user