mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 06:28:53 +00:00
WIP
This commit is contained in:
1 parent
9e20805529
commit
26a5022280
24 files changed
+121
-45
No files matched your search
+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