From 5a4fef855e9209379268257b12e7318221fe1dba Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Sun, 8 May 2022 09:57:06 -0400 Subject: [PATCH 1/4] Proxy delete channel tests (#2174) * feat: delete channel tests * fix: use new tests in ci * Update testss/deps.ts Co-authored-by: LTS20050703 <87189679+lts20050703@users.noreply.github.com> Co-authored-by: LTS20050703 <87189679+lts20050703@users.noreply.github.com> --- .github/workflows/test.yml | 4 +++- helpers/channels/getChannel.ts | 11 +++++---- site/docs/general/migrating.md | 5 ++-- template/bigbot/src/bot/types/command.ts | 10 ++++---- testss/channels/deleteWithReason.test.ts | 23 ++++++++++++++++++ testss/channels/deleteWithoutReason.test.ts | 24 +++++++++++++++++++ testss/deps.ts | 2 ++ testss/mod.ts | 26 +++++++++++++++++++++ testss/utils.ts | 21 +++++++++++++++++ transformers/channel.ts | 5 ++-- transformers/guild.ts | 15 +++++++----- transformers/message.ts | 16 ++++++++----- 12 files changed, 135 insertions(+), 27 deletions(-) create mode 100644 testss/channels/deleteWithReason.test.ts create mode 100644 testss/channels/deleteWithoutReason.test.ts create mode 100644 testss/deps.ts create mode 100644 testss/mod.ts create mode 100644 testss/utils.ts diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e487d06e8..7c8d9c462 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: run: deno cache template/beginner/mod.ts template/bigbot/src/bot/mod.ts template/bigbot/src/gateway/mod.ts template/bigbot/src/rest/mod.ts template/minimal/mod.ts - name: Run test script for maintainers if: ${{ github.actor == 'Skillz4Killz' || github.actor == 'itohatweb' }} - run: deno test --unstable --coverage=coverage -A tests/mod.ts + run: deno test --unstable --coverage=coverage -A testss/ - name: Create coverage report if: github.ref == 'refs/heads/main' run: deno coverage --exclude=tests ./coverage --lcov > coverage.lcov @@ -43,3 +43,5 @@ jobs: file: ./coverage.lcov env: DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }} + PROXY_REST_SECRET: ${{ secrets.PROXY_REST_SECRET }} + PROXY_REST_URL: ${{ secrets.PROXY_REST_URL }} diff --git a/helpers/channels/getChannel.ts b/helpers/channels/getChannel.ts index 06ab574a1..60f9d7fe2 100644 --- a/helpers/channels/getChannel.ts +++ b/helpers/channels/getChannel.ts @@ -9,8 +9,11 @@ export async function getChannel(bot: Bot, channelId: bigint) { bot.constants.endpoints.CHANNEL_BASE(channelId), ); - return bot.transformers.channel(bot, { - channel: result, - guildId: result.guild_id ? bot.transformers.snowflake(result.guild_id) : undefined, - }); + // IF A CHANNEL DOESN'T EXIST, DISCORD RETURNS `{}` + return result.id + ? bot.transformers.channel(bot, { + channel: result, + guildId: result.guild_id ? bot.transformers.snowflake(result.guild_id) : undefined, + }) + : undefined; } diff --git a/site/docs/general/migrating.md b/site/docs/general/migrating.md index 929925458..746d293bb 100644 --- a/site/docs/general/migrating.md +++ b/site/docs/general/migrating.md @@ -62,9 +62,8 @@ fs.readdir("./src/events/", (err, files) => { const eventFunction = require(`./src/events/${file}`); if (eventFunction.disabled) return; const event = eventFunction.event || file.split(".")[0]; - const emitter = (typeof eventFunction.emitter === "string" - ? client[eventFunction.emitter] - : eventFunction.emitter) || client; + const emitter = + (typeof eventFunction.emitter === "string" ? client[eventFunction.emitter] : eventFunction.emitter) || client; const { once } = eventFunction; try { emitter[ diff --git a/template/bigbot/src/bot/types/command.ts b/template/bigbot/src/bot/types/command.ts index d04cf1dba..8d498a2e8 100644 --- a/template/bigbot/src/bot/types/command.ts +++ b/template/bigbot/src/bot/types/command.ts @@ -188,11 +188,11 @@ export type ConvertArgumentDefinitionsToArgs< UnionToIntersection< { [P in keyof T]: T[P] extends StringOptionalArgumentDefinition // STRING - ? { - [_ in getName]?: T[P]["choices"] extends readonly { name: string; value: string }[] ? // @ts-ignore ts being dumb - T[P]["choices"][number]["value"] - : string; - } + ? { + [_ in getName]?: T[P]["choices"] extends readonly { name: string; value: string }[] ? // @ts-ignore ts being dumb + T[P]["choices"][number]["value"] + : string; + } : T[P] extends StringArgumentDefinition ? { [_ in getName]: T[P]["choices"] extends readonly { name: string; value: string }[] ? // @ts-ignore ts being dumb T[P]["choices"][number]["value"] diff --git a/testss/channels/deleteWithReason.test.ts b/testss/channels/deleteWithReason.test.ts new file mode 100644 index 000000000..d9abc8936 --- /dev/null +++ b/testss/channels/deleteWithReason.test.ts @@ -0,0 +1,23 @@ +import { assertEquals, assertExists } from "../deps.ts"; +import { loadBot } from "../mod.ts"; +import { CACHED_COMMUNITY_GUILD_ID, delayUntil } from "../utils.ts"; + +Deno.test({ + name: "[channel] delete a channel with a reason", + async fn(t) { + const bot = loadBot(); + const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { + name: "delete-channel", + }); + + // Make sure the channel was created + assertExists(channel.id); + + // Delete the channel now with a reason + await bot.helpers.deleteChannel(channel.id, "with a reason"); + + // Check if channel still exists + const exists = await bot.helpers.getChannel(channel.id); + assertEquals(exists, undefined); + }, +}); diff --git a/testss/channels/deleteWithoutReason.test.ts b/testss/channels/deleteWithoutReason.test.ts new file mode 100644 index 000000000..1b7059b8b --- /dev/null +++ b/testss/channels/deleteWithoutReason.test.ts @@ -0,0 +1,24 @@ +import { assertEquals, assertExists, assertThrows, assertThrowsAsync } from "../deps.ts"; +import { loadBot } from "../mod.ts"; +import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; + +Deno.test({ + name: "[channel] delete a channel without a reason", + async fn(t) { + const bot = loadBot(); + // Create a channel to delete + const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { + name: "delete-channel", + }); + + // Make sure the channel was created + assertExists(channel.id); + + // Delete the channel now without a reason + await bot.helpers.deleteChannel(channel.id); + + // Check if channel still exists + const exists = await bot.helpers.getChannel(channel.id); + assertEquals(exists, undefined); + }, +}); diff --git a/testss/deps.ts b/testss/deps.ts new file mode 100644 index 000000000..4db277891 --- /dev/null +++ b/testss/deps.ts @@ -0,0 +1,2 @@ +export { config as dotenv } from "https://deno.land/x/dotenv@v3.2.0/mod.ts"; +export * from "https://deno.land/std@0.137.0/testing/asserts.ts"; diff --git a/testss/mod.ts b/testss/mod.ts new file mode 100644 index 000000000..1fa43901b --- /dev/null +++ b/testss/mod.ts @@ -0,0 +1,26 @@ +import { createBot, createRestManager, runMethod } from "../mod.ts"; +import enableCachePlugin from "../plugins/cache/mod.ts"; +import { dotenv } from "./deps.ts"; + +dotenv({ export: true, path: `${Deno.cwd()}/.env` }); + +export function loadBot() { + const token = Deno.env.get("DISCORD_TOKEN"); + if (!token) throw new Error("Token was not provided."); + + const botId = BigInt(atob(token.split(".")[0])); + const bot = enableCachePlugin(createBot({ + events: {}, + intents: [], + botId, + token, + })); + + bot.rest = createRestManager({ + token, + customUrl: Deno.env.get("PROXY_REST_URL"), + secretKey: Deno.env.get("PROXY_REST_SECRET"), + }); + + return bot; +} diff --git a/testss/utils.ts b/testss/utils.ts new file mode 100644 index 000000000..e9ab3407b --- /dev/null +++ b/testss/utils.ts @@ -0,0 +1,21 @@ +export const CACHED_COMMUNITY_GUILD_ID = 907350958810480671n; + +export function delayUntil( + maxMs: number, + isReady: () => boolean | undefined | Promise, + timeoutTime = 100, +): Promise { + const maxTime = Date.now() + maxMs; + + async function hackyFix(resolve: () => void) { + if ((await isReady()) || Date.now() >= maxTime) { + resolve(); + } else { + setTimeout(() => { + hackyFix(resolve); + }, timeoutTime); + } + } + + return new Promise((resolve) => hackyFix(resolve)); +} diff --git a/transformers/channel.ts b/transformers/channel.ts index f81792c17..fb04a6952 100644 --- a/transformers/channel.ts +++ b/transformers/channel.ts @@ -45,8 +45,9 @@ export function transformChannel(bot: Bot, payload: { channel: DiscordChannel } ? bot.transformers.snowflake(payload.channel.last_message_id) : undefined, ownerId: payload.channel.owner_id ? bot.transformers.snowflake(payload.channel.owner_id) : undefined, - applicationId: payload.channel.application_id ? bot.transformers.snowflake(payload.channel.application_id) - : undefined, + applicationId: payload.channel.application_id + ? bot.transformers.snowflake(payload.channel.application_id) + : undefined, parentId: payload.channel.parent_id ? bot.transformers.snowflake(payload.channel.parent_id) : undefined, memberCount: payload.channel.member_count, messageCount: payload.channel.message_count, diff --git a/transformers/guild.ts b/transformers/guild.ts index cb0f723b5..788e2e77a 100644 --- a/transformers/guild.ts +++ b/transformers/guild.ts @@ -88,13 +88,16 @@ export function transformGuild(bot: Bot, payload: { guild: DiscordGuild } & { sh ownerId: payload.guild.owner_id ? bot.transformers.snowflake(payload.guild.owner_id) : 0n, permissions: payload.guild.permissions ? bot.transformers.snowflake(payload.guild.permissions) : 0n, afkChannelId: payload.guild.afk_channel_id ? bot.transformers.snowflake(payload.guild.afk_channel_id) : undefined, - widgetChannelId: payload.guild.widget_channel_id ? bot.transformers.snowflake(payload.guild.widget_channel_id) - : undefined, + widgetChannelId: payload.guild.widget_channel_id + ? bot.transformers.snowflake(payload.guild.widget_channel_id) + : undefined, applicationId: payload.guild.application_id ? bot.transformers.snowflake(payload.guild.application_id) : undefined, - systemChannelId: payload.guild.system_channel_id ? bot.transformers.snowflake(payload.guild.system_channel_id) - : undefined, - rulesChannelId: payload.guild.rules_channel_id ? bot.transformers.snowflake(payload.guild.rules_channel_id) - : undefined, + systemChannelId: payload.guild.system_channel_id + ? bot.transformers.snowflake(payload.guild.system_channel_id) + : undefined, + rulesChannelId: payload.guild.rules_channel_id + ? bot.transformers.snowflake(payload.guild.rules_channel_id) + : undefined, publicUpdatesChannelId: payload.guild.public_updates_channel_id ? bot.transformers.snowflake(payload.guild.public_updates_channel_id) : undefined, diff --git a/transformers/message.ts b/transformers/message.ts index b4b5aac72..eaded7a16 100644 --- a/transformers/message.ts +++ b/transformers/message.ts @@ -48,12 +48,15 @@ export function transformMessage(bot: Bot, payload: DiscordMessage) { ? Date.parse(payload.interaction.member.joined_at) : undefined, premiumSince: payload.interaction.member.premium_since - ? Date.parse(payload.interaction.member.premium_since) : undefined, + ? Date.parse(payload.interaction.member.premium_since) + : undefined, toggles: new MemberToggles(payload.interaction.member), - avatar: payload.interaction.member.avatar ? bot.utils.iconHashToBigInt(payload.interaction.member.avatar) - : undefined, + avatar: payload.interaction.member.avatar + ? bot.utils.iconHashToBigInt(payload.interaction.member.avatar) + : undefined, permissions: payload.interaction.member.permissions - ? bot.transformers.snowflake(payload.interaction.member.permissions) : undefined, + ? bot.transformers.snowflake(payload.interaction.member.permissions) + : undefined, communicationDisabledUntil: payload.interaction.member.communication_disabled_until ? Date.parse(payload.interaction.member.communication_disabled_until) : undefined, @@ -84,8 +87,9 @@ export function transformMessage(bot: Bot, payload: DiscordMessage) { channelId: payload.message_reference.channel_id ? bot.transformers.snowflake(payload.message_reference.channel_id) : undefined, - guildId: payload.message_reference.guild_id ? bot.transformers.snowflake(payload.message_reference.guild_id) - : undefined, + guildId: payload.message_reference.guild_id + ? bot.transformers.snowflake(payload.message_reference.guild_id) + : undefined, } : undefined, mentionedUserIds: payload.mentions ? payload.mentions.map((m) => bot.transformers.snowflake(m.id)) : [], From e31ee82d37f640ea8d38a0683b4500076c2c7ae9 Mon Sep 17 00:00:00 2001 From: Reboot-Codes <55662140+Reboot-Codes@users.noreply.github.com> Date: Sun, 8 May 2022 06:57:42 -0700 Subject: [PATCH 2/4] Fixing the BigBot Template (#2189) * Add `create-discordeno-bot` reference in README.md * Switch to deno tasks. * Fix `DISCORD_TOKEN` var * Fix `gateway` workers Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> --- README.md | 1 + template/bigbot/README.md | 97 +++++++++++++++++------------- template/bigbot/configs.ts | 2 +- template/bigbot/deno.json | 7 +++ template/bigbot/makefile | 6 +- template/bigbot/src/gateway/mod.ts | 14 +++-- 6 files changed, 77 insertions(+), 50 deletions(-) create mode 100644 template/bigbot/deno.json diff --git a/README.md b/README.md index 63efb22db..3ea81f268 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ these awesome official and unofficial templates: - [Discordeno Template (official)](https://github.com/discordeno/discordeno/tree/main/template) - [Serverless Slash Commands Template (official)](https://github.com/discordeno/serverless-deno-deploy-template) +- [`create-discordeno-bot` (WIP, unoffical)](https://github.com/Reboot-Codes/create-discordeno-bot/) - [Add Your Own!](https://github.com/discordeno/discordeno/pulls) ### Frameworks diff --git a/template/bigbot/README.md b/template/bigbot/README.md index 62ac8082a..7c47c9187 100644 --- a/template/bigbot/README.md +++ b/template/bigbot/README.md @@ -1,77 +1,90 @@ # Discordeno Big Bot Template -Support: https://discord.gg/ddeno +Support: -This template is designed for bots that aim or are already in millions of Discord servers. +This template is designed for bots that aim or are already in millions of +Discord servers. ## Setup - Use the template generator button to make your own copy. -- Delete all the template folders except the bigbot folder. -- Move all files from the bigbot folder to the root of the project. - - You may encounter an issue with .vscode but force move the files to the root of the project. We have setup special - import maps in this template that should override the general .vscode folder already in the root folder. -- Rename the .env.example file to .env -- Fill out the .env file -- Go to configs.ts file and remove all the intents you don't want in your bot. -- Install `make` if you want to make it easier to use. - - This may be switched to `deno tasks` when it is available. +- Delete all the template folders except the `bigbot` folder. +- Move all files from the `bigbot` folder to the root of the project. + - You may encounter an issue with .vscode but force move the files to the root + of the project. We have setup special import maps in this template that + should override the general .vscode folder already in the root folder. +- Rename the `.env.example` file to `.env` +- Fill out the `.env` file +- Go to `configs.ts` file and remove all the intents you don't want in your bot. ## Usage -- Always run the `rest` process first. `make rest` -- Start the `bot` process next. `make bot` -- Lastly, start the `gateway` process. `make gateway` +- Always run the `rest` process first. `deno task rest` +- Start the `bot` process next. `deno task bot` +- Lastly, start the `gateway` process. `deno task gateway` -Note: The `gateway` process and `rest` are designed not to be shut off. So once those are on, the only thing you should -be doing is restarting your `bot` process. +Note: The `gateway` process and `rest` are designed not to be shut off. So once +those are on, the only thing you should be doing is restarting your `bot` +process. ## Details ### Translating Application Commands -The template supports translations for application commands. This is possible using guild commands. If you use global -commands, translations will not work and will default to english. +The template supports translations for application commands. This is possible +using guild commands. If you use global commands, translations will not work and +will default to english. -If you prefer a different default(not english), please use the Find And Replace to change the `'english'` everywhere -necessary. +If you prefer a different default(not english), please use the Find And Replace +to change the `'english'` everywhere necessary. #### Autocomplete & Type Checking -One cool thing about the translations is that you will get autocomplete and type checking built in for all the keys. -This will ensure you do not miss a key to be translated. It will also make it easier to code by providing the -autocomplete functionality. +One cool thing about the translations is that you will get autocomplete and type +checking built in for all the keys. This will ensure you do not miss a key to be +translated. It will also make it easier to code by providing the autocomplete +functionality. ### Updating Application Commands -The template is designed in a way that you will no longer need to worry about updating or maintaing your commands. +The template is designed in a way that you will no longer need to worry about +updating or maintaing your commands. -- Global Commands: For simplicity you can add a line in mod.ts to update them globally. This generally takes 1 call and - isn't a deal breaker. - - `/update global` is also available on your development server, to trigger manually. -- Guild Commands: This is a bit more complicated. By default, our system will update guild commands on demand! Instead - of making a million requests for all your servers, we will update them as needed. +- Global Commands: For simplicity you can add a line in mod.ts to update them + globally. This generally takes 1 call and isn't a deal breaker. + - `/update global` is also available on your development server, to trigger + manually. +- Guild Commands: This is a bit more complicated. By default, our system will + update guild commands on demand! Instead of making a million requests for all + your servers, we will update them as needed. **Guild Commands Kwik & Command Versioning** -For Global Commands you can make 1 request to api to update all commands on restart. Its not a big deal. But with Guild -commands essentially you need to make a request per guild. This can get spammy. That would be crazy. To solve this we -created the concept of `commandVersions`. This basically will decide whether or not guild commands should be updated. +For Global Commands you can make 1 request to api to update all commands on +restart. Its not a big deal. But with Guild commands essentially you need to +make a request per guild. This can get spammy. That would be crazy. To solve +this we created the concept of `commandVersions`. This basically will decide +whether or not guild commands should be updated. -Kwik is a file based database I used in order to make this setup easy and allow any dev using this template to use a -database of their choice for their bot. I do not recommend using Kwik as your database. Please add a full database of -your choice for your bot. You can even replace Kwik should you choose in the database folder. +Kwik is a file based database I used in order to make this setup easy and allow +any dev using this template to use a database of their choice for their bot. I +do not recommend using Kwik as your database. Please add a full database of your +choice for your bot. You can even replace Kwik should you choose in the database +folder. Process: 1. You update your command options/args or create new commands etc... -2. Increment the `CURRENT_SLASH_COMMAND_VERSION` in `src/database/commandVersion.ts` +2. Increment the `CURRENT_SLASH_COMMAND_VERSION` in + `src/database/commandVersion.ts` -- I recommend moving this into your database so you can build a dev command or eval and update this on the fly as you - wish. +- I recommend moving this into your database so you can build a dev command or + eval and update this on the fly as you wish. -3. Now whenever a guild emits any event, this will make sure to update the guild commands if necessary. If it already - has the latest commands, it will just ignore. If it was never updated or is using an outdated version, it will update - it. +3. Now whenever a guild emits any event, this will make sure to update the guild + commands if necessary. If it already has the latest commands, it will just + ignore. If it was never updated or is using an outdated version, it will + update it. -Aside from the automated system, there is also the option of `/update guild id` to update a guild manually. +Aside from the automated system, there is also the option of `/update guild id` +to update a guild manually. diff --git a/template/bigbot/configs.ts b/template/bigbot/configs.ts index 01a452312..6fc1cb2a4 100644 --- a/template/bigbot/configs.ts +++ b/template/bigbot/configs.ts @@ -25,7 +25,7 @@ export const GATEWAY_INTENTS: (keyof typeof GatewayIntents)[] = [ if (!env.DISCORD_TOKEN) { throw new Error("DUDE! You did not provide a Discord token!"); } -export const DISCORD_TOKEN = `Bot ${env.DISCORD_TOKEN!}`; +export const DISCORD_TOKEN = env.DISCORD_TOKEN!; // Set as 0 to make it use default values. NOT RECOMMENDED TO DEFAULT FOR BIG BOTS!!!! export const MAX_SHARDS = env.MAX_SHARDS ? parseInt(env.MAX_SHARDS, 10) : 0; diff --git a/template/bigbot/deno.json b/template/bigbot/deno.json new file mode 100644 index 000000000..8c30258a2 --- /dev/null +++ b/template/bigbot/deno.json @@ -0,0 +1,7 @@ +{ + "tasks": { + "rest": "deno run -A --unstable --import-map ./importMap.json ./src/rest/mod.ts", + "bot": "deno run -A --unstable --import-map ./importMap.json ./src/bot/mod.ts", + "gateway": "deno run -A --unstable --import-map ./importMap.json ./src/gateway/mod.ts" + } +} diff --git a/template/bigbot/makefile b/template/bigbot/makefile index 19f482cf4..c3e21b895 100644 --- a/template/bigbot/makefile +++ b/template/bigbot/makefile @@ -1,8 +1,8 @@ rest: - deno run -A --unstable --import-map ./importMap.json rest/mod.ts + deno run -A --unstable --import-map ./importMap.json ./src/rest/mod.ts gateway: - deno run -A --unstable --import-map ./importMap.json src/gateway/mod.ts + deno run -A --unstable --import-map ./importMap.json ./src/gateway/mod.ts bot: - deno run -A --unstable --import-map ./importMap.json src/bot/mod.ts \ No newline at end of file + deno run -A --unstable --import-map ./importMap.json ./src/bot/mod.ts \ No newline at end of file diff --git a/template/bigbot/src/gateway/mod.ts b/template/bigbot/src/gateway/mod.ts index bbb53a60e..b798653f7 100644 --- a/template/bigbot/src/gateway/mod.ts +++ b/template/bigbot/src/gateway/mod.ts @@ -68,10 +68,16 @@ async function startGateway() { gateway.buckets.forEach((bucket, bucketId) => { for (let i = 0; i < bucket.workers.length; i++) { const workerId = bucket.workers[i][0]; - const worker = new Worker(new URL("./worker.js", import.meta.url).href, { - name: `w-${workerId}-b${bucketId}`, - type: "module", - }); + const worker = new Worker( + new URL("./worker.ts", import.meta.url).href, + { + name: `w-${workerId}-b${bucketId}`, + type: "module", + deno: { + namespace: true, + }, + }, + ); workers.set(workerId, worker); if (bucket.workers[i + 1]) { From 29ff5faecdce4812dee293e8eb3893c899457130 Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Sun, 8 May 2022 09:58:57 -0400 Subject: [PATCH 3/4] fix: edge case ack crashes big bots (#2190) --- gateway/handleOnMessage.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gateway/handleOnMessage.ts b/gateway/handleOnMessage.ts index bcaca849b..68f13785a 100644 --- a/gateway/handleOnMessage.ts +++ b/gateway/handleOnMessage.ts @@ -26,6 +26,11 @@ export async function handleOnMessage(gateway: GatewayManager, message: any, sha if (typeof message !== "string") return; const shard = gateway.shards.get(shardId); + + if (shard) { + // Edge case for big bots when too many events that 45 seconds are not enough for receving the heartbeat ack. As long as we are receving events no point in closing a connection. + shard.heartbeat.acknowledged = true; + } const messageData = JSON.parse(message) as DiscordGatewayPayload; gateway.debug("GW RAW", { shardId, payload: messageData }); @@ -52,8 +57,7 @@ export async function handleOnMessage(gateway: GatewayManager, message: any, sha if (shard) shard.safeRequestsPerShard = gateway.safeRequestsPerShard(gateway, shard); break; case GatewayOpcodes.HeartbeatACK: - if (gateway.shards.has(shardId)) { - const shard = gateway.shards.get(shardId)!; + if (shard) { shard.heartbeat.acknowledged = true; shard.heartbeat.lastReceivedAt = Date.now(); } From 6a85ac26314c8c5ccd754421e08c2f5bc5af58dd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 8 May 2022 09:59:14 -0400 Subject: [PATCH 4/4] build(deps): bump async from 2.6.3 to 2.6.4 in /site (#2175) Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4. - [Release notes](https://github.com/caolan/async/releases) - [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md) - [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4) --- updated-dependencies: - dependency-name: async dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> --- site/package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/site/package-lock.json b/site/package-lock.json index ec498d504..1785fdf1e 100644 --- a/site/package-lock.json +++ b/site/package-lock.json @@ -3753,9 +3753,9 @@ "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" }, "node_modules/async": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", - "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", "dependencies": { "lodash": "^4.17.14" } @@ -15638,9 +15638,9 @@ "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" }, "async": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", - "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", "requires": { "lodash": "^4.17.14" }