Skip to content

Commit 3787c54

Browse files
authored
fix(discord): add Discord.ClientOptions (#2714)
Added missing gateway intents (as required in v13) Otherwise, a "TypeError [CLIENT_MISSING_INTENTS]" is thrown due to the upgraded to discord.js v13 in f14a1ca. For more informations visist discordjs.guide/additional-info/changes-in-v13.html#intents.
1 parent 00b468a commit 3787c54

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/messaging/discord.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import {RawUserData} from 'discord.js/typings/rawDataTypes';
77

88
const {notifyGroup, webhooks, notifyGroupSeries} = config.notifications.discord;
99
const {pollInterval, responseTimeout, token, userId} = config.captchaHandler;
10+
const clientOptions: Discord.ClientOptions = {
11+
intents: new Discord.Intents(),
12+
};
1013

1114
function getIdAndToken(webhook: string) {
1215
const match = /.*\/webhooks\/(\d+)\/(.+)/.exec(webhook);
@@ -66,13 +69,13 @@ export function sendDiscordMessage(link: Link, store: Store) {
6669
const promises = [];
6770
for (const webhook of webhooks) {
6871
const {id, token} = getIdAndToken(webhook);
69-
const client = new Discord.WebhookClient({id, token});
72+
const client = new Discord.WebhookClient({id, token}, clientOptions);
7073

7174
promises.push(
7275
new Promise((resolve, reject) => {
7376
client
7477
.send({
75-
content: notifyText.join(' '),
78+
content: notifyText.length ? notifyText.join(' ') : null,
7679
embeds: [embed],
7780
username: 'streetmerchant',
7881
})
@@ -199,7 +202,7 @@ export async function sendDMAndGetResponseAsync(
199202
async function getDiscordClientAsync() {
200203
let clientInstance = undefined;
201204
if (token) {
202-
clientInstance = new Discord.Client({} as Discord.ClientOptions);
205+
clientInstance = new Discord.Client(clientOptions);
203206
await clientInstance.login(token);
204207
}
205208
return clientInstance;

0 commit comments

Comments
 (0)