From 529b8145bf4f23fcb33fdeccd183d3745949596e Mon Sep 17 00:00:00 2001 From: utarwyn Date: Thu, 28 Jul 2022 00:56:02 +0200 Subject: [PATCH] GH-292: Add MessageContent intent if using text command --- src/index.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 19370762..6ab91730 100644 --- a/src/index.ts +++ b/src/index.ts @@ -57,10 +57,21 @@ class TicTacToe { intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, - GatewayIntentBits.GuildMessageReactions + GatewayIntentBits.GuildMessageReactions, + ...(this.config.textCommand ? [GatewayIntentBits.MessageContent] : []) ] }); - await client.login(loginToken); + + try { + await client.login(loginToken); + } catch (e: any) { + if (e.message?.startsWith('Privileged')) { + throw new Error('You must enable Message Content intent to use the text command.'); + } else { + throw e; + } + } + this.bot.attachToClient(client); }