m->d edits now wait for original message
This commit is contained in:
@@ -98,7 +98,7 @@ function waitFor(id, resolve, existsInDatabase) {
|
|||||||
const GET_EVENT_PREPARED = from("event_message").select("event_id").and("WHERE event_id = ?").prepare().raw()
|
const GET_EVENT_PREPARED = from("event_message").select("event_id").and("WHERE event_id = ?").prepare().raw()
|
||||||
/**
|
/**
|
||||||
* @param {string} eventID
|
* @param {string} eventID
|
||||||
* @returns {Promise<boolean>} if true then the message did not arrive
|
* @returns {Promise<boolean>} if false then the message did not arrive
|
||||||
*/
|
*/
|
||||||
function waitForEvent(eventID) {
|
function waitForEvent(eventID) {
|
||||||
const {promise, resolve} = Promise.withResolvers()
|
const {promise, resolve} = Promise.withResolvers()
|
||||||
@@ -109,7 +109,7 @@ function waitForEvent(eventID) {
|
|||||||
const GET_MESSAGE_PREPARED = from("event_message").select("message_id").and("WHERE message_id = ?").prepare().raw()
|
const GET_MESSAGE_PREPARED = from("event_message").select("message_id").and("WHERE message_id = ?").prepare().raw()
|
||||||
/**
|
/**
|
||||||
* @param {string} messageID
|
* @param {string} messageID
|
||||||
* @returns {Promise<boolean>} if true then the message did not arrive
|
* @returns {Promise<boolean>} if false then the message did not arrive
|
||||||
*/
|
*/
|
||||||
function waitForMessage(messageID) {
|
function waitForMessage(messageID) {
|
||||||
const {promise, resolve} = Promise.withResolvers()
|
const {promise, resolve} = Promise.withResolvers()
|
||||||
@@ -120,7 +120,7 @@ function waitForMessage(messageID) {
|
|||||||
const GET_REACTION_EVENT_PREPARED = from("reaction").select("hashed_event_id").and("WHERE hashed_event_id = ?").prepare().raw()
|
const GET_REACTION_EVENT_PREPARED = from("reaction").select("hashed_event_id").and("WHERE hashed_event_id = ?").prepare().raw()
|
||||||
/**
|
/**
|
||||||
* @param {string} eventID
|
* @param {string} eventID
|
||||||
* @returns {Promise<boolean>} if true then the message did not arrive
|
* @returns {Promise<boolean>} if false then the message did not arrive
|
||||||
*/
|
*/
|
||||||
function waitForReactionEvent(eventID) {
|
function waitForReactionEvent(eventID) {
|
||||||
const {promise, resolve} = Promise.withResolvers()
|
const {promise, resolve} = Promise.withResolvers()
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ async function sendEvent(event) {
|
|||||||
channel_id: messageResponse.channel_id,
|
channel_id: messageResponse.channel_id,
|
||||||
guild_id: guild.id,
|
guild_id: guild.id,
|
||||||
embeds: messageResponse.embeds
|
embeds: messageResponse.embeds
|
||||||
}, guild, null)
|
}, guild)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ const setupEmojis = sync.require("../actions/setup-emojis")
|
|||||||
const userToMxid = sync.require("../../d2m/converters/user-to-mxid")
|
const userToMxid = sync.require("../../d2m/converters/user-to-mxid")
|
||||||
/** @type {import("../../web/routes/letter-avatar")} */
|
/** @type {import("../../web/routes/letter-avatar")} */
|
||||||
const letterAvatar = sync.require("../../web/routes/letter-avatar")
|
const letterAvatar = sync.require("../../web/routes/letter-avatar")
|
||||||
|
/** @type {import("../../d2m/actions/retrigger")} */
|
||||||
|
const retrigger = sync.require("../../d2m/actions/retrigger")
|
||||||
|
|
||||||
/** @type {[RegExp, string][]} */
|
/** @type {[RegExp, string][]} */
|
||||||
const markdownEscapes = [
|
const markdownEscapes = [
|
||||||
@@ -696,6 +698,7 @@ async function eventToMessage(event, guild, channel, di) {
|
|||||||
// Check if we have a pointer to what was edited
|
// Check if we have a pointer to what was edited
|
||||||
const originalEventId = relatesTo.event_id
|
const originalEventId = relatesTo.event_id
|
||||||
if (!originalEventId) return
|
if (!originalEventId) return
|
||||||
|
if (!await retrigger.waitForEvent(originalEventId)) return
|
||||||
messageIDsToEdit = select("event_message", "message_id", {event_id: originalEventId}, "ORDER BY part").pluck().all()
|
messageIDsToEdit = select("event_message", "message_id", {event_id: originalEventId}, "ORDER BY part").pluck().all()
|
||||||
if (!messageIDsToEdit.length) return
|
if (!messageIDsToEdit.length) return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user