refactor(.github,README,gateway,plugins/fileloader,tests,types)!: make intent calculation manual

This changes the calculation of intents to be manual to the dev.
This is to improve overall consistency of our code base, also it is not a big drawback for users since intents are usually done once and then never (seldom) touched again.
This commit is contained in:
ITOH
2022-05-24 23:16:01 +02:00
parent 3a5263c4e9
commit d7883855ec
13 changed files with 35 additions and 37 deletions
+4 -3
View File
@@ -25,14 +25,14 @@ Create a file path like `src/bot/mod.ts`.
```ts
import { DISCORD_TOKEN } from "../../configs.ts";
import { Collection, createBot } from "../../deps.ts";
import { Collection, createBot, Intents } from "../../deps.ts";
import { psql } from "./cache/mod.ts";
export const bot = createBot({
token: DISCORD_TOKEN,
botId: 270010330782892032n,
// applicationId: 270010330782892032,
intents: ["Guilds", "GuildMessages"],
intents: Intents.Guilds | Intents.GuildMessages,
events: {
messageCreate: function (bot, message) {
console.log("message arrived");
@@ -126,7 +126,8 @@ Alright that was a lot of code. Now let's break it down little by little.
developers have mentioned that this behavior is not documented and not supposed to be relied on to remain stable. Due
to these reasons, we chose to just require the bot id be passed here.
- `applicationId` is an optional choice if your bot is old and has a unique id different from it's bot id.
- `intents`: Provide the intents you like using strings or a number. String form supports autocomplete and type safety.
- `intents`: Provide the intents you like using a bitwise OR operation (eg. `Intents.Guilds | Intents.GuildsMessages`).
String form supports autocomplete and type safety.
- `events`: These are your event handler functions. When a MESSAGE_CREATE event arrives from Discord it will be
processed here. We will set up the routing to run these functions later in the guide but for now you can see how to
set it up. Note, you can create these functions in separate files and just import them here as you wish.
+1 -1
View File
@@ -111,7 +111,7 @@ With this info, we can now create our gateway manager.
const gateway = createGatewayManager({
secretKey: EVENT_HANDLER_SECRET_KEY,
token: DISCORD_TOKEN,
intents: ["GuildMessages", "Guilds"],
intents: Intents.Guilds | Intents.GuildMessages,
shardsRecommended: result.shards,
sessionStartLimitTotal: result.sessionStartLimit.total,
sessionStartLimitRemaining: result.sessionStartLimit.remaining,
+2 -2
View File
@@ -45,11 +45,11 @@ Starting with Discordeno is very simple, you can start from scratch without any
of code into a new TypeScript file:
```ts
import { startBot } from "https://deno.land/x/discordeno/mod.ts";
import { Intents, startBot } from "https://deno.land/x/discordeno/mod.ts";
startBot({
token: "BOT TOKEN",
intents: ["GUILDS", "GUILD_MESSAGES"],
intents: Intents.Guilds | Intents.GuildMessages,
eventHandlers: {
ready() {
console.log("Successfully connected to gateway");
+1 -1
View File
@@ -161,7 +161,7 @@ startBot({
token: configs.token,
// Pick the intents you wish to have for your bot.
// For instance, to work with guild message reactions, you will have to pass the Intents.GUILD_MESSAGE_REACTIONS intent to the array.
intents: [Intents.GUILDS, Intents.GUILD_MESSAGES],
intents: Intents.Guilds | Intents.GuildMessages,
// These are all your event handler functions. Imported from the events folder
eventHandlers: botCache.eventHandlers,
});