diff --git a/.gitmodules b/.gitmodules index 13d69690..e8fdd35f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,3 @@ [submodule "Database"] path = Database url = https://github.com/N-D-B-Project/Database.git -[submodule "SharedModule"] - path = src/modules/shared - url = https://github.com/N-D-B-Project/SharedModule.git diff --git a/src/app.module.ts b/src/app.module.ts new file mode 100644 index 00000000..f67d7f17 --- /dev/null +++ b/src/app.module.ts @@ -0,0 +1,13 @@ +import { Module } from "@nestjs/common"; +import { ConfigModule } from "@nestjs/config"; + +@Module({ + imports: [ + ConfigModule.forRoot({ + isGlobal: true, + cache: true, + load: [], + }), + ], +}) +export class AppModule {} diff --git a/src/common/guards/CommandPermissions.guard.ts b/src/common/guards/CommandPermissions.guard.ts index 8b274cee..da9304ec 100644 --- a/src/common/guards/CommandPermissions.guard.ts +++ b/src/common/guards/CommandPermissions.guard.ts @@ -1,16 +1,8 @@ import { CommandPermissions } from "@/common/decorators"; -import type { Config } from "@/modules/SharedModule/config/types"; +import type { Config } from "@/modules/shared/config/types"; import { formatArray } from "@/utils/Tools"; -import { - LOCALIZATION_ADAPTER, - type NestedLocalizationAdapter, -} from "@necord/localization"; -import { - Inject, - Injectable, - type CanActivate, - type ExecutionContext, -} from "@nestjs/common"; +import { LOCALIZATION_ADAPTER, type NestedLocalizationAdapter } from "@necord/localization"; +import { type CanActivate, type ExecutionContext, Inject, Injectable } from "@nestjs/common"; import type { ConfigService } from "@nestjs/config"; import type { Reflector } from "@nestjs/core"; import type { ChatInputCommandInteraction } from "discord.js"; @@ -24,13 +16,8 @@ export class CommandPermissionsGuard implements CanActivate { private readonly config: ConfigService, ) {} - public async canActivate( - executionContext: ExecutionContext, - ): Promise { - const permissions = this.reflector.get( - CommandPermissions.KEY, - executionContext.getHandler(), - ); + public async canActivate(executionContext: ExecutionContext): Promise { + const permissions = this.reflector.get(CommandPermissions.KEY, executionContext.getHandler()); const context = NecordExecutionContext.create(executionContext); const args = context.getArgByIndex(0); const interaction = args[0] as ChatInputCommandInteraction; @@ -38,53 +25,31 @@ export class CommandPermissionsGuard implements CanActivate { if (permissions.bot) { if (!interaction.guild.members.me.permissions.has(permissions.bot)) { interaction.reply( - this.translate.getTranslation( - "Tools.Commands.Permission.Bot", - interaction.guildLocale, - { - PERMS: formatArray(permissions.bot as string[]), - }, - ), + this.translate.getTranslation("Tools.Commands.Permission.Bot", interaction.guildLocale, { + PERMS: formatArray(permissions.bot as string[]), + }), ); return false; } } if (permissions.user) { - if ( - !( - await interaction.guild.members.fetch(interaction.user.id) - ).permissions.has(permissions.user) - ) { + if (!(await interaction.guild.members.fetch(interaction.user.id)).permissions.has(permissions.user)) { interaction.reply( - this.translate.getTranslation( - "Tools.Commands.Permission.User", - interaction.guildLocale, - { - PERMS: formatArray(permissions.user as string[]), - }, - ), + this.translate.getTranslation("Tools.Commands.Permission.User", interaction.guildLocale, { + PERMS: formatArray(permissions.user as string[]), + }), ); } } if (permissions.guildOnly && !this.checkGuild(interaction.guildId)) { - interaction.reply( - this.translate.getTranslation( - "Tools.Command.Checker.GuildOnly", - interaction.guildLocale, - ), - ); + interaction.reply(this.translate.getTranslation("Tools.Command.Checker.GuildOnly", interaction.guildLocale)); return false; } if (permissions.ownerOnly && !this.checkOwner(interaction.user.id)) { - interaction.reply( - this.translate.getTranslation( - "Tools.Command.Checker.OwnerOnly", - interaction.guildLocale, - ), - ); + interaction.reply(this.translate.getTranslation("Tools.Command.Checker.OwnerOnly", interaction.guildLocale)); return false; } @@ -93,16 +58,12 @@ export class CommandPermissionsGuard implements CanActivate { private checkGuild(target: string): boolean { return ( - this.config.getOrThrow("Discord").Servers - .NDCommunity === target || - this.config.getOrThrow("Discord").Servers.TestGuild === - target + this.config.getOrThrow("Discord").Servers.NDCommunity === target || + this.config.getOrThrow("Discord").Servers.TestGuild === target ); } private checkOwner(target: string) { - return this.config - .getOrThrow("Discord") - .Client.Owners.includes(target); + return this.config.getOrThrow("Discord").Client.Owners.includes(target); } } diff --git a/src/lib/sharding.ts b/src/lib/sharding.ts index 4fa30103..1b4df6ac 100644 --- a/src/lib/sharding.ts +++ b/src/lib/sharding.ts @@ -1,13 +1,13 @@ +import path from "node:path"; import { Logger } from "@nestjs/common"; import type { ConfigService } from "@nestjs/config"; import { ShardingManager as _ShardingManager } from "discord.js"; -import path from "node:path"; -import type { Config } from "../modules/SharedModule/config/types"; +import type { Config } from "../modules/shared/config/types"; export class ShardingManager extends _ShardingManager { public constructor(private readonly config: ConfigService) { super(path.join(__dirname, "bot.js"), { - token: config.getOrThrow("Discord").Token, + token: config.getOrThrow("Discord").Token, shardList: "auto", respawn: true, mode: "process", diff --git a/src/main.ts b/src/main.ts index cdd28a8d..85e87088 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,16 +1,15 @@ import { Logger } from "@nestjs/common"; -import { ConfigService } from "@nestjs/config"; import { ShardingManager, TopGGAutoPoster } from "./lib"; -import type { Config } from "./modules/SharedModule/config/types"; +import {NestFactory } from "@nestjs/core"; +import { AppModule } from "./app.module"; +import { ConfigService } from "@nestjs/config"; async function bootstrap() { + const app = await NestFactory.create(AppModule); + const configService = app.get(ConfigService); const logger = new Logger("Main"); - const configService = new ConfigService() const ShardManager = new ShardingManager(configService); - const TopGGPoster = new TopGGAutoPoster( - configService.getOrThrow("TopGGToken"), - ShardManager, - ); + const TopGGPoster = new TopGGAutoPoster(configService.getOrThrow("TopGGToken"), ShardManager); try { await ShardManager.init(); diff --git "a/src/modules/commands/\360\237\233\240\357\270\217 Developer Tools/commands/eval/eval.command.ts" "b/src/modules/commands/\360\237\233\240\357\270\217 Developer Tools/commands/eval/eval.command.ts" index 81edb634..02f8ab66 100644 --- "a/src/modules/commands/\360\237\233\240\357\270\217 Developer Tools/commands/eval/eval.command.ts" +++ "b/src/modules/commands/\360\237\233\240\357\270\217 Developer Tools/commands/eval/eval.command.ts" @@ -1,7 +1,7 @@ import { inspect } from "node:util"; import { CommandConfig, CommandPermissions } from "@/common/decorators"; import { CommandConfigGuard, CommandPermissionsGuard } from "@/common/guards"; -import { Config } from "@/modules/SharedModule/config/types"; +import { Config } from "@/modules/shared/config/types"; import { CurrentTranslate, TranslationFn, localizationMapByKey } from "@necord/localization"; import { UseGuards } from "@nestjs/common"; import { ConfigService } from "@nestjs/config"; diff --git a/src/modules/core/NDB.module.ts b/src/modules/core/NDB.module.ts index e4f79794..758f7b64 100644 --- a/src/modules/core/NDB.module.ts +++ b/src/modules/core/NDB.module.ts @@ -3,12 +3,12 @@ import { NecordPaginationModule } from "@necord/pagination"; import { Module } from "@nestjs/common"; import { ConfigService } from "@nestjs/config"; import { NecordModule } from "necord"; -import { JSONLocaleLoader, NecordConfigService, SharedModule } from "../SharedModule"; -import { Config } from "../SharedModule/config/types"; import { CommandsModule } from "../commands/Commands.module"; import { ComponentsModule } from "../components/Components.module"; import { EventsModule } from "../events/Events.module"; import { ReactionRolesModule } from "../reactionRoles/ReactionRoles.module"; +import { JSONLocaleLoader, NecordConfigService, SharedModule } from "../shared"; +import { Config } from "../shared/config/types"; import { NDBServiceProvider } from "./provider/NDBService.provider"; @Module({ diff --git a/src/modules/events/Gateway.ts b/src/modules/events/Gateway.ts index 7da7d04a..48619fc8 100644 --- a/src/modules/events/Gateway.ts +++ b/src/modules/events/Gateway.ts @@ -1,5 +1,5 @@ -import { Config } from "@/modules/SharedModule/config/types"; -import { IDatabaseService } from "@/modules/SharedModule/database/interfaces/IDatabaseService"; +import { Config } from "@/modules/shared/config/types"; +import { IDatabaseService } from "@/modules/shared/database/interfaces/IDatabaseService"; import { Services } from "@/types/Constants"; import { Inject, Injectable, Logger } from "@nestjs/common"; import { ConfigService } from "@nestjs/config"; diff --git a/src/modules/events/Guild.ts b/src/modules/events/Guild.ts index a5c279e1..6f4b7b13 100644 --- a/src/modules/events/Guild.ts +++ b/src/modules/events/Guild.ts @@ -1,4 +1,4 @@ -import type { IDatabaseService } from "@/modules/SharedModule"; +import type { IDatabaseService } from "@/modules/shared"; import { Services } from "@/types/Constants"; import { Inject, Injectable } from "@nestjs/common"; import { Client } from "discord.js"; diff --git a/src/modules/music/Music.embeds.ts b/src/modules/music/Music.embeds.ts index 087df97f..1dc3bdce 100644 --- a/src/modules/music/Music.embeds.ts +++ b/src/modules/music/Music.embeds.ts @@ -1,4 +1,4 @@ -import { Config } from "@/modules/SharedModule/config/types"; +import { Config } from "@/modules/shared/config/types"; import { Timer } from "@/utils/Tools"; import { LOCALIZATION_ADAPTER, NestedLocalizationAdapter } from "@necord/localization"; import { Inject, Injectable } from "@nestjs/common"; @@ -284,10 +284,10 @@ export class MusicEmbeds implements IMusicEmbeds { IsPlaying: player.paused ? this.translate.getTranslation("Tools.Music.NowPlayingEmbed.Paused", interaction.guildLocale, { Emoji: this.config.getOrThrow("Emojis").fail, - }) + }) : this.translate.getTranslation("Tools.Music.NowPlayingEmbed.Playing", interaction.guildLocale, { Emoji: this.config.getOrThrow("Emojis").success, - }), + }), }, ), inline: true, @@ -301,10 +301,10 @@ export class MusicEmbeds implements IMusicEmbeds { IsBassBoosted: player.filterManager.equalizerBands ? this.translate.getTranslation("Tools.Music.NowPlayingEmbed.ActiveBass", interaction.guildLocale, { Emoji: this.config.getOrThrow("Emojis").success, - }) + }) : this.translate.getTranslation("Tools/Music:NowPlayingEmbed:NoBass", interaction.guildLocale, { Emoji: this.config.getOrThrow("Emojis").fail, - }), + }), }, ), inline: true, @@ -501,14 +501,14 @@ export class MusicEmbeds implements IMusicEmbeds { ? this.translate.getTranslation( "Events.PlayerEvents.trackStart.Embed.Fields.Content.3²", textChannel.guild.preferredLocale, - ) + ) : this.translate.getTranslation( "Events.PlayerEvents.trackStart.Embed.Fields.Content.3", textChannel.guild.preferredLocale, { TIMER: Timer, }, - ) + ) }`, inline: true, }, diff --git a/src/modules/music/Music.service.ts b/src/modules/music/Music.service.ts index 4869ccad..9436f15a 100644 --- a/src/modules/music/Music.service.ts +++ b/src/modules/music/Music.service.ts @@ -1,5 +1,5 @@ -import { Config } from "@/modules/SharedModule/config/types"; -import { IDatabaseService } from "@/modules/SharedModule/database/interfaces/IDatabaseService"; +import { Config } from "@/modules/shared/config/types"; +import { IDatabaseService } from "@/modules/shared/database/interfaces/IDatabaseService"; import { Services } from "@/types/Constants"; import { LOCALIZATION_ADAPTER, NestedLocalizationAdapter } from "@necord/localization"; import { Inject, Injectable } from "@nestjs/common"; diff --git a/src/modules/music/classes/BaseManager.ts b/src/modules/music/classes/BaseManager.ts index dbbfb4cc..5b749780 100644 --- a/src/modules/music/classes/BaseManager.ts +++ b/src/modules/music/classes/BaseManager.ts @@ -1,5 +1,5 @@ -import { Config } from "@/modules/SharedModule/config/types"; import { LavalinkManagerEvents, NodeManagerEvents } from "@/modules/music/types/lavalink-client"; +import { Config } from "@/modules/shared/config/types"; import { Logger } from "@nestjs/common"; import { ConfigService } from "@nestjs/config"; import { EventEmitter2 } from "@nestjs/event-emitter"; diff --git a/src/modules/music/events/Channel.ts b/src/modules/music/events/Channel.ts index 2222bfab..6765acd5 100644 --- a/src/modules/music/events/Channel.ts +++ b/src/modules/music/events/Channel.ts @@ -1,4 +1,4 @@ -import type { IDatabaseService } from "@/modules/SharedModule/database/interfaces/IDatabaseService"; +import type { IDatabaseService } from "@/modules/shared/database/interfaces/IDatabaseService"; import { Services } from "@/types/Constants"; import { LOCALIZATION_ADAPTER, type NestedLocalizationAdapter } from "@necord/localization"; import { Inject, Injectable, Logger } from "@nestjs/common"; diff --git a/src/modules/music/events/Guild.ts b/src/modules/music/events/Guild.ts index b6994e78..2f23aa9a 100644 --- a/src/modules/music/events/Guild.ts +++ b/src/modules/music/events/Guild.ts @@ -1,4 +1,4 @@ -import type { IDatabaseService } from "@/modules/SharedModule/database/interfaces/IDatabaseService"; +import type { IDatabaseService } from "@/modules/shared/database/interfaces/IDatabaseService"; import { Services } from "@/types/Constants"; import { Inject, Injectable } from "@nestjs/common"; import { Client } from "discord.js"; diff --git a/src/modules/music/events/Node.ts b/src/modules/music/events/Node.ts index fa94351e..c0ce7293 100644 --- a/src/modules/music/events/Node.ts +++ b/src/modules/music/events/Node.ts @@ -1,4 +1,4 @@ -import { Config } from "@/modules/SharedModule/config/types"; +import { Config } from "@/modules/shared/config/types"; import { Injectable, Logger } from "@nestjs/common"; import { ConfigService } from "@nestjs/config"; import { OnEvent } from "@nestjs/event-emitter"; diff --git a/src/modules/music/events/Player.ts b/src/modules/music/events/Player.ts index 6851eab8..690a62f8 100644 --- a/src/modules/music/events/Player.ts +++ b/src/modules/music/events/Player.ts @@ -1,4 +1,4 @@ -import type { Config } from "@/modules/SharedModule/config/types"; +import type { Config } from "@/modules/shared/config/types"; import { Inject, Injectable, Logger } from "@nestjs/common"; import type { ConfigService } from "@nestjs/config"; import { OnEvent } from "@nestjs/event-emitter"; diff --git a/src/modules/music/events/Queue.ts b/src/modules/music/events/Queue.ts index afb6b8ef..31a4bb67 100644 --- a/src/modules/music/events/Queue.ts +++ b/src/modules/music/events/Queue.ts @@ -1,4 +1,4 @@ -import { Config } from "@/modules/SharedModule/config/types"; +import { Config } from "@/modules/shared/config/types"; import { Extends } from "@/types/Constants"; import { LOCALIZATION_ADAPTER, NestedLocalizationAdapter } from "@necord/localization"; import { Inject, Injectable, Logger } from "@nestjs/common"; diff --git a/src/modules/music/events/Voice.ts b/src/modules/music/events/Voice.ts index b5f8fb1b..b4e70fcf 100644 --- a/src/modules/music/events/Voice.ts +++ b/src/modules/music/events/Voice.ts @@ -1,5 +1,5 @@ -import { Config } from "@/modules/SharedModule/config/types"; -import type { IDatabaseService } from "@/modules/SharedModule/database/interfaces/IDatabaseService"; +import { Config } from "@/modules/shared/config/types"; +import type { IDatabaseService } from "@/modules/shared/database/interfaces/IDatabaseService"; import { Services } from "@/types/Constants"; import { LOCALIZATION_ADAPTER, NestedLocalizationAdapter } from "@necord/localization"; import { Inject, Logger } from "@nestjs/common"; diff --git a/src/modules/reactionRoles/ReactionRoles.embeds.ts b/src/modules/reactionRoles/ReactionRoles.embeds.ts index 10687c2e..af820aa0 100644 --- a/src/modules/reactionRoles/ReactionRoles.embeds.ts +++ b/src/modules/reactionRoles/ReactionRoles.embeds.ts @@ -1,5 +1,5 @@ -import { Config } from "@/modules/SharedModule/config/types"; import { MessageTools } from "@/modules/commands/Message"; +import { Config } from "@/modules/shared/config/types"; import { LOCALIZATION_ADAPTER, NestedLocalizationAdapter } from "@necord/localization"; import { Inject, Injectable } from "@nestjs/common"; import { ConfigService } from "@nestjs/config"; diff --git a/src/modules/reactionRoles/ReactionRoles.repository.ts b/src/modules/reactionRoles/ReactionRoles.repository.ts index 8d627c1f..fc13b3be 100644 --- a/src/modules/reactionRoles/ReactionRoles.repository.ts +++ b/src/modules/reactionRoles/ReactionRoles.repository.ts @@ -1,4 +1,4 @@ -import { PrismaService } from "@/modules/SharedModule/database/prisma/Prisma.service"; +import { PrismaService } from "@/modules/shared/database/prisma/Prisma.service"; import { Services } from "@/types/Constants"; import { Inject, Injectable } from "@nestjs/common"; import { Guild, TextChannel } from "discord.js"; diff --git a/src/modules/reactionRoles/ReactionRoles.service.ts b/src/modules/reactionRoles/ReactionRoles.service.ts index 5e48ca4f..bdd6a5ca 100644 --- a/src/modules/reactionRoles/ReactionRoles.service.ts +++ b/src/modules/reactionRoles/ReactionRoles.service.ts @@ -1,4 +1,4 @@ -import type { IDatabaseService } from "@/modules/SharedModule/database/interfaces/IDatabaseService"; +import type { IDatabaseService } from "@/modules/shared/database/interfaces/IDatabaseService"; import { Services } from "@/types/Constants"; import { Inject, Injectable } from "@nestjs/common"; import { Client, CommandInteraction, Guild, Message, Role, TextChannel } from "discord.js"; diff --git a/src/modules/reactionRoles/events/ReactionRoles.ts b/src/modules/reactionRoles/events/ReactionRoles.ts index e92e73f1..5bb8f85a 100644 --- a/src/modules/reactionRoles/events/ReactionRoles.ts +++ b/src/modules/reactionRoles/events/ReactionRoles.ts @@ -1,5 +1,5 @@ -import type { IDatabaseService } from "@/modules/SharedModule/database/interfaces/IDatabaseService"; import { MessageTools } from "@/modules/commands/Message"; +import type { IDatabaseService } from "@/modules/shared/database/interfaces/IDatabaseService"; import { Services } from "@/types/Constants"; import { LOCALIZATION_ADAPTER, NestedLocalizationAdapter } from "@necord/localization"; import { Inject, Injectable } from "@nestjs/common"; diff --git a/src/modules/shared b/src/modules/shared deleted file mode 160000 index bdb19e69..00000000 --- a/src/modules/shared +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bdb19e69b7656cf52cb920f634cea090f2588f7b diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 28006884..2f93b2e1 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -1,4 +1,4 @@ -import { UserEntity } from "@/modules/SharedModule/database/entities"; +import { UserEntity } from "@/modules/shared/database/entities"; import { BaseMessageOptions, EmbedBuilder } from "discord.js"; import "fastify";