From 8f8f988e2b4883d1745e6a978da7939572d0bb7d Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Fri, 26 Feb 2021 19:11:02 +0100 Subject: [PATCH 01/13] fix(structures/channel): empty guildID in Channel struct (#551) --- src/api/structures/guild.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/structures/guild.ts b/src/api/structures/guild.ts index bffd97546..f1cc711cb 100644 --- a/src/api/structures/guild.ts +++ b/src/api/structures/guild.ts @@ -146,7 +146,7 @@ export async function createGuild(data: CreateGuildPayload, shardID: number) { ); await Promise.all(channels.map(async (channel) => { - const channelStruct = await structures.createChannel(channel); + const channelStruct = await structures.createChannel(channel, rest.id); return cacheHandlers.set("channels", channelStruct.id, channelStruct); })); From 7a52f301b3b3d4348f4889847615c6d2a1f96032 Mon Sep 17 00:00:00 2001 From: ayntee Date: Sat, 27 Feb 2021 23:54:37 +0400 Subject: [PATCH 02/13] fix(util/permissions): move owner check before member cache check (#555) --- src/util/permissions.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/permissions.ts b/src/util/permissions.ts index 97a97ac27..8579cb99b 100644 --- a/src/util/permissions.ts +++ b/src/util/permissions.ts @@ -52,15 +52,15 @@ export async function botHasPermission( guildID: string, permissions: Permission[], ) { - const member = await cacheHandlers.get("members", botID); - if (!member) return false; - const guild = await cacheHandlers.get("guilds", guildID); if (!guild) return false; // Check if the bot is the owner of the guild, if it is, returns true if (guild.ownerID === botID) return true; + const member = await cacheHandlers.get("members", botID); + if (!member) return false; + // The everyone role is not in member.roles const permissionBits = [...member.guilds.get(guildID)?.roles || [], guild.id] .map((id) => guild.roles.get(id)!) From a72bf9bb2e2e0c0d97f9ba620509d567aa021798 Mon Sep 17 00:00:00 2001 From: ayntee Date: Sun, 28 Feb 2021 00:05:01 +0400 Subject: [PATCH 03/13] test: remove weird workaround (#556) --- .github/workflows/test.yml | 6 ++---- test/mod.test.ts | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6bf456c31..4c31dcf43 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,10 +13,8 @@ jobs: deno-version: ${{ matrix.deno }} - name: Cache dependencies run: deno cache mod.ts - - name: Run local tests - run: TEST_TYPE=local deno test --allow-env - - name: Run API tests + - name: Run test script if: github.ref == 'refs/heads/master' - run: TEST_TYPE=api deno test --allow-net --allow-env + run: deno test --allow-net --allow-env env: DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }} diff --git a/test/mod.test.ts b/test/mod.test.ts index 15fca7706..4be57e15c 100644 --- a/test/mod.test.ts +++ b/test/mod.test.ts @@ -36,7 +36,6 @@ import { export const defaultTestOptions: Partial = { sanitizeOps: false, sanitizeResources: false, - ignore: Deno.env.get("TEST_TYPE") !== "api", }; // Temporary data From 56ae257f02c1f83bf4bdf479d314f52b374a3990 Mon Sep 17 00:00:00 2001 From: ayntee Date: Sun, 28 Feb 2021 00:06:45 +0400 Subject: [PATCH 04/13] docs(README): add link to invalid request limit (#552) * docs(README): add link to invalid request limit * style: format README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1759d3482..97d6e7517 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ Discordeno follows [Semantic Versioning](https://semver.org/) - **Secure & stable**: Discordeno is actively maintained to ensure great performance and convenience. Moreover, it internally checks all missing permissions before forwarding a request to the Discord API so that the client - does not get globally-banned by Discord. + does not get + [globally-banned by Discord](https://discord.com/developers/docs/topics/rate-limits#invalid-request-limit). - **Simple, Efficient, & Lightweight**: Discordeno is simplistic, easy-to-use, versatile while being efficient and lightweight. Follows [Convention Over Configuration](https://en.wikipedia.org/wiki/Convention_over_configuration) From 684f827bd728f2b4e123b87fdf2559ac18835a63 Mon Sep 17 00:00:00 2001 From: Dhruvin-Purohit <73269605+Dhruvin-Purohit@users.noreply.github.com> Date: Sun, 28 Feb 2021 14:42:14 +0530 Subject: [PATCH 05/13] docs(README): fix grammatical error (#557) * feat(grammar): fixed a mistake. resources is a plural word but is being used as a singular word here * Update docs/src/README.md Co-authored-by: ayntee --- docs/src/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/README.md b/docs/src/README.md index 20afdd20f..fbdc3ec3f 100644 --- a/docs/src/README.md +++ b/docs/src/README.md @@ -54,5 +54,5 @@ resources: - [TypeScript Crash Course by Traversy Media](https://www.youtube.com/watch?v=rAy_3SIqT-E) -There is always more resources... Take your time and don't fret! Come back when +There are always more resources... Take your time and don't fret! Come back when you are ready, we can't wait to see what your Discordeno created bot does! From 04dbdaf2e0b955b72af077d7ec18fd68cbc22c66 Mon Sep 17 00:00:00 2001 From: Dhruvin-Purohit <73269605+Dhruvin-Purohit@users.noreply.github.com> Date: Mon, 1 Mar 2021 00:22:30 +0530 Subject: [PATCH 06/13] docs(faq): fix spelling and grammatical errors (#558) * feat(grammar): Common Mistakes. * Update docs/src/faq.md Co-authored-by: ayntee --- docs/src/faq.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/faq.md b/docs/src/faq.md index 04ecfcc44..14af40820 100644 --- a/docs/src/faq.md +++ b/docs/src/faq.md @@ -21,11 +21,11 @@ of it's code! A breaking change in typings is a breaking change for the library! ## How Stable Is Discordeno? -One of the biggest issues with almost every library(I have used) is stability. +One of the biggest issues with almost every library (that I have used) is stability. None of the libraries gave much love and attention to TypeScript developers the way it deserves. Sometimes TypeScript projects would break because breaking changes to typings did not make a MAJOR bump so TypeScript bots in production -would break. Sometimes I was personally maintaing the typings because no one +would break. Sometimes I was personally maintaining the typings because no one else was for that lib. Some libs were pre 1.0 and didn't even have a stable branch/version where I would not have to worry about breaking changes. From 848e3d5ced5a6add042c8948905af165272258e9 Mon Sep 17 00:00:00 2001 From: ayntee Date: Mon, 1 Mar 2021 15:19:09 +0400 Subject: [PATCH 07/13] style(docs/faq): run deno fmt --- docs/src/faq.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/src/faq.md b/docs/src/faq.md index 14af40820..e8bfdf840 100644 --- a/docs/src/faq.md +++ b/docs/src/faq.md @@ -21,13 +21,14 @@ of it's code! A breaking change in typings is a breaking change for the library! ## How Stable Is Discordeno? -One of the biggest issues with almost every library (that I have used) is stability. -None of the libraries gave much love and attention to TypeScript developers the -way it deserves. Sometimes TypeScript projects would break because breaking -changes to typings did not make a MAJOR bump so TypeScript bots in production -would break. Sometimes I was personally maintaining the typings because no one -else was for that lib. Some libs were pre 1.0 and didn't even have a stable -branch/version where I would not have to worry about breaking changes. +One of the biggest issues with almost every library (that I have used) is +stability. None of the libraries gave much love and attention to TypeScript +developers the way it deserves. Sometimes TypeScript projects would break +because breaking changes to typings did not make a MAJOR bump so TypeScript bots +in production would break. Sometimes I was personally maintaining the typings +because no one else was for that lib. Some libs were pre 1.0 and didn't even +have a stable branch/version where I would not have to worry about breaking +changes. This is why I made it one of my foundational goals of this library to have the best stability for TypeScript developers. No matter how small, a breaking change From 0ec769fad0777848c52016d0db9cf171374aecc2 Mon Sep 17 00:00:00 2001 From: ayntee Date: Mon, 1 Mar 2021 15:33:45 +0400 Subject: [PATCH 08/13] chore: remove 'deno.unstable' from settings.json --- .vscode/settings.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index e15e7fd59..088bb67d7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,6 @@ { "deno.enable": true, "deno.lint": true, - "deno.unstable": true, "editor.defaultFormatter": "denoland.vscode-deno", "editor.formatOnSave": true, "editor.codeActionsOnSave": { From 832cb634605449ef56b96a8bd83ece1c781754b5 Mon Sep 17 00:00:00 2001 From: ayntee Date: Mon, 1 Mar 2021 20:56:17 +0400 Subject: [PATCH 09/13] test(main): close websocket instead of Deno.exit() (#560) --- test/mod.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/mod.test.ts b/test/mod.test.ts index 4be57e15c..d28280831 100644 --- a/test/mod.test.ts +++ b/test/mod.test.ts @@ -13,6 +13,7 @@ import { cache, Channel, channelOverwriteHasPermission, + closeWS, createGuildChannel, createGuildRole, createServer, @@ -347,8 +348,9 @@ Deno.test({ // Forcefully exit the Deno process once all tests are done. Deno.test({ - name: "exit the process forcefully after all the tests are done\n", + name: "[main] close the websocket connection", fn() { - Deno.exit(); + closeWS(); }, + ...defaultTestOptions, }); From 25d7983ebab789e860aa7496581736a2d0b38794 Mon Sep 17 00:00:00 2001 From: ayntee Date: Mon, 1 Mar 2021 21:26:53 +0400 Subject: [PATCH 10/13] chore: add vscode-related files to .gitignore (#561) --- .gitignore | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f82cdf33a..33cbff9b6 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,10 @@ public/ .idea/ # Windows -desktop.ini \ No newline at end of file +desktop.ini + +# Visual Studio Code +.vscode/* +!.vscode/tasks.json +!.vscode/launch.json +*.code-workspace From b021d3a21ce85071ad58e20ea52185bd36517ce1 Mon Sep 17 00:00:00 2001 From: ayntee Date: Mon, 1 Mar 2021 21:28:29 +0400 Subject: [PATCH 11/13] chore: enable deno and deno lint in container --- .devcontainer/devcontainer.json | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c382addc8..77746a261 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,7 +4,15 @@ // Set *default* container specific settings.json values on container create. "settings": { - "terminal.integrated.shell.linux": "/bin/bash" + "terminal.integrated.shell.linux": "/bin/bash", + "deno.enable": true, + "deno.lint": true, + "editor.defaultFormatter": "denoland.vscode-deno", + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.organizeImports": true, + "source.fixAll": true + } }, // Add the IDs of extensions you want installed when the container is created. @@ -20,4 +28,4 @@ // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. // "remoteUser": "vscode" -} \ No newline at end of file +} From 585ed283fefcdbce3274444e8ce315a8e39313b3 Mon Sep 17 00:00:00 2001 From: ayntee Date: Mon, 1 Mar 2021 21:57:59 +0400 Subject: [PATCH 12/13] test(main): remove auto-deletion of guilds --- test/mod.test.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/mod.test.ts b/test/mod.test.ts index d28280831..9ba38479a 100644 --- a/test/mod.test.ts +++ b/test/mod.test.ts @@ -59,14 +59,6 @@ Deno.test({ intents: ["GUILD_MESSAGES", "GUILDS"], }); - eventHandlers.ready = () => { - if (cache.guilds.size >= 10) { - cache.guilds.map((guild) => - guild.ownerID === botID && deleteServer(guild.id) - ); - } - }; - // Delay the execution by 5 seconds await delay(5000); From f1473224cca4bb15a30205fe64b759e61835ff62 Mon Sep 17 00:00:00 2001 From: ayntee Date: Tue, 2 Mar 2021 00:09:00 +0400 Subject: [PATCH 13/13] docs(README): add table of contents section --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 97d6e7517..ef5bd5094 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,15 @@ Discordeno follows [Semantic Versioning](https://semver.org/) ![Lint](https://github.com/discordeno/discordeno/workflows/Lint/badge.svg) ![Test](https://github.com/discordeno/discordeno/workflows/Test/badge.svg) +## Table of contents + +- [Features](#features) +- [Getting Started](#getting-started) + - [Minimal Example](#minimal-example) + - [Boilerplates](#boilerplates) +- [Links](#links) +- [Contributing](#contributing) + ## Features - **Secure & stable**: Discordeno is actively maintained to ensure great @@ -65,7 +74,7 @@ unofficial boilerplates: (official)](https://github.com/discordeno/slash-commands-boilerplate) - [Add Your Own!](https://github.com/discordeno/discordeno/pulls) -## Useful Links +## Links - [Website](https://discordeno.mod.land) - [Documentation](https://doc.deno.land/https/deno.land/x/discordeno/mod.ts) @@ -75,7 +84,3 @@ unofficial boilerplates: We appreciate your help! Before contributing, please read the [Contributing Guide](https://github.com/discordeno/discordeno/blob/master/.github/CONTRIBUTING.md). - -### License - -[License can be found here](https://github.com/discordeno/discordeno/blob/master/LICENSE)