From ebbf8743854eb390927ec093a92f0655da1d3158 Mon Sep 17 00:00:00 2001 From: chroventer Date: Fri, 2 Oct 2020 09:53:01 -0700 Subject: [PATCH 01/24] Use wasm zlib decompression @devcat --- deps.ts | 2 +- src/module/basicShard.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deps.ts b/deps.ts index 0856d2233..37a594163 100644 --- a/deps.ts +++ b/deps.ts @@ -7,4 +7,4 @@ export { isWebSocketPongEvent, } from "https://deno.land/std@0.67.0/ws/mod.ts"; export type { WebSocket } from "https://deno.land/std@0.67.0/ws/mod.ts"; -export { inflate } from "https://deno.land/x/zlib.es@v1.0.0/mod.ts"; +export { decompress as inflate } from "https://unpkg.com/@evan/wasm@0.0.9/target/zlib/deno.js"; diff --git a/src/module/basicShard.ts b/src/module/basicShard.ts index f83e43c63..cdab660e1 100644 --- a/src/module/basicShard.ts +++ b/src/module/basicShard.ts @@ -109,7 +109,7 @@ export async function createBasicShard( } if (message instanceof Uint8Array) { - message = new TextDecoder().decode(inflate(message as Uint8Array)); + message = new TextDecoder().decode(inflate(message, 9)); } if (typeof message === "string") { From c7ba6383256b01de96dcfd43b686c561b1d1b761 Mon Sep 17 00:00:00 2001 From: chroventer Date: Fri, 2 Oct 2020 23:08:00 +0400 Subject: [PATCH 02/24] Typo; this is why we need unit tests --- src/module/basicShard.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/basicShard.ts b/src/module/basicShard.ts index cdab660e1..b22c01d5f 100644 --- a/src/module/basicShard.ts +++ b/src/module/basicShard.ts @@ -109,7 +109,7 @@ export async function createBasicShard( } if (message instanceof Uint8Array) { - message = new TextDecoder().decode(inflate(message, 9)); + message = new TextDecoder().decode(inflate(message, 0)); } if (typeof message === "string") { From e7d3d00580322321716a2e399a1a36790ea92307 Mon Sep 17 00:00:00 2001 From: devcat Date: Fri, 2 Oct 2020 21:16:21 +0200 Subject: [PATCH 03/24] change to zlib zero-copy inflate --- deps.ts | 2 +- src/module/basicShard.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/deps.ts b/deps.ts index 37a594163..776b73054 100644 --- a/deps.ts +++ b/deps.ts @@ -7,4 +7,4 @@ export { isWebSocketPongEvent, } from "https://deno.land/std@0.67.0/ws/mod.ts"; export type { WebSocket } from "https://deno.land/std@0.67.0/ws/mod.ts"; -export { decompress as inflate } from "https://unpkg.com/@evan/wasm@0.0.9/target/zlib/deno.js"; +export { decompress_with as inflate } from "https://unpkg.com/@evan/wasm@0.0.11/target/zlib/deno.js"; diff --git a/src/module/basicShard.ts b/src/module/basicShard.ts index cdab660e1..19a50802d 100644 --- a/src/module/basicShard.ts +++ b/src/module/basicShard.ts @@ -24,6 +24,7 @@ import { handleDiscordPayload } from "./shardingManager.ts"; const basicShards = new Map(); const heartbeating = new Set(); +const utf8decoder = new TextDecoder(); export interface BasicShard { id: number; @@ -109,7 +110,11 @@ export async function createBasicShard( } if (message instanceof Uint8Array) { - message = new TextDecoder().decode(inflate(message, 9)); + message = inflate( + message, + 0, + (slice: Uint8Array) => utf8decoder.decode(slice), + ); } if (typeof message === "string") { From 954f8304c2622df845faa9ae03b04b3845ecd893 Mon Sep 17 00:00:00 2001 From: Skillz Date: Sat, 3 Oct 2020 12:43:27 -0400 Subject: [PATCH 04/24] fmt fixes --- src/controllers/messages.ts | 1 - src/handlers/guild.ts | 12 +----------- src/module/basicShard.ts | 5 +---- src/module/shardingManager.ts | 7 +------ src/types/options.ts | 4 ---- 5 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/controllers/messages.ts b/src/controllers/messages.ts index 43a591545..fe45ed022 100644 --- a/src/controllers/messages.ts +++ b/src/controllers/messages.ts @@ -3,7 +3,6 @@ import { structures } from "../structures/mod.ts"; import type { DiscordPayload } from "../types/discord.ts"; import type { MessageCreateOptions, - MessageDeleteBulkPayload, MessageDeletePayload, } from "../types/message.ts"; diff --git a/src/handlers/guild.ts b/src/handlers/guild.ts index e11695062..5ef7b5f07 100644 --- a/src/handlers/guild.ts +++ b/src/handlers/guild.ts @@ -7,33 +7,23 @@ import type { Guild } from "../structures/guild.ts"; import type { Member } from "../structures/member.ts"; import { structures } from "../structures/mod.ts"; import type { ImageFormats, ImageSize } from "../types/cdn.ts"; -import { - ChannelCreatePayload, - ChannelTypes, -} from "../types/channel.ts"; +import { ChannelCreatePayload, ChannelTypes } from "../types/channel.ts"; import { Errors } from "../types/errors.ts"; import type { BannedUser, BanOptions, - ChannelCreateOptions, CreateEmojisOptions, - CreateRoleOptions, - CreateServerOptions, EditEmojisOptions, - EditIntegrationOptions, FetchMembersOptions, GetAuditLogsOptions, - GuildEditOptions, PositionSwap, - PruneOptions, PrunePayload, - UserPayload, } from "../types/guild.ts"; import type { MemberCreatePayload } from "../types/member.ts"; diff --git a/src/module/basicShard.ts b/src/module/basicShard.ts index 19a50802d..d55ad72c5 100644 --- a/src/module/basicShard.ts +++ b/src/module/basicShard.ts @@ -16,10 +16,7 @@ import { GatewayOpcode } from "../types/discord.ts"; import type { FetchMembersOptions } from "../types/guild.ts"; import type { BotStatusRequest } from "../utils/utils.ts"; import type { IdentifyPayload } from "./client.ts"; -import { - botGatewayData, - eventHandlers, -} from "./client.ts"; +import { botGatewayData, eventHandlers } from "./client.ts"; import { handleDiscordPayload } from "./shardingManager.ts"; const basicShards = new Map(); diff --git a/src/module/shardingManager.ts b/src/module/shardingManager.ts index 48c3ffb08..4b1cb2d31 100644 --- a/src/module/shardingManager.ts +++ b/src/module/shardingManager.ts @@ -15,12 +15,7 @@ import { requestGuildMembers, } from "./basicShard.ts"; import type { IdentifyPayload } from "./client.ts"; -import { - botGatewayData, - eventHandlers, - - identifyPayload, -} from "./client.ts"; +import { botGatewayData, eventHandlers, identifyPayload } from "./client.ts"; let shardCounter = 0; let basicSharding = false; diff --git a/src/types/options.ts b/src/types/options.ts index 1ad67dc6c..4b57be9f4 100644 --- a/src/types/options.ts +++ b/src/types/options.ts @@ -6,10 +6,8 @@ import type { Role } from "../structures/role.ts"; import type { DiscordPayload, Emoji, - PresenceUpdatePayload, Properties, - TypingStartPayload, VoiceStateUpdatePayload, } from "./discord.ts"; @@ -17,10 +15,8 @@ import type { UserPayload } from "./guild.ts"; import type { Attachment, BaseMessageReactionPayload, - Embed, MessageReactionRemoveEmojiPayload, - MessageReactionUncachedPayload, PartialMessage, ReactionPayload, From 8e8fd6f88c5b3307484b81524c3c61fea9e4db03 Mon Sep 17 00:00:00 2001 From: chroventer Date: Sun, 4 Oct 2020 05:53:42 -0700 Subject: [PATCH 05/24] Update README.md --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 662026ec3..4d12951fa 100644 --- a/README.md +++ b/README.md @@ -56,9 +56,7 @@ The instructions below are meant for advanced developers! Starting with Discordeno is very simple, you can start from scratch without any boilerplates/frameworks: Add this snippet of code into a new TypeScript file: ```typescript -import StartBot from "https://x.nest.land/Discordeno@9.0.1/src/module/client.ts"; -import { sendMessage } from "https://x.nest.land/Discordeno@9.0.1/src/handlers/channel.ts"; -import { Intents } from "https://x.nest.land/Discordeno@9.0.1/src/types/options.ts"; +import StartBot, { sendMessage, Intents } from "https://x.nest.land/Discordeno@9.0.1/mod.ts"; import config from "./config.ts"; StartBot({ From 5326574e6ba7e694d53c5ffa3018260955f6cd8b Mon Sep 17 00:00:00 2001 From: Just a Badly Drawn TABS Dude <45307955+Suyashtnt@users.noreply.github.com> Date: Sat, 10 Oct 2020 21:51:40 +0200 Subject: [PATCH 06/24] Update gettingstarted.md --- docs/content/gettingstarted.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/content/gettingstarted.md b/docs/content/gettingstarted.md index 009065154..1c2c98e47 100644 --- a/docs/content/gettingstarted.md +++ b/docs/content/gettingstarted.md @@ -73,6 +73,7 @@ Alternatively, you can use boilerplate template repositories that were created b | -------------------- | ----------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | | Official Boilerplate | Skillz4Killz#4500 | [GitHub](https://github.com/Skillz4Killz/Discordeno-bot-template), [Support Server](https://discord.gg/J4NqJ72) | This is a very minimalistic design for a boilerplate for your bot to get you started. | | DenoBot | NTM Nathan#0001 | [GitHub](https://github.com/ntm-development/DenoBot), [Support Server](https://discord.com/invite/G2rb53z) | Another boilerplate example of the first one, with more commands and improvements. | +| Discordeno Helper | Suyashtnt | [Github](https://github.com/Suyashtnt/discordeno-helper-template/) | A reimplementation of DenoBot using the [discordeno-helper](https://github.com/Suyashtnt/discordeno-helper) framework Open Sourced Bots: | Bot Name | Developer | Links | From 82183d67395d940857941dd00530df8224f26c33 Mon Sep 17 00:00:00 2001 From: Skillz Date: Mon, 12 Oct 2020 12:10:40 -0400 Subject: [PATCH 07/24] test fix --- docs/content/gettingstarted.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/content/gettingstarted.md b/docs/content/gettingstarted.md index 009065154..41621b834 100644 --- a/docs/content/gettingstarted.md +++ b/docs/content/gettingstarted.md @@ -74,7 +74,8 @@ Alternatively, you can use boilerplate template repositories that were created b | Official Boilerplate | Skillz4Killz#4500 | [GitHub](https://github.com/Skillz4Killz/Discordeno-bot-template), [Support Server](https://discord.gg/J4NqJ72) | This is a very minimalistic design for a boilerplate for your bot to get you started. | | DenoBot | NTM Nathan#0001 | [GitHub](https://github.com/ntm-development/DenoBot), [Support Server](https://discord.com/invite/G2rb53z) | Another boilerplate example of the first one, with more commands and improvements. | -Open Sourced Bots: +**Open Sourced Bots:** + | Bot Name | Developer | Links | | ----------------- | ---------- | ---------------------------------------------------------- | | discordeno-mattis | Mattis6666 | [Github](https://github.com/Mattis6666/discordeno-mattis/) | From 13ff5f854c14e4ac70eb618b957d383e03d2bd47 Mon Sep 17 00:00:00 2001 From: Skillz Date: Wed, 14 Oct 2020 21:07:01 -0400 Subject: [PATCH 08/24] add user reviews section --- docs/content/introduction.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/content/introduction.md b/docs/content/introduction.md index 29c6b408c..0c2f6524b 100644 --- a/docs/content/introduction.md +++ b/docs/content/introduction.md @@ -19,6 +19,11 @@ Discordeno is a Third Party Deno Library for interacting with the Discord API. - Latest and Greatest JavaScript - Actively Maintained! +### User Reviews + +If you wish to leave a review for other users, please send a PR adding your review to this section! + + ## Read me first... Discordeno is cool right? You could make the next big bot! Who knows, but before we get right into developing our Bot. We want to get started with learning the basics... From d68f5d8ea09d8770a66c4bebcf381d96c643839f Mon Sep 17 00:00:00 2001 From: Skillz Date: Wed, 14 Oct 2020 21:08:13 -0400 Subject: [PATCH 09/24] ack handling --- src/module/basicShard.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/module/basicShard.ts b/src/module/basicShard.ts index d55ad72c5..84d4f9c9f 100644 --- a/src/module/basicShard.ts +++ b/src/module/basicShard.ts @@ -20,8 +20,10 @@ import { botGatewayData, eventHandlers } from "./client.ts"; import { handleDiscordPayload } from "./shardingManager.ts"; const basicShards = new Map(); -const heartbeating = new Set(); +const heartbeating = new Map(); const utf8decoder = new TextDecoder(); +const RequestMembersQueue: RequestMemberQueuedRequest[] = []; +let processQueue = false; export interface BasicShard { id: number; @@ -32,9 +34,6 @@ export interface BasicShard { needToResume: boolean; } -const RequestMembersQueue: RequestMemberQueuedRequest[] = []; -let processQueue = false; - interface RequestMemberQueuedRequest { guildID: string; shardID: number; @@ -126,6 +125,9 @@ export async function createBasicShard( ); } break; + case GatewayOpcode.HeartbeatACK: + heartbeating.set(shardID, true); + break; case GatewayOpcode.Reconnect: eventHandlers.debug?.( { type: "reconnect", data: { shardID: basicShard.id } }, @@ -200,7 +202,6 @@ function resume(shard: BasicShard, payload: IdentifyPayload) { })); } -// TODO: If a client does not receive a heartbeat ack between its attempts at sending heartbeats, it should immediately terminate the connection with a non-1000 close code, reconnect, and attempt to resume. async function heartbeat( shard: BasicShard, interval: number, @@ -210,7 +211,13 @@ async function heartbeat( return; } - if (!heartbeating.has(shard.id)) heartbeating.add(shard.id); + if (!heartbeating.has(shard.id)) heartbeating.set(shard.id, false); + else { + const receivedACK = heartbeating.get(shard.id); + if (!receivedACK) { + shard.socket.send(JSON.stringify({ op: 4009 })); + } + } shard.socket.send( JSON.stringify( From 4060dbee2ba63d525ce34b14702bb24dcfd752e3 Mon Sep 17 00:00:00 2001 From: Skillz Date: Wed, 14 Oct 2020 21:17:15 -0400 Subject: [PATCH 10/24] small fixes --- src/module/basicShard.ts | 19 ++++++++++++++++--- src/types/options.ts | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/module/basicShard.ts b/src/module/basicShard.ts index 84d4f9c9f..ea7de1acd 100644 --- a/src/module/basicShard.ts +++ b/src/module/basicShard.ts @@ -211,14 +211,27 @@ async function heartbeat( return; } - if (!heartbeating.has(shard.id)) heartbeating.set(shard.id, false); - else { + if (heartbeating.has(shard.id)) { const receivedACK = heartbeating.get(shard.id); + // If a ACK response was not received since last heartbeat, issue invalid session close if (!receivedACK) { - shard.socket.send(JSON.stringify({ op: 4009 })); + eventHandlers.debug?.( + { + type: "heartbeatStopped", + data: { + interval, + previousSequenceNumber: shard.previousSequenceNumber, + shardID: shard.id, + }, + }, + ); + return shard.socket.send(JSON.stringify({ op: 4009 })); } } + // Set it to false as we are issuing a new heartbeat + heartbeating.set(shard.id, false); + shard.socket.send( JSON.stringify( { op: GatewayOpcode.Heartbeat, d: shard.previousSequenceNumber }, diff --git a/src/types/options.ts b/src/types/options.ts index 4b57be9f4..641432ada 100644 --- a/src/types/options.ts +++ b/src/types/options.ts @@ -64,6 +64,7 @@ export interface DebugArg { | "requestManagerFetched" | "requestMembersProcessing" | "heartbeat" + | "heartbeatStopped" | "createShard" | "invalidSession" | "reconnect" From 509d60346cb43c2ffb58853e146b196e55f84597 Mon Sep 17 00:00:00 2001 From: Skillz Date: Fri, 16 Oct 2020 13:04:14 -0400 Subject: [PATCH 11/24] fix dynamic command nsfw stuff --- docs/content/advanced/dynamiccommands.md | 75 ++++++++++++------------ 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/docs/content/advanced/dynamiccommands.md b/docs/content/advanced/dynamiccommands.md index 313ee0719..a68da76e1 100644 --- a/docs/content/advanced/dynamiccommands.md +++ b/docs/content/advanced/dynamiccommands.md @@ -54,43 +54,44 @@ const nekosEndpoints = [ { name: "gecg", path: "/img/gecg", nsfw: false }, { name: "avatar", path: "/img/avatar", nsfw: false }, { name: "waifu", path: "/img/waifu", nsfw: false }, - { name: "randomHentaiGif", path: "/img/Random_hentai_gif", nsfw: true }, - { name: "pussy", path: "/img/pussy", nsfw: true }, - { name: "nekoGif", path: "/img/nsfw_neko_gif", nsfw: true }, - { name: "neko", path: "/img/lewd", nsfw: true }, - { name: "lesbian", path: "/img/les", nsfw: true }, - { name: "kuni", path: "/img/kuni", nsfw: true }, - { name: "cumsluts", path: "/img/cum", nsfw: true }, - { name: "classic", path: "/img/classic", nsfw: true }, - { name: "boobs", path: "/img/boobs", nsfw: true }, - { name: "bJ", path: "/img/bj", nsfw: true }, - { name: "anal", path: "/img/anal", nsfw: true }, - { name: "avatar", path: "/img/nsfw_avatar", nsfw: true }, - { name: "yuri", path: "/img/yuri", nsfw: true }, - { name: "trap", path: "/img/trap", nsfw: true }, - { name: "tits", path: "/img/tits", nsfw: true }, - { name: "girlSoloGif", path: "/img/solog", nsfw: true }, - { name: "girlSolo", path: "/img/solo", nsfw: true }, - { name: "pussyWankGif", path: "/img/pwankg", nsfw: true }, - { name: "pussyArt", path: "/img/pussy_jpg", nsfw: true }, - { name: "kemonomimi", path: "/img/lewdkemo", nsfw: true }, - { name: "kitsune", path: "/img/lewdk", nsfw: true }, - { name: "keta", path: "/img/keta", nsfw: true }, - { name: "holo", path: "/img/hololewd", nsfw: true }, - { name: "holoEro", path: "/img/holoero", nsfw: true }, - { name: "hentai", path: "/img/hentai", nsfw: true }, - { name: "futanari", path: "/img/futanari", nsfw: true }, - { name: "femdom", path: "/img/femdom", nsfw: true }, - { name: "feetGif", path: "/img/feetg", nsfw: true }, - { name: "eroFeet", path: "/img/erofeet", nsfw: true }, - { name: "feet", path: "/img/feet", nsfw: true }, - { name: "ero", path: "/img/ero", nsfw: true }, - { name: "eroKitsune", path: "/img/erok", nsfw: true }, - { name: "eroKemonomimi", path: "/img/erokemo", nsfw: true }, - { name: "eroNeko", path: "/img/eron", nsfw: true }, - { name: "eroYuri", path: "/img/eroyuri", nsfw: true }, - { name: "cumArts", path: "/img/cum_jpg", nsfw: true }, - { name: "blowJob", path: "/img/blowjob", nsfw: true }, + // The follow name and paths have been hidden for this guide as they are NSFW. + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, + { name: "nsfw_endpoint", path: "/img/nsfw_example", nsfw: true }, ]; nekosEndpoints.forEach((endpoint) => { From a804f293b754c205456c741244f3267da7d88524 Mon Sep 17 00:00:00 2001 From: Bryan Berger Date: Fri, 16 Oct 2020 15:15:52 -0400 Subject: [PATCH 12/24] fix: resume connect of shard socket if lost between heartbeats --- src/module/basicShard.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/module/basicShard.ts b/src/module/basicShard.ts index ea7de1acd..959c3f188 100644 --- a/src/module/basicShard.ts +++ b/src/module/basicShard.ts @@ -122,6 +122,7 @@ export async function createBasicShard( heartbeat( basicShard, (data.d as DiscordHeartbeatPayload).heartbeat_interval, + identifyPayload, ); } break; @@ -205,8 +206,12 @@ function resume(shard: BasicShard, payload: IdentifyPayload) { async function heartbeat( shard: BasicShard, interval: number, + payload: IdentifyPayload ) { + // We lost socket connection between heartbeats, resume connection if (shard.socket.isClosed) { + shard.needToResume = true; + resumeConnection(botGatewayData, payload, shard.id); heartbeating.delete(shard.id); return; } @@ -248,7 +253,7 @@ async function heartbeat( }, ); await delay(interval); - heartbeat(shard, interval); + heartbeat(shard, interval, payload); } async function resumeConnection( From 80156b80d153407ea034617b48659dbfaa48e3d0 Mon Sep 17 00:00:00 2001 From: Bryan Berger Date: Fri, 16 Oct 2020 15:33:33 -0400 Subject: [PATCH 13/24] fix: comma --- src/module/basicShard.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/basicShard.ts b/src/module/basicShard.ts index 959c3f188..60717ca3c 100644 --- a/src/module/basicShard.ts +++ b/src/module/basicShard.ts @@ -206,7 +206,7 @@ function resume(shard: BasicShard, payload: IdentifyPayload) { async function heartbeat( shard: BasicShard, interval: number, - payload: IdentifyPayload + payload: IdentifyPayload, ) { // We lost socket connection between heartbeats, resume connection if (shard.socket.isClosed) { From a376d8fe9f5f62e971c9465eac0bde085af94eef Mon Sep 17 00:00:00 2001 From: Skillz Date: Tue, 20 Oct 2020 09:00:01 -0400 Subject: [PATCH 14/24] publish to egs --- egg.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/egg.yml b/egg.yml index aaacd0120..5bf99cdbd 100644 --- a/egg.yml +++ b/egg.yml @@ -2,9 +2,9 @@ name: Discordeno description: >- Discord Deno TypeScript API library wrapper(Officially vetted library by Discord Team) https://discordeno.netlify.app -version: 9.0.1 +version: 9.0.2 stable: true -entry: /mod.ts +entry: mod.ts repository: 'https://github.com/Skillz4Killz/Discordeno' files: - ./src/**/* @@ -13,7 +13,5 @@ files: - README.md - tsconfig.json - ./deps.ts - - ./mod.ts - - ./mod.ts checkAll: false unlisted: false From eb6ea07906a1ac2a6efa57bf519ba6333c1d4de3 Mon Sep 17 00:00:00 2001 From: Skillz Date: Wed, 21 Oct 2020 12:38:20 -0400 Subject: [PATCH 15/24] latest eggs --- egg.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/egg.yml b/egg.yml index 5bf99cdbd..1c425d705 100644 --- a/egg.yml +++ b/egg.yml @@ -2,7 +2,7 @@ name: Discordeno description: >- Discord Deno TypeScript API library wrapper(Officially vetted library by Discord Team) https://discordeno.netlify.app -version: 9.0.2 +version: 9.0.3 stable: true entry: mod.ts repository: 'https://github.com/Skillz4Killz/Discordeno' From 954931cb1a90cfcb067e8d38e9b6a08f03533dfa Mon Sep 17 00:00:00 2001 From: Lukas Does Dev <51633285+LukasDoesDev@users.noreply.github.com> Date: Fri, 23 Oct 2020 19:51:08 +0300 Subject: [PATCH 16/24] Update introduction.md --- docs/content/introduction.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/content/introduction.md b/docs/content/introduction.md index 0c2f6524b..effb978f7 100644 --- a/docs/content/introduction.md +++ b/docs/content/introduction.md @@ -23,6 +23,7 @@ Discordeno is a Third Party Deno Library for interacting with the Discord API. If you wish to leave a review for other users, please send a PR adding your review to this section! +Using the Discord API with types but such a simple language like TypeScript is so easy now. Discordeno is A W E S O M E! -[LukasDoesDev](https://github.com/LukasDoesDev) ## Read me first... Discordeno is cool right? You could make the next big bot! Who knows, but before we get right into developing our Bot. We want to get started with learning the basics... From 2ed1c8b72d367838465221bb92f61cffc2d6c504 Mon Sep 17 00:00:00 2001 From: chroventer Date: Sat, 24 Oct 2020 18:24:37 +0400 Subject: [PATCH 17/24] fix: guildMemberRemove event triggered twice --- src/controllers/members.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/controllers/members.ts b/src/controllers/members.ts index 6d413f90f..0083f158f 100644 --- a/src/controllers/members.ts +++ b/src/controllers/members.ts @@ -41,11 +41,6 @@ export async function handleInternalGuildMemberRemove(data: DiscordPayload) { member || payload.user, ); - eventHandlers.guildMemberRemove?.( - guild, - member || payload.user, - ); - guild.members.delete(payload.user.id); } From 45c8fe668de75f42ceb81fc90a43cba01591d175 Mon Sep 17 00:00:00 2001 From: Skillz Date: Sat, 24 Oct 2020 10:31:32 -0400 Subject: [PATCH 18/24] cleaner type --- src/structures/channel.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/channel.ts b/src/structures/channel.ts index 64e77ef9b..00e28eaff 100644 --- a/src/structures/channel.ts +++ b/src/structures/channel.ts @@ -20,7 +20,7 @@ export async function createChannel( const channel = { ...rest, /** The guild id of the channel if it is a guild channel. */ - guildID: guildID || rawGuildID, + guildID: guildID || rawGuildID || "", /** The id of the last message sent in this channel */ lastMessageID, /** The amount of users allowed in this voice channel. */ From 7635c98af127426f2e0427b2ffec1183622ccfcb Mon Sep 17 00:00:00 2001 From: Skillz Date: Sat, 24 Oct 2020 10:33:24 -0400 Subject: [PATCH 19/24] egs --- egg.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/egg.yml b/egg.yml index 1c425d705..86ddea0a7 100644 --- a/egg.yml +++ b/egg.yml @@ -2,7 +2,7 @@ name: Discordeno description: >- Discord Deno TypeScript API library wrapper(Officially vetted library by Discord Team) https://discordeno.netlify.app -version: 9.0.3 +version: 9.0.4 stable: true entry: mod.ts repository: 'https://github.com/Skillz4Killz/Discordeno' From a81ceff28f7136517a9b0596876b75c08e729c3d Mon Sep 17 00:00:00 2001 From: chroventer Date: Sun, 25 Oct 2020 09:54:40 +0400 Subject: [PATCH 20/24] Add "Competing --- src/types/activity.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/types/activity.ts b/src/types/activity.ts index 81a180b4b..f5a97e293 100644 --- a/src/types/activity.ts +++ b/src/types/activity.ts @@ -18,4 +18,6 @@ export enum ActivityType { Listening, /** Example: ":smiley: I am cool" */ Custom = 4, + /** Example: "Competing in Arena World Champions" */ + Competing } From b3704b27772c6c1dbe7a129b8fc55d1ccd1e6a78 Mon Sep 17 00:00:00 2001 From: chroventer Date: Sun, 25 Oct 2020 09:57:31 +0400 Subject: [PATCH 21/24] revert: "Add "Competing" --- src/types/activity.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/types/activity.ts b/src/types/activity.ts index f5a97e293..81a180b4b 100644 --- a/src/types/activity.ts +++ b/src/types/activity.ts @@ -18,6 +18,4 @@ export enum ActivityType { Listening, /** Example: ":smiley: I am cool" */ Custom = 4, - /** Example: "Competing in Arena World Champions" */ - Competing } From 2b618b1cb8438af950968b75352f84acc217eab6 Mon Sep 17 00:00:00 2001 From: chroventer Date: Sun, 25 Oct 2020 10:07:19 +0400 Subject: [PATCH 22/24] Add "Competing" to ActivityType (#142) * Add "Competing" to ActivityType * Add trailing comma --- src/types/activity.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/types/activity.ts b/src/types/activity.ts index 81a180b4b..0299625ff 100644 --- a/src/types/activity.ts +++ b/src/types/activity.ts @@ -18,4 +18,6 @@ export enum ActivityType { Listening, /** Example: ":smiley: I am cool" */ Custom = 4, + /** Example: "Competing in Arena World Champions" */ + Competing, } From 1c65db528f6edaa06adbe57cd47ed8e637895c1f Mon Sep 17 00:00:00 2001 From: Skillz Date: Mon, 26 Oct 2020 11:40:35 -0400 Subject: [PATCH 23/24] slight fix for deleted roles without members inten --- src/controllers/roles.ts | 5 +++++ src/utils/permissions.ts | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/controllers/roles.ts b/src/controllers/roles.ts index 9f889d23b..a1b4586d0 100644 --- a/src/controllers/roles.ts +++ b/src/controllers/roles.ts @@ -30,6 +30,11 @@ export async function handleInternalGuildRoleDelete(data: DiscordPayload) { const cachedRole = guild.roles.get(payload.role_id)!; guild.roles.delete(payload.role_id); eventHandlers.roleDelete?.(guild, cachedRole); + + // For bots without GUILD_MEMBERS member.roles is never updated breaking permissions checking. + guild.members.forEach(member => { + member.roles = member.roles.filter(id => id !== payload.role_id); + }); } export async function handleInternalGuildRoleUpdate(data: DiscordPayload) { diff --git a/src/utils/permissions.ts b/src/utils/permissions.ts index 013c1c56c..049a62089 100644 --- a/src/utils/permissions.ts +++ b/src/utils/permissions.ts @@ -58,6 +58,8 @@ export async function botHasPermission( const permissionBits = member.roles .map((id) => guild.roles.get(id)!) + // Remove any edge case undefined + .filter((r) => r) .reduce((bits, data) => { bits |= BigInt(data.permissions); From f58683b55f6b35eb222300739122220e19b5e89a Mon Sep 17 00:00:00 2001 From: Skillz Date: Mon, 26 Oct 2020 11:41:55 -0400 Subject: [PATCH 24/24] eggs --- egg.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/egg.yml b/egg.yml index 86ddea0a7..408443064 100644 --- a/egg.yml +++ b/egg.yml @@ -2,7 +2,7 @@ name: Discordeno description: >- Discord Deno TypeScript API library wrapper(Officially vetted library by Discord Team) https://discordeno.netlify.app -version: 9.0.4 +version: 9.0.5 stable: true entry: mod.ts repository: 'https://github.com/Skillz4Killz/Discordeno'