Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9d3451b
refactor: update Dockerfile and package.json for bun compatibility; s…
Larsundso Jan 14, 2026
a275a1c
refactor: replace bun commands with pnpm in Dockerfile and package.js…
Larsundso Jan 14, 2026
f0e46c7
refactor: simplify module imports in index.ts for improved readability
Larsundso Jan 14, 2026
6a3ce42
refactor: streamline ClusterManager startup process by removing unnec…
Larsundso Jan 15, 2026
a7b2a5e
refactor: enhance memory usage logging in index.ts and update run scr…
Larsundso Jan 15, 2026
efb7c1d
refactor: enhance memory usage logging in bot.ts and improve module i…
Larsundso Jan 15, 2026
96624ce
refactor: correct cache method from cacheDb to cachePub in EventBus.ts
Larsundso Jan 15, 2026
676a024
refactor: replace HGETALL with HSCAN for non-blocking access to large…
Larsundso Jan 16, 2026
371d4da
refactor: replace BunRedisWrapper with createRedisWrapper for Redis c…
Larsundso Jan 16, 2026
0bb917e
refactor: streamline event emission in EventBus and update cache hand…
Larsundso Jan 16, 2026
dbf0795
refactor: replace fixed expiration time with random duration for cach…
Larsundso Jan 16, 2026
040b7a0
feat: Implement Priority Queue system for managing Discord API requests
Larsundso Jan 19, 2026
4e2b320
refactor: Implement backpressure handling in RestQueue based on Redis…
Larsundso Jan 19, 2026
2bac550
feat: Implement cold start detection for event emission control
Larsundso Jan 20, 2026
cb49818
refactor: Enhance GatewayQueue with chunk timeout handling and skip e…
Larsundso Jan 20, 2026
fd24852
feat: Add completed request count logging to RestQueue
Larsundso Jan 20, 2026
c119131
feat: Implement in-flight task tracking for REST queue
Larsundso Jan 20, 2026
45016c2
feat: Add logging for enqueued guild and channel tasks in RestQueue
Larsundso Jan 20, 2026
518a421
feat: Implement bucket-based rate limiting in RestQueue
Larsundso Jan 21, 2026
4b1f5d3
feat: Implement task execution timeout to prevent hanging tasks in Re…
Larsundso Jan 21, 2026
2f9fe5f
feat: Remove firstChannelInteraction and related channel tasks
Larsundso Jan 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
FROM node:alpine
WORKDIR /app
FROM oven/bun:1.3

COPY ./package.json /app/package.json
COPY ./pnpm-lock.yaml /app/pnpm-lock.yaml
RUN npm install -g pnpm
RUN apt-get update && apt-get install -y \
build-essential \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN pnpm install
RUN pnpm build
RUN npm install -g pnpm

COPY . /app
WORKDIR /app
COPY ./.env /app/.env

WORKDIR /app
WORKDIR /app/Ayako/packages/Utility
RUN rm -rf ./dist
RUN pnpm install
RUN pnpm run build

WORKDIR /app/Ayako/packages/Gateway
COPY ./.env /app/Ayako/packages/Gateway/.env
RUN rm -rf ./dist
RUN pnpm install
RUN pnpm run build
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"type": "module",
"scripts": {
"build": "swc src -d dist --strip-leading-paths --copy-files",
"dev": "pnpm build && node --enable-source-maps --experimental-wasm-modules --experimental-json-modules ./dist/index.js --debug --warn --dev --debug-db --local",
"dev": "pnpm build && bun ./dist/index.js --debug --warn --dev --debug-db --local",
"lint": "pnpx eslint 'src/**/*.ts' --fix",
"run": "node --max-old-space-size=64 --no-deprecation --no-warnings --experimental-json-modules ./dist/index.js",
"run": "bun ./dist/index.js",
"start": "pnpm run run",
"watch": "swc src -d dist --strip-leading-paths --copy-files --watch"
},
Expand All @@ -19,7 +19,6 @@
"discord-hybrid-sharding": "^3.0.1",
"dotenv": "^17.2.3",
"glob": "^13.0.0",
"ioredis": "^5.9.1",
"node-schedule": "^2.1.1",
"prom-client": "^15.1.3"
},
Expand All @@ -32,6 +31,7 @@
"@swc/core": "1.15.8",
"@total-typescript/ts-reset": "^0.6.1",
"@types/glob": "^9.0.0",
"@types/bun": "latest",
"@types/node": "^25.0.7",
"@types/node-schedule": "^2.1.8",
"@typescript-eslint/eslint-plugin": "^8.53.0",
Expand Down
2 changes: 0 additions & 2 deletions src/BaseClient/Bot/CacheHandlers/AutoModeration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
type GatewayAutoModerationRuleUpdateDispatchData,
} from 'discord-api-types/gateway/v10';

