diff --git a/apps/barry/package.json b/apps/barry/package.json index 2ec056c..e41da4e 100644 --- a/apps/barry/package.json +++ b/apps/barry/package.json @@ -1,6 +1,6 @@ { "name": "barry", - "version": "1.2.0", + "version": "1.2.1", "description": "Barry is a versatile Discord bot that simplifies server management with a range of features such as moderation, leveling, and marketplace tools.", "repository": "HeadTriXz/Barry", "author": "HeadTriXz", @@ -28,9 +28,9 @@ }, "dependencies": { "@barry-bot/core": "*", - "@discordjs/core": "^1.3.0-dev.1721153953-efa16a609", - "@discordjs/rest": "^2.3.0", - "@discordjs/ws": "^1.2.0-dev.1721153959-efa16a609", + "@discordjs/core": "^2.0.0", + "@discordjs/rest": "^2.4.0", + "@discordjs/ws": "^2.0.0", "@napi-rs/canvas": "^0.1.41", "@prisma/client": "^5.0.0", "canvas-constructor": "^7.0.1", diff --git a/package-lock.json b/package-lock.json index bdef3ff..4e08660 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,9 +36,9 @@ "license": "AGPL-3.0", "dependencies": { "@barry-bot/core": "*", - "@discordjs/core": "^1.3.0-dev.1721153953-efa16a609", - "@discordjs/rest": "^2.3.0", - "@discordjs/ws": "^1.2.0-dev.1721153959-efa16a609", + "@discordjs/core": "^2.0.0", + "@discordjs/rest": "^2.4.0", + "@discordjs/ws": "^2.0.0", "@napi-rs/canvas": "^0.1.41", "@prisma/client": "^5.0.0", "canvas-constructor": "^7.0.1", @@ -57,38 +57,6 @@ "node": ">=20.0.0" } }, - "apps/barry/node_modules/@discordjs/ws": { - "version": "1.2.0-dev.1721153959-efa16a609", - "resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.2.0-dev.1721153959-efa16a609.tgz", - "integrity": "sha512-Vo6HhS7R9F2jJV2rykLsloQPJKdiPR/PpHslFy192EgkOByiwC3JhL7+wzL6ATNitl6lsDTzQLwsPpMj1crbDA==", - "dependencies": { - "@discordjs/collection": "^2.1.0", - "@discordjs/rest": "^2.3.0", - "@discordjs/util": "^1.1.0", - "@sapphire/async-queue": "^1.5.2", - "@types/ws": "^8.5.10", - "@vladfrangu/async_event_emitter": "^2.2.4", - "discord-api-types": "0.37.90", - "tslib": "^2.6.2", - "ws": "^8.17.0" - }, - "engines": { - "node": ">=16.11.0" - }, - "funding": { - "url": "https://github.com/discordjs/discord.js?sponsor" - } - }, - "apps/barry/node_modules/discord-api-types": { - "version": "0.37.90", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.90.tgz", - "integrity": "sha512-lpOJSGrqHuXoM4FV/2HtjoaJpCClGFHpRNIdZEW8zPINlsCHNSfIwA2EQ8dxeE6k1QhhTuM9ZlOGVYXoU7FLgA==" - }, - "apps/barry/node_modules/tslib": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", - "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" - }, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", @@ -130,9 +98,9 @@ "dev": true }, "node_modules/@discordjs/collection": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.0.tgz", - "integrity": "sha512-mLcTACtXUuVgutoznkh6hS3UFqYirDYAg5Dc1m8xn6OvPjetnUlf/xjtqnnc47OwWdaoCQnHmHh9KofhD6uRqw==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.1.tgz", + "integrity": "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==", "engines": { "node": ">=18" }, @@ -141,93 +109,88 @@ } }, "node_modules/@discordjs/core": { - "version": "1.3.0-dev.1721153953-efa16a609", - "resolved": "https://registry.npmjs.org/@discordjs/core/-/core-1.3.0-dev.1721153953-efa16a609.tgz", - "integrity": "sha512-BUbuXjxfEYqw32TcsBDblpYbcm8ohB8G3H5BFtWFtKCqcwQVny4WE6+rmaMzb202a3aZ89PZeeOU1BPBlz0p3Q==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@discordjs/core/-/core-2.0.0.tgz", + "integrity": "sha512-N5PaTaEsEJyX9/KpcRN4+Jzc2qWvi55DVD2U6PXlbK1+C1du+B7yC4ey5yNeI2lG8k4vha3iGPR0LPemUkvIZA==", "dependencies": { - "@discordjs/rest": "^2.3.0", - "@discordjs/util": "^1.1.0", - "@discordjs/ws": "^1.1.1", + "@discordjs/rest": "^2.4.0", + "@discordjs/util": "^1.1.1", + "@discordjs/ws": "^2.0.0", "@sapphire/snowflake": "^3.5.3", - "@vladfrangu/async_event_emitter": "^2.2.4", - "discord-api-types": "0.37.90" + "@vladfrangu/async_event_emitter": "^2.4.6", + "discord-api-types": "0.37.97" }, "engines": { - "node": ">=18" + "node": ">=20" }, "funding": { "url": "https://github.com/discordjs/discord.js?sponsor" } }, - "node_modules/@discordjs/core/node_modules/discord-api-types": { - "version": "0.37.90", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.90.tgz", - "integrity": "sha512-lpOJSGrqHuXoM4FV/2HtjoaJpCClGFHpRNIdZEW8zPINlsCHNSfIwA2EQ8dxeE6k1QhhTuM9ZlOGVYXoU7FLgA==" - }, "node_modules/@discordjs/rest": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.3.0.tgz", - "integrity": "sha512-C1kAJK8aSYRv3ZwMG8cvrrW4GN0g5eMdP8AuN8ODH5DyOCbHgJspze1my3xHOAgwLJdKUbWNVyAeJ9cEdduqIg==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.4.0.tgz", + "integrity": "sha512-Xb2irDqNcq+O8F0/k/NaDp7+t091p+acb51iA4bCKfIn+WFWd6HrNvcsSbMMxIR9NjcMZS6NReTKygqiQN+ntw==", "dependencies": { - "@discordjs/collection": "^2.1.0", - "@discordjs/util": "^1.1.0", - "@sapphire/async-queue": "^1.5.2", + "@discordjs/collection": "^2.1.1", + "@discordjs/util": "^1.1.1", + "@sapphire/async-queue": "^1.5.3", "@sapphire/snowflake": "^3.5.3", - "@vladfrangu/async_event_emitter": "^2.2.4", - "discord-api-types": "0.37.83", + "@vladfrangu/async_event_emitter": "^2.4.6", + "discord-api-types": "0.37.97", "magic-bytes.js": "^1.10.0", - "tslib": "^2.6.2", - "undici": "6.13.0" + "tslib": "^2.6.3", + "undici": "6.19.8" }, "engines": { - "node": ">=16.11.0" + "node": ">=18" }, "funding": { "url": "https://github.com/discordjs/discord.js?sponsor" } }, "node_modules/@discordjs/rest/node_modules/tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" }, "node_modules/@discordjs/util": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.1.0.tgz", - "integrity": "sha512-IndcI5hzlNZ7GS96RV3Xw1R2kaDuXEp7tRIy/KlhidpN/BQ1qh1NZt3377dMLTa44xDUNKT7hnXkA/oUAzD/lg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.1.1.tgz", + "integrity": "sha512-eddz6UnOBEB1oITPinyrB2Pttej49M9FZQY8NxgEvc3tq6ZICZ19m70RsmzRdDHk80O9NoYN/25AqJl8vPVf/g==", "engines": { - "node": ">=16.11.0" + "node": ">=18" }, "funding": { "url": "https://github.com/discordjs/discord.js?sponsor" } }, "node_modules/@discordjs/ws": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.1.1.tgz", - "integrity": "sha512-PZ+vLpxGCRtmr2RMkqh8Zp+BenUaJqlS6xhgWKEZcgC/vfHLEzpHtKkB0sl3nZWpwtcKk6YWy+pU3okL2I97FA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-2.0.0.tgz", + "integrity": "sha512-VSVFMOFE+G9bp/2+4e/lFySIU+urxW8NPRXPsKLbP9AUl1MvQxoUVIUfPjZkUP23jjQh+AvWWm6vaA0A5Rb2Rg==", "dependencies": { - "@discordjs/collection": "^2.1.0", - "@discordjs/rest": "^2.3.0", - "@discordjs/util": "^1.1.0", - "@sapphire/async-queue": "^1.5.2", - "@types/ws": "^8.5.10", - "@vladfrangu/async_event_emitter": "^2.2.4", - "discord-api-types": "0.37.83", - "tslib": "^2.6.2", - "ws": "^8.16.0" + "@discordjs/collection": "^2.1.1", + "@discordjs/rest": "^2.4.0", + "@discordjs/util": "^1.1.1", + "@sapphire/async-queue": "^1.5.3", + "@types/ws": "^8.5.12", + "@vladfrangu/async_event_emitter": "^2.4.6", + "discord-api-types": "0.37.97", + "tslib": "^2.6.3", + "ws": "^8.18.0" }, "engines": { - "node": ">=16.11.0" + "node": ">=20" }, "funding": { "url": "https://github.com/discordjs/discord.js?sponsor" } }, "node_modules/@discordjs/ws/node_modules/tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" }, "node_modules/@esbuild/android-arm": { "version": "0.18.20", @@ -1619,9 +1582,9 @@ ] }, "node_modules/@sapphire/async-queue": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.2.tgz", - "integrity": "sha512-7X7FFAA4DngXUl95+hYbUF19bp1LGiffjJtu7ygrZrbdCSsdDDBaSjB7Akw0ZbOu6k0xpXyljnJ6/RZUvLfRdg==", + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.3.tgz", + "integrity": "sha512-x7zadcfJGxFka1Q3f8gCts1F0xMwCKbZweM85xECGI0hBTeIZJGGCrHgLggihBoprlQ/hBmDR5LKfIPqnmHM3w==", "engines": { "node": ">=v14.0.0", "npm": ">=7.0.0" @@ -1835,9 +1798,9 @@ "integrity": "sha512-UE7oxhQLLd9gub6JKIAhDq06T0F6FnztwMNRvYgjeQSBeMc1ZG/tA47EwfduvkuQS8apbkM/lpLpWsaCeYsXVg==" }, "node_modules/@types/ws": { - "version": "8.5.10", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.10.tgz", - "integrity": "sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==", + "version": "8.5.12", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.12.tgz", + "integrity": "sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==", "dependencies": { "@types/node": "*" } @@ -2157,9 +2120,9 @@ } }, "node_modules/@vladfrangu/async_event_emitter": { - "version": "2.4.4", - "resolved": "https://registry.npmjs.org/@vladfrangu/async_event_emitter/-/async_event_emitter-2.4.4.tgz", - "integrity": "sha512-ZL62PFXEIeGUI8btfJ5S8Flc286eU1ZUSjwyFQtIGXfRUDPZKO+CDJMYb1R71LjGWRZ4n202O+a6FGjsgTw58g==", + "version": "2.4.6", + "resolved": "https://registry.npmjs.org/@vladfrangu/async_event_emitter/-/async_event_emitter-2.4.6.tgz", + "integrity": "sha512-RaI5qZo6D2CVS6sTHFKg1v5Ohq/+Bo2LZ5gzUEwZ/WkHhwtGTCB/sVLw8ijOkAUxasZ+WshN/Rzj4ywsABJ5ZA==", "engines": { "node": ">=v14.0.0", "npm": ">=7.0.0" @@ -2731,9 +2694,9 @@ } }, "node_modules/discord-api-types": { - "version": "0.37.83", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.83.tgz", - "integrity": "sha512-urGGYeWtWNYMKnYlZnOnDHm8fVRffQs3U0SpE8RHeiuLKb/u92APS8HoQnPTFbnXmY1vVnXjXO4dOxcAn3J+DA==" + "version": "0.37.97", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.97.tgz", + "integrity": "sha512-No1BXPcVkyVD4ZVmbNgDKaBoqgeQ+FJpzZ8wqHkfmBnTZig1FcH3iPPersiK1TUIAzgClh2IvOuVUYfcWLQAOA==" }, "node_modules/doctrine": { "version": "3.0.0", @@ -5788,11 +5751,11 @@ "dev": true }, "node_modules/undici": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.13.0.tgz", - "integrity": "sha512-Q2rtqmZWrbP8nePMq7mOJIN98M0fYvSgV89vwl/BQRT4mDOeY2GXZngfGpcBBhtky3woM7G24wZV3Q304Bv6cw==", + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.19.8.tgz", + "integrity": "sha512-U8uCCl2x9TK3WANvmBavymRzxbfFYG+tAu+fgx3zxQy3qdagQqBLwJVrdyO1TBfUXvfKveMKJZhpvUYoOjM+4g==", "engines": { - "node": ">=18.0" + "node": ">=18.17" } }, "node_modules/undici-types": { @@ -6615,9 +6578,9 @@ "license": "MIT", "dependencies": { "@barry-bot/logger": "*", - "@discordjs/core": "^1.3.0-dev.1721153953-efa16a609", - "@discordjs/rest": "^2.3.0", - "@discordjs/ws": "^1.2.0-dev.1721153959-efa16a609", + "@discordjs/core": "^2.0.0", + "@discordjs/rest": "^2.4.0", + "@discordjs/ws": "^2.0.0", "fastify": "^4.15.0", "tweetnacl": "^1.0.3" }, @@ -6628,38 +6591,6 @@ "node": ">=20.0.0" } }, - "packages/core/node_modules/@discordjs/ws": { - "version": "1.2.0-dev.1721153959-efa16a609", - "resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.2.0-dev.1721153959-efa16a609.tgz", - "integrity": "sha512-Vo6HhS7R9F2jJV2rykLsloQPJKdiPR/PpHslFy192EgkOByiwC3JhL7+wzL6ATNitl6lsDTzQLwsPpMj1crbDA==", - "dependencies": { - "@discordjs/collection": "^2.1.0", - "@discordjs/rest": "^2.3.0", - "@discordjs/util": "^1.1.0", - "@sapphire/async-queue": "^1.5.2", - "@types/ws": "^8.5.10", - "@vladfrangu/async_event_emitter": "^2.2.4", - "discord-api-types": "0.37.90", - "tslib": "^2.6.2", - "ws": "^8.17.0" - }, - "engines": { - "node": ">=16.11.0" - }, - "funding": { - "url": "https://github.com/discordjs/discord.js?sponsor" - } - }, - "packages/core/node_modules/discord-api-types": { - "version": "0.37.90", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.90.tgz", - "integrity": "sha512-lpOJSGrqHuXoM4FV/2HtjoaJpCClGFHpRNIdZEW8zPINlsCHNSfIwA2EQ8dxeE6k1QhhTuM9ZlOGVYXoU7FLgA==" - }, - "packages/core/node_modules/tslib": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", - "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" - }, "packages/logger": { "name": "@barry-bot/logger", "version": "1.0.1", @@ -6676,7 +6607,7 @@ "version": "1.0.1", "license": "MIT", "devDependencies": { - "@discordjs/core": "^1.3.0-dev.1721153953-efa16a609" + "@discordjs/core": "^2.0.0" }, "engines": { "node": ">=20.0.0" diff --git a/package.json b/package.json index 71749cd..3fdcdc9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "barry", - "version": "1.2.0", + "version": "1.2.1", "description": "Barry is a versatile Discord bot that simplifies server management with a range of features such as moderation, leveling, and marketplace tools.", "repository": "HeadTriXz/Barry", "author": "HeadTriXz", diff --git a/packages/core/package.json b/packages/core/package.json index 732e38f..d67afe3 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@barry-bot/core", - "version": "1.1.0", + "version": "1.1.1", "description": "A toolkit for building advanced Discord bots.", "repository": "HeadTriXz/Barry", "author": "HeadTriXz", @@ -24,9 +24,9 @@ }, "dependencies": { "@barry-bot/logger": "*", - "@discordjs/core": "^1.3.0-dev.1721153953-efa16a609", - "@discordjs/rest": "^2.3.0", - "@discordjs/ws": "^1.2.0-dev.1721153959-efa16a609", + "@discordjs/core": "^2.0.0", + "@discordjs/rest": "^2.4.0", + "@discordjs/ws": "^2.0.0", "fastify": "^4.15.0", "tweetnacl": "^1.0.3" }, diff --git a/packages/core/src/Client.ts b/packages/core/src/Client.ts index 734ec59..67e957d 100644 --- a/packages/core/src/Client.ts +++ b/packages/core/src/Client.ts @@ -15,10 +15,10 @@ import { import { type API, type APIInteraction, + type APIVoiceState, type GatewayDispatchPayload, - type GatewayVoiceState, type MappedEvents, - type WithIntrinsicProps, + type ToEventProps, GatewayDispatchEvents } from "@discordjs/core"; @@ -42,12 +42,12 @@ type IncludedEvents = Omit< * A mapped type that extracts the intrinsic props from the values of a given mapped type. */ export type ClientEvents = { - [K in keyof IncludedEvents]: MappedEvents[K] extends [WithIntrinsicProps] + [K in keyof IncludedEvents]: MappedEvents[K] extends [ToEventProps] ? [U] : MappedEvents[K]; } & { [GatewayDispatchEvents.InteractionCreate]: [AnyInteraction]; - [GatewayDispatchEvents.VoiceStateUpdate]: [GatewayVoiceState, string?]; + [GatewayDispatchEvents.VoiceStateUpdate]: [APIVoiceState, string?]; }; /** @@ -224,8 +224,8 @@ export class Client extends EventEmitter { this.interactions = new InteractionService(this); this.modules = new ModuleService(); - this.gateway?.on(WebSocketShardEvents.Dispatch, ({ data }) => { - this.#handleGatewayDispatchEvent(data); + this.gateway?.on(WebSocketShardEvents.Dispatch, (dispatch) => { + this.#handleGatewayDispatchEvent(dispatch); }); this.server?.post(this.#options.serverEndpoint, async (body, respond) => { diff --git a/packages/core/tests/Client.test.ts b/packages/core/tests/Client.test.ts index 2fdaf0e..7f0db6c 100644 --- a/packages/core/tests/Client.test.ts +++ b/packages/core/tests/Client.test.ts @@ -8,8 +8,8 @@ import { } from "../src/index.js"; import { type API, + type APIVoiceState, type GatewayMessageDeleteDispatchData, - type GatewayVoiceState, GatewayDispatchEvents, GatewayOpcodes } from "@discordjs/core"; @@ -148,14 +148,11 @@ describe("Client", () => { }; gatewaySpy.mock.calls[0][1]({ - data: { - op: GatewayOpcodes.Dispatch, - t: GatewayDispatchEvents.MessageDelete, - d: deleteEvent, - s: 0 - }, - shardId: 0 - }); + op: GatewayOpcodes.Dispatch, + t: GatewayDispatchEvents.MessageDelete, + d: deleteEvent, + s: 0 + }, 0); expect(gatewaySpy).toHaveBeenCalledOnce(); expect(onMessageDelete).toHaveBeenCalledOnce(); @@ -171,14 +168,11 @@ describe("Client", () => { const handleSpy = vi.spyOn(client.interactions, "handle").mockResolvedValue(); gatewaySpy.mock.calls[0][1]({ - data: { - op: GatewayOpcodes.Dispatch, - t: GatewayDispatchEvents.InteractionCreate, - d: mockPingInteraction, - s: 0 - }, - shardId: 0 - }); + op: GatewayOpcodes.Dispatch, + t: GatewayDispatchEvents.InteractionCreate, + d: mockPingInteraction, + s: 0 + }, 0); expect(gatewaySpy).toHaveBeenCalledOnce(); expect(handleSpy).toHaveBeenCalledOnce(); @@ -189,7 +183,7 @@ describe("Client", () => { channel_id: "30527482987641765", guild_id: "68239102456844360", user_id: "257522665441460225" - } as GatewayVoiceState; + } as APIVoiceState; it("should handle incoming voice state update events and update 'voiceConnections'", () => { const gateway: Gateway = new MockGateway(); @@ -198,20 +192,17 @@ describe("Client", () => { options.gateway = gateway; client = new Client(options); - const onVoiceStateUpdate = vi.fn<[GatewayVoiceState, string | undefined]>(); + const onVoiceStateUpdate = vi.fn<[APIVoiceState, string | undefined]>(); client.on(GatewayDispatchEvents.VoiceStateUpdate, onVoiceStateUpdate); expect(client.voiceConnections.size).toBe(0); gatewaySpy.mock.calls[0][1]({ - data: { - op: GatewayOpcodes.Dispatch, - t: GatewayDispatchEvents.VoiceStateUpdate, - d: voiceStateUpdateEvent, - s: 0 - }, - shardId: 0 - }); + op: GatewayOpcodes.Dispatch, + t: GatewayDispatchEvents.VoiceStateUpdate, + d: voiceStateUpdateEvent, + s: 0 + }, 0); expect(gatewaySpy).toHaveBeenCalledOnce(); expect(onVoiceStateUpdate).toHaveBeenCalledOnce(); @@ -230,26 +221,20 @@ describe("Client", () => { expect(client.voiceConnections.size).toBe(0); gatewaySpy.mock.calls[0][1]({ - data: { - op: GatewayOpcodes.Dispatch, - t: GatewayDispatchEvents.VoiceStateUpdate, - d: voiceStateUpdateEvent, - s: 0 - }, - shardId: 0 - }); + op: GatewayOpcodes.Dispatch, + t: GatewayDispatchEvents.VoiceStateUpdate, + d: voiceStateUpdateEvent, + s: 0 + }, 0); expect(client.voiceConnections.size).toBe(1); gatewaySpy.mock.calls[0][1]({ - data: { - op: GatewayOpcodes.Dispatch, - t: GatewayDispatchEvents.VoiceStateUpdate, - d: { ...voiceStateUpdateEvent, channel_id: null }, - s: 0 - }, - shardId: 0 - }); + op: GatewayOpcodes.Dispatch, + t: GatewayDispatchEvents.VoiceStateUpdate, + d: { ...voiceStateUpdateEvent, channel_id: null }, + s: 0 + }, 0); expect(client.voiceConnections.size).toBe(0); }); @@ -261,28 +246,22 @@ describe("Client", () => { options.gateway = gateway; client = new Client(options); - const onVoiceStateUpdate = vi.fn<[GatewayVoiceState, string | undefined]>(); + const onVoiceStateUpdate = vi.fn<[APIVoiceState, string | undefined]>(); client.on(GatewayDispatchEvents.VoiceStateUpdate, onVoiceStateUpdate); gatewaySpy.mock.calls[0][1]({ - data: { - op: GatewayOpcodes.Dispatch, - t: GatewayDispatchEvents.VoiceStateUpdate, - d: voiceStateUpdateEvent, - s: 0 - }, - shardId: 0 - }); + op: GatewayOpcodes.Dispatch, + t: GatewayDispatchEvents.VoiceStateUpdate, + d: voiceStateUpdateEvent, + s: 0 + }, 0); gatewaySpy.mock.calls[0][1]({ - data: { - op: GatewayOpcodes.Dispatch, - t: GatewayDispatchEvents.VoiceStateUpdate, - d: { ...voiceStateUpdateEvent, channel_id: "60527482987641760" }, - s: 0 - }, - shardId: 0 - }); + op: GatewayOpcodes.Dispatch, + t: GatewayDispatchEvents.VoiceStateUpdate, + d: { ...voiceStateUpdateEvent, channel_id: "60527482987641760" }, + s: 0 + }, 0); expect(gatewaySpy).toHaveBeenCalledOnce(); expect(onVoiceStateUpdate).toHaveBeenCalledTimes(2); @@ -300,34 +279,25 @@ describe("Client", () => { client.on(GatewayDispatchEvents.VoiceStateUpdate, vi.fn()); gatewaySpy.mock.calls[0][1]({ - data: { - op: GatewayOpcodes.Dispatch, - t: GatewayDispatchEvents.VoiceStateUpdate, - d: voiceStateUpdateEvent, - s: 0 - }, - shardId: 0 - }); + op: GatewayOpcodes.Dispatch, + t: GatewayDispatchEvents.VoiceStateUpdate, + d: voiceStateUpdateEvent, + s: 0 + }, 0); gatewaySpy.mock.calls[0][1]({ - data: { - op: GatewayOpcodes.Dispatch, - t: GatewayDispatchEvents.VoiceStateUpdate, - d: { ...voiceStateUpdateEvent, guild_id: "60527482987641760" }, - s: 0 - }, - shardId: 0 - }); + op: GatewayOpcodes.Dispatch, + t: GatewayDispatchEvents.VoiceStateUpdate, + d: { ...voiceStateUpdateEvent, guild_id: "60527482987641760" }, + s: 0 + }, 0); gatewaySpy.mock.calls[0][1]({ - data: { - op: GatewayOpcodes.Dispatch, - t: GatewayDispatchEvents.VoiceStateUpdate, - d: { ...voiceStateUpdateEvent, guild_id: undefined }, - s: 0 - }, - shardId: 0 - }); + op: GatewayOpcodes.Dispatch, + t: GatewayDispatchEvents.VoiceStateUpdate, + d: { ...voiceStateUpdateEvent, guild_id: undefined }, + s: 0 + }, 0); expect(client.voiceConnections.size).toBe(3); }); diff --git a/packages/testing/package.json b/packages/testing/package.json index 33fd318..518009d 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -1,6 +1,6 @@ { "name": "@barry-bot/testing", - "version": "1.0.1", + "version": "1.0.2", "description": "A collection of mock data for testing Discord bots.", "repository": "HeadTriXz/Barry", "author": "HeadTriXz", @@ -24,6 +24,6 @@ "typecheck": "tsc --noEmit" }, "devDependencies": { - "@discordjs/core": "^1.3.0-dev.1721153953-efa16a609" + "@discordjs/core": "^2.0.0" } }