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