From 4f70f06de7e58a5df00ec800c7c1c5c40b71687c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Vrba?= Date: Sat, 5 Oct 2024 11:49:55 +0200 Subject: [PATCH] Add debug logging for now --- bot/index.js | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/bot/index.js b/bot/index.js index eb338ad..fb54a99 100644 --- a/bot/index.js +++ b/bot/index.js @@ -27,26 +27,28 @@ client.on("messageCreate", (event) => { return; } + const request = { + message_id: event.id.toString(), + user: { + id: event.author.id.toString(), + name: event.author.username, + avatar_url: event.author.avatarURL() + }, + channel: { + id: event.channelId.toString(), + name: event.channel.name, + }, + guild: { + id: event.guildId.toString(), + name: event.guild.name, + icon_url: event.guild.iconURL() + } + }; + fetch(API_ENDPOINT, { method: "POST", credentials: "omit", - body: JSON.stringify({ - message_id: event.id.toString(), - user: { - id: event.author.id.toString(), - name: event.author.username, - avatar_url: event.author.avatarURL() - }, - channel: { - id: event.channelId.toString(), - name: event.channel.name, - }, - guild: { - id: event.guildId.toString(), - name: event.guild.name, - icon_url: event.guild.iconURL() - } - }), + body: JSON.stringify(request), headers: { "Accept": "application/json", "Content-Type": "application/json", @@ -55,6 +57,8 @@ client.on("messageCreate", (event) => { }) .then(response => response.json()) .then(async response => { + console.log({request, response}); + if (!response.matches) { return; }