mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 14:38:49 +00:00
WIP
This commit is contained in:
1 parent
9e20805529
commit
26a5022280
24 files changed
+121
-45
No files matched your search
Generated
+1
-17
@@ -21,14 +21,12 @@
|
||||
"mediaplex": "^0.0.6",
|
||||
"node-os-utils": "^1.3.7",
|
||||
"pino": "^8.15.0",
|
||||
"pino-loki": "^2.1.3",
|
||||
"uuid": "^9.0.0"
|
||||
"pino-loki": "^2.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/config": "^3.3.0",
|
||||
"@types/node": "^20.5.9",
|
||||
"@types/node-os-utils": "^1.3.1",
|
||||
"@types/uuid": "^9.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "^6.5.0",
|
||||
"@typescript-eslint/parser": "^6.5.0",
|
||||
"eslint": "^8.48.0",
|
||||
@@ -512,12 +510,6 @@
|
||||
"integrity": "sha512-cJRQXpObxfNKkFAZbJl2yjWtJCqELQIdShsogr1d2MilP8dKD9TE/nEKHkJgUNHdGKCQaf9HbIynuV2csLGVLg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/uuid": {
|
||||
"version": "9.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.3.tgz",
|
||||
"integrity": "sha512-taHQQH/3ZyI3zP8M/puluDEIEvtQHVYcC6y3N8ijFtAd28+Ey/G4sg1u2gB01S8MwybLOKAp9/yCMu/uR5l3Ug==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/ws": {
|
||||
"version": "8.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.5.tgz",
|
||||
@@ -4149,14 +4141,6 @@
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
|
||||
},
|
||||
"node_modules/uuid": {
|
||||
"version": "9.0.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz",
|
||||
"integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==",
|
||||
"bin": {
|
||||
"uuid": "dist/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/web-streams-polyfill": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz",
|
||||
|
||||
+1
-3
@@ -40,14 +40,12 @@
|
||||
"mediaplex": "^0.0.6",
|
||||
"node-os-utils": "^1.3.7",
|
||||
"pino": "^8.15.0",
|
||||
"pino-loki": "^2.1.3",
|
||||
"uuid": "^9.0.0"
|
||||
"pino-loki": "^2.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/config": "^3.3.0",
|
||||
"@types/node": "^20.5.9",
|
||||
"@types/node-os-utils": "^1.3.1",
|
||||
"@types/uuid": "^9.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "^6.5.0",
|
||||
"@typescript-eslint/parser": "^6.5.0",
|
||||
"eslint": "^8.48.0",
|
||||
|
||||
+4
-6
@@ -1,16 +1,14 @@
|
||||
import 'dotenv/config';
|
||||
|
||||
import { Player } from 'discord-player';
|
||||
import { Client } from 'discord.js';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import 'dotenv/config';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
import { Logger } from 'pino';
|
||||
import loggerModule from './services/logger';
|
||||
import { ExtendedClient } from './types/clientTypes';
|
||||
import { createClient } from './utils/factory/createClient';
|
||||
import { createPlayer } from './utils/factory/createPlayer';
|
||||
import { registerClientInteractions } from './utils/registerClientInteractions';
|
||||
import { registerEventListeners } from './utils/registerEventListeners';
|
||||
import { Player } from 'discord-player';
|
||||
import { Logger } from 'pino';
|
||||
|
||||
const executionId: string = uuidv4();
|
||||
const logger: Logger = loggerModule.child({
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import config from 'config';
|
||||
import {
|
||||
ChatInputCommandInteraction,
|
||||
EmbedAuthorData,
|
||||
EmbedBuilder,
|
||||
EmbedFooterData,
|
||||
InteractionResponse,
|
||||
Message,
|
||||
MessageComponentInteraction,
|
||||
EmbedField
|
||||
} from 'discord.js';
|
||||
import { EmbedOptions } from '../types/configTypes';
|
||||
|
||||
export type EmbedContext = {
|
||||
author?: EmbedAuthorData;
|
||||
title?: string;
|
||||
description: string;
|
||||
footer?: EmbedFooterData;
|
||||
thumbnail?: string;
|
||||
fields?: EmbedField[];
|
||||
};
|
||||
|
||||
abstract class BaseEmbed {
|
||||
embedOptions: EmbedOptions;
|
||||
context: EmbedContext;
|
||||
interaction: ChatInputCommandInteraction | MessageComponentInteraction;
|
||||
embed: EmbedBuilder;
|
||||
|
||||
constructor(interaction: ChatInputCommandInteraction | MessageComponentInteraction, context: EmbedContext) {
|
||||
this.embedOptions = config.get('embedOptions');
|
||||
this.context = context;
|
||||
this.interaction = interaction;
|
||||
this.embed = new EmbedBuilder();
|
||||
this.embed.setDescription(`${context.title ? `**${context.title}**\n` : ''}${context.description}`);
|
||||
context.author && this.embed.setAuthor(context.author);
|
||||
context.footer && this.embed.setFooter(context.footer);
|
||||
context.thumbnail && this.embed.setThumbnail(context.thumbnail);
|
||||
}
|
||||
|
||||
abstract send(): Promise<Message<boolean> | InteractionResponse<boolean>>;
|
||||
}
|
||||
|
||||
export class InfoEmbed extends BaseEmbed {
|
||||
constructor(interaction: ChatInputCommandInteraction | MessageComponentInteraction, context: EmbedContext) {
|
||||
super(interaction, context);
|
||||
|
||||
this.embed.setColor(this.embedOptions.colors.info);
|
||||
}
|
||||
|
||||
async send(): Promise<Message<boolean>> {
|
||||
const embeds = { embeds: [this.embed] };
|
||||
return await this.interaction.editReply(embeds);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Events } from 'discord.js';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
|
||||
import loggerModule from '../../services/logger';
|
||||
import { Logger } from 'pino';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import config from 'config';
|
||||
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
|
||||
import loggerModule from '../../services/logger';
|
||||
import { ExtendedClient } from '../../types/clientTypes';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Events } from 'discord.js';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
|
||||
import loggerModule from '../../services/logger';
|
||||
import { Logger } from 'pino';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Events, Guild } from 'discord.js';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
|
||||
import loggerModule from '../../services/logger';
|
||||
import { Logger } from 'pino';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Events, Guild } from 'discord.js';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
|
||||
import loggerModule from '../../services/logger';
|
||||
import { Logger } from 'pino';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import config from 'config';
|
||||
import { BaseGuildTextChannel, EmbedBuilder, Events, PresenceData } from 'discord.js';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
|
||||
import { Logger } from 'pino';
|
||||
import loggerModule from '../../services/logger';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import config from 'config';
|
||||
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
|
||||
import { Logger } from 'pino';
|
||||
import loggerModule from '../../services/logger';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Events } from 'discord.js';
|
||||
import { Logger } from 'pino';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
import loggerModule from '../../services/logger';
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
MessageComponentInteraction
|
||||
} from 'discord.js';
|
||||
import { Logger } from 'pino';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
import { handleAutocomplete } from '../../handlers/interactionAutocompleteHandler';
|
||||
import { handleCommand } from '../../handlers/interactionCommandHandler';
|
||||
import { handleComponent } from '../../handlers/interactionComponentHandler';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Logger } from 'pino';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
import loggerModule from '../../services/logger';
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import config from 'config';
|
||||
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
|
||||
import { Logger } from 'pino';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
import loggerModule from '../../services/logger';
|
||||
import { BotOptions, EmbedOptions, SystemOptions } from '../../types/configTypes';
|
||||
import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Logger } from 'pino';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
import loggerModule from '../../services/logger';
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import config from 'config';
|
||||
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
|
||||
import { Logger } from 'pino';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
import loggerModule from '../../services/logger';
|
||||
import { BotOptions, EmbedOptions, SystemOptions } from '../../types/configTypes';
|
||||
import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
|
||||
|
||||
@@ -2,7 +2,7 @@ import config from 'config';
|
||||
import { Track } from 'discord-player';
|
||||
import { BaseGuildTextChannel, EmbedBuilder } from 'discord.js';
|
||||
import { Logger } from 'pino';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
import loggerModule from '../../services/logger';
|
||||
import { BotOptions, EmbedOptions, SystemOptions } from '../../types/configTypes';
|
||||
import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Track } from 'discord-player';
|
||||
import { Logger } from 'pino';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
import loggerModule from '../../services/logger';
|
||||
import { ExtendedGuildQueuePlayerNode } from '../../types/eventTypes';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Logger } from 'pino';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
import loggerModule from '../../services/logger';
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Logger } from 'pino';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
import loggerModule from '../../services/logger';
|
||||
|
||||
module.exports = {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import 'dotenv/config';
|
||||
|
||||
import config from 'config';
|
||||
import { Client, Shard, ShardEvents, ShardingManager, ShardingManagerOptions } from 'discord.js';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
|
||||
import { Logger } from 'pino';
|
||||
import loggerModule from './services/logger';
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { EmbedContext, InfoEmbed } from '../../../classes/embeds';
|
||||
import { BaseSlashCommandInteraction } from '../../../classes/interactions';
|
||||
import { BaseSlashCommandParams, BaseSlashCommandReturnType } from '../../../types/interactionTypes';
|
||||
|
||||
class TestCommand extends BaseSlashCommandInteraction {
|
||||
constructor() {
|
||||
const data = new SlashCommandBuilder().setName('test').setDescription('Test command.');
|
||||
super(data);
|
||||
}
|
||||
|
||||
async execute(params: BaseSlashCommandParams): BaseSlashCommandReturnType {
|
||||
const { executionId, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
|
||||
const embedContext: EmbedContext = {
|
||||
title: 'Test title',
|
||||
description: 'This is a test embed.',
|
||||
author: {
|
||||
name: 'Test author',
|
||||
iconURL: 'https://cdn.discordapp.com/embed/avatars/0.png'
|
||||
},
|
||||
footer: {
|
||||
text: 'Test footer',
|
||||
iconURL: 'https://cdn.discordapp.com/embed/avatars/0.png'
|
||||
},
|
||||
thumbnail: 'https://cdn.discordapp.com/embed/avatars/0.png',
|
||||
fields: [
|
||||
{
|
||||
name: 'Test field',
|
||||
value: 'Test field value',
|
||||
inline: false
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
logger.debug('Responding with info embed.');
|
||||
return new InfoEmbed(interaction, embedContext).send();
|
||||
}
|
||||
}
|
||||
|
||||
export default new TestCommand();
|
||||
@@ -4,7 +4,7 @@ import config from 'config';
|
||||
import { REST, RESTPostAPIChatInputApplicationCommandsJSONBody, RouteLike, Routes } from 'discord.js';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { randomUUID as uuidv4 } from 'node:crypto';
|
||||
|
||||
import loggerModule from '../services/logger';
|
||||
import { SystemOptions } from '../types/configTypes';
|
||||
|
||||
Reference in new issue
Block a user