diff --git a/services/kanao-cache/src/Listeners/Caches/DispatchListener.ts b/services/kanao-cache/src/Listeners/Caches/DispatchListener.ts index 702338aa..ae0291ac 100644 --- a/services/kanao-cache/src/Listeners/Caches/DispatchListener.ts +++ b/services/kanao-cache/src/Listeners/Caches/DispatchListener.ts @@ -6,7 +6,7 @@ import type { GatewayDispatchPayload } from "discord-api-types/v10"; import { GatewayDispatchEvents } from "discord-api-types/v10"; import type { ListenerContext } from "../../Stores/Listener.js"; import { Listener } from "../../Stores/Listener.js"; -import { clientId } from "../../config.js"; +import { clientId, dispatchMessage } from "../../config.js"; export class DispatchListener extends Listener { public constructor(context: ListenerContext) { @@ -45,9 +45,10 @@ export class DispatchListener extends Listener { } public static async dispatch(payload: { shardId: number; data: GatewayDispatchPayload; }): Promise { - const routing = new RoutedQueue(GatewayExchangeRoutes.DISPATCH, clientId) - .shard(payload.shardId); - - await container.client.cacheQueue.publish(RabbitMQ.GATEWAY_EXCHANGE, routing.key, Buffer.from(JSON.stringify(payload.data))); + if (dispatchMessage) { + const routing = new RoutedQueue(GatewayExchangeRoutes.DISPATCH, clientId) + .shard(payload.shardId); + await container.client.cacheQueue.publish(RabbitMQ.GATEWAY_EXCHANGE, routing.key, Buffer.from(JSON.stringify(payload.data))); + } } } diff --git a/services/kanao-cache/src/config.ts b/services/kanao-cache/src/config.ts index 3e307204..dfd030b8 100644 --- a/services/kanao-cache/src/config.ts +++ b/services/kanao-cache/src/config.ts @@ -22,3 +22,4 @@ export const stateMessages = process.env.STATE_MESSAGE === "true"; export const guildCreateGcEvery = Number(process.env.GUILD_CREATE_GC_EVERY ?? 150); export const prefetchCount = Number(process.env.PREFETCH_COUNT ?? 500); +export const dispatchMessage = process.env.DISPATCH_MESSAGE ? process.env.DISPATCH_MESSAGE === "true" : true;