Skip to content
Extraits de code Groupes Projets
Valider 8d2c2734 rédigé par Will Hunt's avatar Will Hunt
Parcourir les fichiers

Use intents

parent ca04d707
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -38,6 +38,9 @@ auth: ...@@ -38,6 +38,9 @@ auth:
# This MUST be a string (wrapped in quotes) # This MUST be a string (wrapped in quotes)
clientID: "12345" clientID: "12345"
botToken: "foobar" 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: logging:
# What level should the logger output to the console at. # What level should the logger output to the console at.
console: "warn" #silly, verbose, info, http, warn, error, silent console: "warn" #silly, verbose, info, http, warn, error, silent
......
...@@ -34,6 +34,8 @@ properties: ...@@ -34,6 +34,8 @@ properties:
type: "string" type: "string"
botToken: botToken:
type: "string" type: "string"
usePriviledgedIntents:
type: "boolean"
logging: logging:
type: "object" type: "object"
properties: properties:
......
...@@ -16,7 +16,7 @@ limitations under the License. ...@@ -16,7 +16,7 @@ limitations under the License.
import { DiscordBridgeConfigAuth } from "./config"; import { DiscordBridgeConfigAuth } from "./config";
import { DiscordStore } from "./store"; 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 { Log } from "./log";
import { MetricPeg } from "./metrics"; import { MetricPeg } from "./metrics";
...@@ -40,8 +40,11 @@ export class DiscordClientFactory { ...@@ -40,8 +40,11 @@ export class DiscordClientFactory {
// We just need to make sure we have a bearer token. // We just need to make sure we have a bearer token.
// Create a new Bot client. // Create a new Bot client.
this.botClient = new DiscordClient({ this.botClient = new DiscordClient({
fetchAllMembers: true, fetchAllMembers: this.config.usePriviledgedIntents,
messageCacheLifetime: 5, messageCacheLifetime: 5,
ws: {
intents: this.config.usePriviledgedIntents ? Intents.PRIVILEGED : Intents.NON_PRIVILEGED,
}
}); });
const waitPromise = new Promise((resolve, reject) => { const waitPromise = new Promise((resolve, reject) => {
...@@ -65,6 +68,9 @@ export class DiscordClientFactory { ...@@ -65,6 +68,9 @@ export class DiscordClientFactory {
const client = new DiscordClient({ const client = new DiscordClient({
fetchAllMembers: false, fetchAllMembers: false,
messageCacheLifetime: 5, messageCacheLifetime: 5,
ws: {
intents: Intents.NON_PRIVILEGED,
}
}); });
await client.login(token, false); await client.login(token, false);
...@@ -95,6 +101,9 @@ export class DiscordClientFactory { ...@@ -95,6 +101,9 @@ export class DiscordClientFactory {
const client = new DiscordClient({ const client = new DiscordClient({
fetchAllMembers: true, fetchAllMembers: true,
messageCacheLifetime: 5, messageCacheLifetime: 5,
ws: {
intents: Intents.NON_PRIVILEGED,
}
}); });
const jsLog = new Log("discord.js-ppt"); const jsLog = new Log("discord.js-ppt");
......
...@@ -108,6 +108,7 @@ export class DiscordBridgeConfigDatabase { ...@@ -108,6 +108,7 @@ export class DiscordBridgeConfigDatabase {
export class DiscordBridgeConfigAuth { export class DiscordBridgeConfigAuth {
public clientID: string; public clientID: string;
public botToken: string; public botToken: string;
public usePriviledgedIntents: boolean;
} }
export class DiscordBridgeConfigLogging { export class DiscordBridgeConfigLogging {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter