Fix reflecting generated embeds
This commit is contained in:
parent
c615ea1e61
commit
bce3d0f2c9
1 changed files with 13 additions and 7 deletions
|
@ -90,6 +90,7 @@ async function sendEvent(event) {
|
|||
}))
|
||||
|
||||
let eventPart = 0 // 0 is primary, 1 is supporting
|
||||
const pendingEdits = []
|
||||
|
||||
/** @type {DiscordTypes.APIMessage[]} */
|
||||
const messageResponses = []
|
||||
|
@ -121,13 +122,16 @@ async function sendEvent(event) {
|
|||
*/
|
||||
const sentEmbedsCount = message.embeds?.length || 0
|
||||
if (messageResponse.embeds.length > sentEmbedsCount) {
|
||||
// @ts-ignore this is a valid message edit payload
|
||||
editMessage.editMessage({ // not awaiting because requests to Matrix shouldn't block requests to Discord
|
||||
id: messageResponse.channel_id,
|
||||
channel_id: messageResponse.channel_id,
|
||||
guild_id: guild.id,
|
||||
embeds: messageResponse.embeds
|
||||
}, guild, null)
|
||||
// not awaiting here because requests to Matrix shouldn't block requests to Discord
|
||||
pendingEdits.push(() =>
|
||||
// @ts-ignore this is a valid message edit payload
|
||||
editMessage.editMessage({
|
||||
id: messageResponse.id,
|
||||
channel_id: messageResponse.channel_id,
|
||||
guild_id: guild.id,
|
||||
embeds: messageResponse.embeds
|
||||
}, guild, null)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,6 +139,8 @@ async function sendEvent(event) {
|
|||
registerUser.ensureSimJoined(user, event.room_id)
|
||||
}
|
||||
|
||||
await Promise.all(pendingEdits.map(f => f())) // `await` will propagate any errors during editing
|
||||
|
||||
return messageResponses
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue