test that edits by webhook work

This commit is contained in:
Cadence Ember 2023-08-17 19:03:09 +12:00
parent b9de84e586
commit e3737997ec
5 changed files with 158 additions and 90 deletions

View file

@ -37,6 +37,13 @@ module.exports = {
* @param {import("discord-api-types/v10").GatewayMessageUpdateDispatchData} message
*/
onMessageUpdate(client, data) {
if (data.webhook_id) {
const row = db.prepare("SELECT webhook_id FROM webhook WHERE webhook_id = ?").pluck().get(message.webhook_id)
if (row) {
// The update was sent by the bridge's own webhook on discord. We don't want to reflect this back, so just drop it.
return
}
}
// Based on looking at data they've sent me over the gateway, this is the best way to check for meaningful changes.
// If the message content is a string then it includes all interesting fields and is meaningful.
if (typeof data.content === "string") {