diff --git a/config/config.sample.yaml b/config/config.sample.yaml index b722917a701995f80f8e2271977ce5814718c76b..11fc75e5fddf36245ea9daddea2e9eefd589de22 100644 --- a/config/config.sample.yaml +++ b/config/config.sample.yaml @@ -38,6 +38,9 @@ auth: # This MUST be a string (wrapped in quotes) clientID: "12345" botToken: "foobar" + # You must enable "Privileged Gateway Intents" in your bot settings on discord.com (e.g.g https://discord.com/developers/applications/12345/bot) + # for this to work + usePriviledgedIntents: false logging: # What level should the logger output to the console at. console: "warn" #silly, verbose, info, http, warn, error, silent diff --git a/config/config.schema.yaml b/config/config.schema.yaml index 860f1310100ee6e686486d8e841fa0ea3fab3a5f..89fe1876acfbc5b4235652d2f31cb0e067b12bb6 100644 --- a/config/config.schema.yaml +++ b/config/config.schema.yaml @@ -34,6 +34,8 @@ properties: type: "string" botToken: type: "string" + usePriviledgedIntents: + type: "boolean" logging: type: "object" properties: diff --git a/src/clientfactory.ts b/src/clientfactory.ts index 149e562bade81175655ba6d52f18828a7f683970..dcf10630dcdbd8c3b9a7201350e97cd0a54cb728 100644 --- a/src/clientfactory.ts +++ b/src/clientfactory.ts @@ -16,7 +16,7 @@ limitations under the License. import { DiscordBridgeConfigAuth } from "./config"; import { DiscordStore } from "./store"; -import { Client as DiscordClient, TextChannel } from "better-discord.js"; +import { Client as DiscordClient, Intents, TextChannel } from "better-discord.js"; import { Log } from "./log"; import { MetricPeg } from "./metrics"; @@ -40,8 +40,11 @@ export class DiscordClientFactory { // We just need to make sure we have a bearer token. // Create a new Bot client. this.botClient = new DiscordClient({ - fetchAllMembers: true, + fetchAllMembers: this.config.usePriviledgedIntents, messageCacheLifetime: 5, + ws: { + intents: this.config.usePriviledgedIntents ? Intents.PRIVILEGED : Intents.NON_PRIVILEGED, + } }); const waitPromise = new Promise((resolve, reject) => { @@ -65,6 +68,9 @@ export class DiscordClientFactory { const client = new DiscordClient({ fetchAllMembers: false, messageCacheLifetime: 5, + ws: { + intents: Intents.NON_PRIVILEGED, + } }); await client.login(token, false); @@ -95,6 +101,9 @@ export class DiscordClientFactory { const client = new DiscordClient({ fetchAllMembers: true, messageCacheLifetime: 5, + ws: { + intents: Intents.NON_PRIVILEGED, + } }); const jsLog = new Log("discord.js-ppt"); diff --git a/src/config.ts b/src/config.ts index 8a77acb43eb68757f0747128b8c1ec8f825f07f2..dfe75e9a3658ad8ea526fa14ba07060469d58cae 100644 --- a/src/config.ts +++ b/src/config.ts @@ -108,6 +108,7 @@ export class DiscordBridgeConfigDatabase { export class DiscordBridgeConfigAuth { public clientID: string; public botToken: string; + public usePriviledgedIntents: boolean; } export class DiscordBridgeConfigLogging {