import firstChannelInteraction from '../../../Util/firstChannelInteraction.js';
import firstGuildInteraction from '../../../Util/firstGuildInteraction.js';
import redis from '../Cache.js';

Expand All @@ -15,7 +14,6 @@ export default {
data: GatewayAutoModerationActionExecutionDispatchData,
) => {
firstGuildInteraction(data.guild_id);
if (data.channel_id) firstChannelInteraction(data.channel_id, data.guild_id);
},

[GatewayDispatchEvents.AutoModerationRuleCreate]: async (
Expand Down
30 changes: 9 additions & 21 deletions src/BaseClient/Bot/CacheHandlers/Channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {
type GatewayChannelUpdateDispatchData,
} from 'discord-api-types/gateway/v10';

import firstChannelInteraction from '../../../Util/firstChannelInteraction.js';
import requestChannelPins from '../../../Util/requestChannelPins.js';
import redis from '../Cache.js';

export default {
Expand All @@ -20,35 +18,27 @@ export default {
redis.pins.delAll(data.id);
redis.channelStatus.del(data.guild_id, data.id);

const pipeline = redis.cacheDb.pipeline();
const messages = await redis.cacheDb.hgetall(redis.messages.keystore(data.guild_id));

pipeline.hdel(
const messageKeys = await redis.cacheDb.hscanKeys(
redis.messages.keystore(data.guild_id),
...Object.keys(messages).filter((m) => m.includes(data.id)),
`*${data.id}*`,
);
pipeline.del(...Object.keys(messages).filter((m) => m.includes(data.id)));
await pipeline.exec();
},

[GatewayDispatchEvents.ChannelPinsUpdate]: async (data: GatewayChannelPinsUpdateDispatchData) => {
if (!data.guild_id) return;

const success = await firstChannelInteraction(data.channel_id, data.guild_id);
if (success) return;
if (messageKeys.length === 0) return;

await requestChannelPins(data.channel_id, data.guild_id);
const pipeline = redis.cacheDb.pipeline();
pipeline.hdel(redis.messages.keystore(data.guild_id), ...messageKeys);
pipeline.del(...messageKeys);
await pipeline.exec();
},

[GatewayDispatchEvents.ChannelPinsUpdate]: async (_: GatewayChannelPinsUpdateDispatchData) => {},

[GatewayDispatchEvents.ChannelUpdate]: async (data: GatewayChannelUpdateDispatchData) => {
firstChannelInteraction(data.id, data.guild_id);
redis.channels.set(data);
},

// eslint-disable-next-line @typescript-eslint/naming-convention
VOICE_CHANNEL_STATUS_UPDATE: async (data: { status: string; id: string; guild_id: string }) => {
firstChannelInteraction(data.id, data.guild_id);

if (!data.status?.length) {
redis.channelStatus.del(data.guild_id, data.id);
return;
Expand All @@ -63,8 +53,6 @@ export default {
guild_id: string;
channels: { status: string; id: string }[];
}) => {
await Promise.all(data.channels.map(async (c) => firstChannelInteraction(c.id, data.guild_id)));

await redis.channelStatus.delAll(data.guild_id);

data.channels.forEach((c) => {
Expand Down
Loading
Loading