From 85ea2d9b8c474ebddbaed7cca990d19c6826e80a Mon Sep 17 00:00:00 2001 From: Awesome Stickz Date: Mon, 17 Apr 2023 05:21:17 +0530 Subject: [PATCH 1/4] fix(bot): missing exports of types (#3004) * fix(bot): missing exports of types * fix: add other exports --- packages/bot/src/handlers/channels/index.ts | 1 + packages/bot/src/index.ts | 3 +++ packages/bot/src/transformers/index.ts | 2 ++ packages/bot/src/transformers/reverse/index.ts | 4 ++++ packages/bot/src/transformers/toggles/index.ts | 2 ++ 5 files changed, 12 insertions(+) diff --git a/packages/bot/src/handlers/channels/index.ts b/packages/bot/src/handlers/channels/index.ts index 088fb7c50..5e61f52d1 100644 --- a/packages/bot/src/handlers/channels/index.ts +++ b/packages/bot/src/handlers/channels/index.ts @@ -8,5 +8,6 @@ export * from './STAGE_INSTANCE_UPDATE.js' export * from './THREAD_CREATE.js' export * from './THREAD_DELETE.js' export * from './THREAD_LIST_SYNC.js' +export * from './THREAD_MEMBER_UPDATE.js' export * from './THREAD_MEMBERS_UPDATE.js' export * from './THREAD_UPDATE.js' diff --git a/packages/bot/src/index.ts b/packages/bot/src/index.ts index 9cae2c845..18a109a1d 100644 --- a/packages/bot/src/index.ts +++ b/packages/bot/src/index.ts @@ -3,8 +3,11 @@ export * from '@discordeno/rest' export * from '@discordeno/types' export * from '@discordeno/utils' export * from './bot.js' +export * from './constants.js' export * from './handlers/index.js' export * from './handlers.js' +export * from './optionalize.js' export * from './transformers/index.js' export * from './transformers.js' +export * from './typings.js' export * from './utils.js' diff --git a/packages/bot/src/transformers/index.ts b/packages/bot/src/transformers/index.ts index a4e9db236..deb0fc5b3 100644 --- a/packages/bot/src/transformers/index.ts +++ b/packages/bot/src/transformers/index.ts @@ -6,6 +6,7 @@ export * from './applicationCommandOptionChoice.js' export * from './applicationCommandPermission.js' export * from './attachment.js' export * from './auditLogEntry.js' +export * from './automodActionExecution.js' export * from './automodRule.js' export * from './channel.js' export * from './component.js' @@ -28,6 +29,7 @@ export * from './team.js' export * from './template.js' export * from './threadMember.js' export * from './toggles/index.js' +export * from './user.js' export * from './voiceRegion.js' export * from './voiceState.js' export * from './webhook.js' diff --git a/packages/bot/src/transformers/reverse/index.ts b/packages/bot/src/transformers/reverse/index.ts index 1d2707510..27cd33208 100644 --- a/packages/bot/src/transformers/reverse/index.ts +++ b/packages/bot/src/transformers/reverse/index.ts @@ -1,4 +1,5 @@ export * from './activity.js' +export * from './allowedMentions.js' export * from './application.js' export * from './applicationCommand.js' export * from './applicationCommandOption.js' @@ -7,10 +8,13 @@ export * from './applicationCommandPermission.js' export * from './attachment.js' export * from './auditLogEntry.js' export * from './component.js' +export * from './createApplicationCommand.js' export * from './embed.js' export * from './emoji.js' export * from './gatewayBot.js' +export * from './interactionResponse.js' export * from './member.js' export * from './presence.js' export * from './team.js' export * from './widgetSettings.js' + diff --git a/packages/bot/src/transformers/toggles/index.ts b/packages/bot/src/transformers/toggles/index.ts index a5783110c..4c88d7d52 100644 --- a/packages/bot/src/transformers/toggles/index.ts +++ b/packages/bot/src/transformers/toggles/index.ts @@ -1,6 +1,8 @@ +export * from './channel.js' export * from './emoji.js' export * from './guild.js' export * from './member.js' +export * from './Permissions.js' export * from './role.js' export * from './ToggleBitfield.js' export * from './user.js' From d320334663a5b47a3c9d90ced53fc63be299aac3 Mon Sep 17 00:00:00 2001 From: Peter Date: Sun, 16 Apr 2023 19:52:35 -0400 Subject: [PATCH 2/4] Mobile responsiveness + add loading (#3005) * Mobile responsiveness + add loading * formatting + remove animate.css - causing useless lag --------- Co-authored-by: Peter Hanania --- website/babel.config.js | 1 + website/docs/bigbot/step-3-gateway.md | 49 ++++++++--------- website/package-lock.json | 7 +-- website/package.json | 2 +- website/src/components/home/faq/index.tsx | 15 +++-- .../src/components/home/features/feature.tsx | 2 +- website/src/components/home/reviews/index.tsx | 5 +- website/src/pages/index.tsx | 55 ++++++++++++++++++- website/src/styling/index.ts | 32 ++++++++++- website/yarn.lock | 11 +--- 10 files changed, 124 insertions(+), 55 deletions(-) diff --git a/website/babel.config.js b/website/babel.config.js index 675264818..7186e2119 100644 --- a/website/babel.config.js +++ b/website/babel.config.js @@ -1,3 +1,4 @@ module.exports = { presets: [require.resolve('@docusaurus/core/lib/babel/preset')], + plugins: ['babel-plugin-styled-components'], } diff --git a/website/docs/bigbot/step-3-gateway.md b/website/docs/bigbot/step-3-gateway.md index 461f3e4fb..24eb53704 100644 --- a/website/docs/bigbot/step-3-gateway.md +++ b/website/docs/bigbot/step-3-gateway.md @@ -405,7 +405,6 @@ This is for bots who need to take certain actions when the bot is added to or re Let's start by creating a small local cache at the top of the file. - ```ts const cache = { guildIds: new Set(), @@ -444,31 +443,31 @@ events: { }, ``` -Now we need to make sure that this will handle it correctly by changing any guild creates that are not new guilds, to a private event. +Now we need to make sure that this will handle it correctly by changing any guild creates that are not new guilds, to a private event. ```ts -if (payload.t === "READY") { +if (payload.t === 'READY') { // Marks which guilds the bot in when initial loading in cache - payload.d.guilds.forEach((g) => cache.loadingGuildIds.add(g.id)); + payload.d.guilds.forEach(g => cache.loadingGuildIds.add(g.id)) } -if (payload.t === "GUILD_CREATE") { +if (payload.t === 'GUILD_CREATE') { // Check if this id is in cache - const existing = cache.guildIds.has(payload.d.id); + const existing = cache.guildIds.has(payload.d.id) // If it already exists this was either a shard resume or unavailable guild became available etc... - if (existing) return; + if (existing) return // add this id to cache or db - cache.guildIds.add(payload.d.id); - - if (cache.loadingGuildIds.has(payload.d.id)) { + cache.guildIds.add(payload.d.id) + + if (cache.loadingGuildIds.has(payload.d.id)) { // SEND A CUSTOM EVENT. Name it whatever u want - payload.t = "GUILD_LOADED_DD"; + payload.t = 'GUILD_LOADED_DD' // Remove from cache - cache.loadingGuildIds.delete(id); + cache.loadingGuildIds.delete(id) } - cache.guildIds.add(id); + cache.guildIds.add(id) } ``` @@ -477,14 +476,14 @@ This will make it so whenever a GUILD_CREATE arrives from the initial batch it w One last bit before you are done, simply add the following to make it ignore any useless **GUILD_DELETE** events as well. You can also choose rename it should you like to something like **GUILD_UNAVAILABLE**. ```ts -if (payload.t === "GUILD_DELETE") { - if ((payload.d as DiscordUnavailableGuild).unavailable) return; +if (payload.t === 'GUILD_DELETE') { + if ((payload.d as DiscordUnavailableGuild).unavailable) return } ``` #### MESSAGE_UPDATE -One other area where we can optimize is for the **MESSAGE_UPDATE** event, assuming you have the MessageContent intent enabled. You can save a ton of your CPU for gateway and bot by adding this in. This event can spam for no reason whatsoever and we can use the following code to ignore useless events. For example, any message that is sent with an embed will have a +One other area where we can optimize is for the **MESSAGE_UPDATE** event, assuming you have the MessageContent intent enabled. You can save a ton of your CPU for gateway and bot by adding this in. This event can spam for no reason whatsoever and we can use the following code to ignore useless events. For example, any message that is sent with an embed will have a - MESSAGE_CREATE - MESSAGE_UPDATE @@ -511,21 +510,21 @@ Then let's say the user actually edits the message just a tiny bit. Imagine having to process all these events, sending them through your queue system and causing a waste of CPU processing power. ```ts -if (payload.t === "MESSAGE_UPDATE") { - const message = payload.d as DiscordMessage; +if (payload.t === 'MESSAGE_UPDATE') { + const message = payload.d as DiscordMessage - const id = message.id; - const content = message.content || ""; - const cached = cache.editedMessages.get(id); + const id = message.id + const content = message.content || '' + const cached = cache.editedMessages.get(id) - if (cached === content) return; + if (cached === content) return else { // Add to local cache for future events comparison - cache.editedMessages.set(id, content); + cache.editedMessages.set(id, content) // Remove after 10 seconds from cache setTimeout(() => { - cache.editedMessages.delete(id); - }, 10000); + cache.editedMessages.delete(id) + }, 10000) } } ``` diff --git a/website/package-lock.json b/website/package-lock.json index b4eb1f481..92a0e4cdf 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -13,7 +13,7 @@ "@docusaurus/preset-classic": "2.3.1", "@easyops-cn/docusaurus-search-local": "^0.34.0", "@mdx-js/react": "^1.6.22", - "animate.css": "^4.1.1", + "babel-plugin-styled-components": "^2.1.1", "chart.js": "^4.2.1", "clsx": "^1.2.1", "prism-react-renderer": "^1.3.5", @@ -5192,11 +5192,6 @@ "algoliasearch": ">= 3.1 < 6" } }, - "node_modules/animate.css": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/animate.css/-/animate.css-4.1.1.tgz", - "integrity": "sha512-+mRmCTv6SbCmtYJCN4faJMNFVNN5EuCTTprDTAo7YzIGji2KADmakjVA3+8mVDkZ2Bf09vayB35lSQIex2+QaQ==" - }, "node_modules/ansi-align": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.1.tgz", diff --git a/website/package.json b/website/package.json index 976f371b5..408a10589 100644 --- a/website/package.json +++ b/website/package.json @@ -22,7 +22,7 @@ "@docusaurus/preset-classic": "2.3.1", "@easyops-cn/docusaurus-search-local": "^0.34.0", "@mdx-js/react": "^1.6.22", - "animate.css": "^4.1.1", + "babel-plugin-styled-components": "^2.1.1", "chart.js": "^4.2.1", "clsx": "^1.2.1", "prism-react-renderer": "^1.3.5", diff --git a/website/src/components/home/faq/index.tsx b/website/src/components/home/faq/index.tsx index 2f07cb0a4..334284e7d 100644 --- a/website/src/components/home/faq/index.tsx +++ b/website/src/components/home/faq/index.tsx @@ -44,23 +44,28 @@ const Faq = ({ const questions = [ { - question: 'Does Discordeno work on all JavaScript runtimes like Deno, Node.js, and Bun?', - answer: "Yes! Discordeno is designed to work on any JavaScript runtime, including Deno, Node.js, and even in the Bun environment. This means that you can use Discordeno in your project no matter where you're running your code.", + question: + 'Does Discordeno work on all JavaScript runtimes like Deno, Node.js, and Bun?', + answer: + "Yes! Discordeno is designed to work on any JavaScript runtime, including Deno, Node.js, and even in the Bun environment. This means that you can use Discordeno in your project no matter where you're running your code.", defaultExpanded: true, }, { question: 'Does Discordeno handle sharding?', - answer: "Yes! Discordeno helps run some of the largest bot's on discord. Discordeno has built-in support for sharding, which allows you to distribute your bot across multiple processes or servers. Sharding can help improve the scalability and reliability of your bot, especially if you're working with a large number of guilds or users. Discordeno's sharding system is designed to be easy to use and configure, with support for automatic sharding and custom sharding strategies. Make sure to check the Discordeno documentation for more information on how to use sharding in your bot.", + answer: + "Yes! Discordeno helps run some of the largest bot's on discord. Discordeno has built-in support for sharding, which allows you to distribute your bot across multiple processes or servers. Sharding can help improve the scalability and reliability of your bot, especially if you're working with a large number of guilds or users. Discordeno's sharding system is designed to be easy to use and configure, with support for automatic sharding and custom sharding strategies. Make sure to check the Discordeno documentation for more information on how to use sharding in your bot.", defaultExpanded: false, }, { question: "Why doesn't Discordeno use Classes like other libraries?", - answer: "Yes and No. Generally, Discordeno does not use classes. However, in certain cases where it makes sense we do use them. Instead, Discordeno uses plain JavaScript objects to define commands, events, and other components. This design choice was made to keep the library lightweight and simple, and to allow for more flexible and dynamic code, as components can be easily modified and extended at runtime. While classes can be useful in some cases, Discordeno has chosen to use a more functional approach.", + answer: + 'Yes and No. Generally, Discordeno does not use classes. However, in certain cases where it makes sense we do use them. Instead, Discordeno uses plain JavaScript objects to define commands, events, and other components. This design choice was made to keep the library lightweight and simple, and to allow for more flexible and dynamic code, as components can be easily modified and extended at runtime. While classes can be useful in some cases, Discordeno has chosen to use a more functional approach.', defaultExpanded: false, }, { question: 'Can I still use classes in my bot with Discordeno?', - answer: "Yes! While Discordeno itself does not use classes, you can still use classes in your own code by using one of the many libraries or frameworks that provide class-based abstractions on top of Discordeno. Some examples of such libraries include the Discordeno.js which provides a very similar framework and API to Discord.js or the Sinf library that provides a similar API to Eris library. These libraries provide classes and other abstractions that can help simplify the development of your bot, while still leveraging the power and flexibility of Discordeno's underlying object-based API. Make sure to check the documentation of these libraries for more information on how to use them in your bot.", + answer: + "Yes! While Discordeno itself does not use classes, you can still use classes in your own code by using one of the many libraries or frameworks that provide class-based abstractions on top of Discordeno. Some examples of such libraries include the Discordeno.js which provides a very similar framework and API to Discord.js or the Sinf library that provides a similar API to Eris library. These libraries provide classes and other abstractions that can help simplify the development of your bot, while still leveraging the power and flexibility of Discordeno's underlying object-based API. Make sure to check the documentation of these libraries for more information on how to use them in your bot.", defaultExpanded: false, }, ] diff --git a/website/src/components/home/features/feature.tsx b/website/src/components/home/features/feature.tsx index 0a58fb42d..47a985e8c 100644 --- a/website/src/components/home/features/feature.tsx +++ b/website/src/components/home/features/feature.tsx @@ -4,7 +4,7 @@ import clsx from 'clsx' export default function Feature({ data }: FeatureList): JSX.Element { return ( -
+
{data.feature.Svg}
diff --git a/website/src/components/home/reviews/index.tsx b/website/src/components/home/reviews/index.tsx index 30d213f7d..907e196d2 100644 --- a/website/src/components/home/reviews/index.tsx +++ b/website/src/components/home/reviews/index.tsx @@ -95,10 +95,7 @@ export default function DiscordenoReviews() { return b.bot.guild_count - a.bot.guild_count }) .map((review, idx) => ( - + {review.bot.username} diff --git a/website/src/pages/index.tsx b/website/src/pages/index.tsx index 4a1747f88..31860e290 100644 --- a/website/src/pages/index.tsx +++ b/website/src/pages/index.tsx @@ -1,7 +1,6 @@ import React from 'react' import useDocusaurusContext from '@docusaurus/useDocusaurusContext' import Layout from '@theme/Layout' -import 'animate.css' import DiscordenoHeader from '../components/header' import { MainPage } from '../styling' import DiscordenoFeatures from '../components/home/features' @@ -10,7 +9,59 @@ import DiscordenoReviews from '../components/home/reviews' import DiscordenoFAQ from '../components/home/faq' export default function Home(): JSX.Element { - const { siteConfig } = useDocusaurusContext() + // Use loading to give time to JS to load + const [loading, setLoading] = React.useState(true) + + React.useEffect(() => { + setTimeout(() => { + setLoading(false) + + // give it a small timeout to make sure the loading screen is shown + }, 1000) + }, []) + + if (loading) + return ( +
+
+ Discordeno Logo + + Loading... + +
+
+ ) + return ( = 1.12.0": +"babel-plugin-styled-components@npm:>= 1.12.0, babel-plugin-styled-components@npm:^2.1.1": version: 2.1.1 resolution: "babel-plugin-styled-components@npm:2.1.1" dependencies: @@ -12294,7 +12287,7 @@ __metadata: "@tsconfig/docusaurus": ^1.0.5 "@typescript-eslint/eslint-plugin": ^5.57.1 "@typescript-eslint/parser": ^5.57.1 - animate.css: ^4.1.1 + babel-plugin-styled-components: ^2.1.1 chart.js: ^4.2.1 clsx: ^1.2.1 eslint: ^8.38.0 From fd518cb554e060d9dfe077fa9ad564b44bd44ff6 Mon Sep 17 00:00:00 2001 From: Yaikava <83710104+Yaikava@users.noreply.github.com> Date: Sun, 16 Apr 2023 23:53:02 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=90=9B=20-=20fix:=20bot=20pkg=20-=20g?= =?UTF-8?q?ateway=20-=20prefer=20snakecase=20by=20default=20(#3006)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/bot/src/bot.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/bot/src/bot.ts b/packages/bot/src/bot.ts index cb10d0ea6..9e791ac57 100644 --- a/packages/bot/src/bot.ts +++ b/packages/bot/src/bot.ts @@ -23,8 +23,8 @@ import type { Role } from './transformers/role.js' import type { ScheduledEvent } from './transformers/scheduledEvent.js' import type { Sticker } from './transformers/sticker.js' import type { ThreadMember } from './transformers/threadMember.js' -import type { VoiceState } from './transformers/voiceState.js' import type { User } from './transformers/user.js' +import type { VoiceState } from './transformers/voiceState.js' /** * Create a bot object that will maintain the rest and gateway connection. @@ -50,6 +50,7 @@ export function createBot(options: CreateBotOptions): Bot { options.rest.token = options.token options.gateway.intents = options.intents + options.gateway.preferSnakeCase = true const id = getBotIdFromToken(options.token) From 3ebe1516432399123e2808ba0247ffafb0a154a3 Mon Sep 17 00:00:00 2001 From: Awesome Stickz Date: Mon, 17 Apr 2023 07:27:02 +0530 Subject: [PATCH 4/4] fix(website): faq grammar (#3003) * fix: website faq grammar * fix: more faq grammar fixes * Update website/src/components/home/faq/index.tsx * Update website/src/components/home/faq/index.tsx --------- Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> --- website/src/components/home/faq/index.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/website/src/components/home/faq/index.tsx b/website/src/components/home/faq/index.tsx index 334284e7d..5747e0b1a 100644 --- a/website/src/components/home/faq/index.tsx +++ b/website/src/components/home/faq/index.tsx @@ -57,15 +57,13 @@ const questions = [ defaultExpanded: false, }, { - question: "Why doesn't Discordeno use Classes like other libraries?", - answer: - 'Yes and No. Generally, Discordeno does not use classes. However, in certain cases where it makes sense we do use them. Instead, Discordeno uses plain JavaScript objects to define commands, events, and other components. This design choice was made to keep the library lightweight and simple, and to allow for more flexible and dynamic code, as components can be easily modified and extended at runtime. While classes can be useful in some cases, Discordeno has chosen to use a more functional approach.', + question: "Why doesn't Discordeno use classes like other libraries?", + answer: "Generally, Discordeno does not use classes. Instead, Discordeno uses plain JavaScript objects to define commands, events, and other components. However, in certain cases where it makes sense, we do use classes. This design choice was made to keep the library lightweight and simple and to allow for more flexible and dynamic code, as components can be easily modified and extended at runtime. While classes can be useful in some cases, Discordeno has chosen to use a more functional approach.", defaultExpanded: false, }, { question: 'Can I still use classes in my bot with Discordeno?', - answer: - "Yes! While Discordeno itself does not use classes, you can still use classes in your own code by using one of the many libraries or frameworks that provide class-based abstractions on top of Discordeno. Some examples of such libraries include the Discordeno.js which provides a very similar framework and API to Discord.js or the Sinf library that provides a similar API to Eris library. These libraries provide classes and other abstractions that can help simplify the development of your bot, while still leveraging the power and flexibility of Discordeno's underlying object-based API. Make sure to check the documentation of these libraries for more information on how to use them in your bot.", + answer: "Yes! While Discordeno itself does not use classes, you can still use classes in your own code by using one of the many libraries or frameworks that provide class-based abstractions on top of Discordeno. Some examples of such libraries include the Discordeno.js which provides a very similar framework and API to Discord.js, or the Sinf library that provides a similar API to Eris library. These libraries provide classes and other abstractions that can help simplify the development of your bot, while still leveraging the power and flexibility of Discordeno's underlying object-based API. Make sure to check the documentation of these libraries for more information on how to use them in your bot.", defaultExpanded: false, }, ]