diff --git a/package.json b/package.json index d78c9130..7ca66204 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "class-validator": "^0.14.1", "discord-api-types": "^0.37.73", "discord.js": "^14.14.1", - "ioredis": "^5.3.2", + "ioredis": "^5.4.1", "lavalink-client": "^2.1.7", "moment": "^2.30.1", "necord": "^6.8.3", diff --git a/src/modules/core/NDB.module.ts b/src/modules/core/NDB.module.ts index f9cec279..96ab5258 100644 --- a/src/modules/core/NDB.module.ts +++ b/src/modules/core/NDB.module.ts @@ -9,6 +9,7 @@ import { JSONLocaleLoader, NecordConfigService, config } from "../config"; import type { Config } from "../config/types"; import { DatabaseModule } from "../database/database.module"; import { EventsModule } from "../events/Events.module"; +import { MusicModule } from "../music"; import { ReactionRolesModule } from "../reactionRoles/ReactionRoles.module"; import { ScheduleModule } from "../schedule/schedule.module"; import { NDBServiceProvider } from "./provider/NDBService.provider"; @@ -45,6 +46,7 @@ import { NDBServiceProvider } from "./provider/NDBService.provider"; CommandsModule, ComponentsModule, EventsModule, + MusicModule, ReactionRolesModule, ], providers: [NDBServiceProvider], diff --git a/src/modules/music/Music.manager.ts b/src/modules/music/Music.manager.ts index e15b38f6..f6fc275a 100644 --- a/src/modules/music/Music.manager.ts +++ b/src/modules/music/Music.manager.ts @@ -17,12 +17,8 @@ export class MusicManager implements OnModuleInit { private readonly eventEmitter: EventEmitter2, ) { this.common = new CommonManager(client, config, eventEmitter); - this.premium = new PremiumManager( - client, - config, - eventEmitter, - new RedisClient(), - ); + // this.premium = new CommonManager(client, config, eventEmitter); + this.premium = new PremiumManager(client, config, eventEmitter, new RedisClient()); } public async onModuleInit() { diff --git a/src/modules/music/classes/BaseManager.ts b/src/modules/music/classes/BaseManager.ts index d499cbd4..1993f3ac 100644 --- a/src/modules/music/classes/BaseManager.ts +++ b/src/modules/music/classes/BaseManager.ts @@ -1,7 +1,7 @@ import type { Config } from "@/modules/config/types"; import type { - LavalinkManagerEvents, - NodeManagerEvents, + LavalinkManagerEvents, + NodeManagerEvents, } from "@/modules/music/types/lavalink-client"; import { Logger } from "@nestjs/common"; import type { ConfigService } from "@nestjs/config"; @@ -25,7 +25,7 @@ export class BaseManager extends LavalinkManager { host: process.env.LavalinkHOST, port: 2333, authorization: process.env.LAVALINK_SERVER_PASSWORD, - retryAmount: 22, + retryAmount: 4, retryDelay: 5000, }, ], diff --git a/src/modules/music/classes/CommonManager.ts b/src/modules/music/classes/CommonManager.ts index 2fa1c805..f22e80d9 100644 --- a/src/modules/music/classes/CommonManager.ts +++ b/src/modules/music/classes/CommonManager.ts @@ -1,7 +1,7 @@ import { ConfigService } from "@nestjs/config"; import { EventEmitter2 } from "@nestjs/event-emitter"; import { Client } from "discord.js"; -import { BaseManager } from "./BaseManager"; +import { BaseManager } from "."; export class CommonManager extends BaseManager { public constructor(client: Client, config: ConfigService, eventEmitter: EventEmitter2) { diff --git a/src/modules/music/classes/PremiumManager.ts b/src/modules/music/classes/PremiumManager.ts index 91eb2480..aa066889 100644 --- a/src/modules/music/classes/PremiumManager.ts +++ b/src/modules/music/classes/PremiumManager.ts @@ -1,9 +1,7 @@ import { ConfigService } from "@nestjs/config"; import { EventEmitter2 } from "@nestjs/event-emitter"; import { Client } from "discord.js"; -import { BaseManager } from "./BaseManager"; -import { QueueStore } from "./QueueStore"; -import { RedisClient } from "./RedisClient"; +import { BaseManager, QueueStore, RedisClient } from "."; export class PremiumManager extends BaseManager { public constructor(client: Client, config: ConfigService, eventEmitter: EventEmitter2, redis: RedisClient) { diff --git a/src/modules/music/classes/QueueStore.ts b/src/modules/music/classes/QueueStore.ts index 3c05f881..a810b2ce 100644 --- a/src/modules/music/classes/QueueStore.ts +++ b/src/modules/music/classes/QueueStore.ts @@ -1,5 +1,5 @@ import { QueueStoreManager, StoredQueue } from "lavalink-client"; -import { RedisClient } from "./RedisClient"; +import { RedisClient } from "."; export class QueueStore implements QueueStoreManager { public constructor(private redis: RedisClient) {} diff --git a/src/modules/music/classes/RedisClient.ts b/src/modules/music/classes/RedisClient.ts index 36a7d4ae..e81cf9a1 100644 --- a/src/modules/music/classes/RedisClient.ts +++ b/src/modules/music/classes/RedisClient.ts @@ -1,10 +1,19 @@ -import { Redis } from "ioredis"; +import { Logger } from "@nestjs/common"; +import { Cluster } from "ioredis"; -export class RedisClient extends Redis { +export class RedisClient extends Cluster { public constructor() { - super({ - port: Number(process.env.RedisPort), - host: process.env.RedisHost, + super([{ host: process.env.RedisHost, port: Number(process.env.RedisPort) }]); + + const logger = new Logger(RedisClient.name); + this.ping((err, result) => { + logger.log("Pinging..."); + if (err) { + logger.error(`Error when trying to connect: ${err.message}`); + } else { + logger.log(`Response: ${result}`); + } + this.quit(); }); } } diff --git a/yarn.lock b/yarn.lock index b3db0981..92667d9a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4149,9 +4149,9 @@ __metadata: languageName: node linkType: hard -"ioredis@npm:^5.3.2": - version: 5.3.2 - resolution: "ioredis@npm:5.3.2" +"ioredis@npm:^5.4.1": + version: 5.4.1 + resolution: "ioredis@npm:5.4.1" dependencies: "@ioredis/commands": "npm:^1.1.1" cluster-key-slot: "npm:^1.1.0" @@ -4162,7 +4162,7 @@ __metadata: redis-errors: "npm:^1.2.0" redis-parser: "npm:^3.0.0" standard-as-callback: "npm:^2.1.0" - checksum: 10c0/0dd2b5b8004e891f5b62edf18ac223194f1f5204698ec827c903e789ea05b0b36f73395491749ec63c66470485bdfb228ccdf1714fbf631a0f78f33211f2c883 + checksum: 10c0/5d28b7c89a3cab5b76d75923d7d4ce79172b3a1ca9be690133f6e8e393a7a4b4ffd55513e618bbb5504fed80d9e1395c9d9531a7c5c5c84aa4c4e765cca75456 languageName: node linkType: hard @@ -5227,7 +5227,7 @@ __metadata: discord-api-types: "npm:^0.37.73" discord.js: "npm:^14.14.1" husky: "npm:^9.0.11" - ioredis: "npm:^5.3.2" + ioredis: "npm:^5.4.1" lavalink-client: "npm:^2.1.7" lint-staged: "npm:^15.2.2" moment: "npm:^2.30.1"