diff --git a/src/bot/commands/bot.ts b/src/bot/commands/bot.ts index 8388984..0564440 100644 --- a/src/bot/commands/bot.ts +++ b/src/bot/commands/bot.ts @@ -46,7 +46,7 @@ async function buildInfo(bot: Bot, guildId?: BigString): Promise { - const edit = async (message: CreateMessageOptions) => await interaction.edit(message); + const edit = async (message: CreateMessageOptions) => await interaction.edit(message).catch((...args) => ['chat interaction', interaction, ...args].forEach(x => interaction.bot.logger.warn(x))); await buildInfo(interaction.bot, interaction.user.id, edit, interaction.guildId, options); }, message: async ({ message, bot, args, env }) => { @@ -47,8 +48,11 @@ export default createCommand({ let previousMsg: Message | undefined; const edit = async (msg: CreateMessageOptions) => { // console.log(previousMsg ? previousMsg.id : "no previous message"); - if (previousMsg) { - previousMsg = await bot.helpers.editMessage(previousMsg.channelId, previousMsg.id, msg); + if (previousMsg?.id) { + previousMsg = await bot.helpers.editMessage(previousMsg.channelId, previousMsg.id, msg).catch((...args) => { + ['chat message', previousMsg, ...args].forEach(x => bot.logger.warn(x)) + return undefined; + }); } else { previousMsg = await bot.helpers.sendMessage(message.channelId, { ...msg, @@ -125,9 +129,8 @@ async function buildInfo( // if last update was more than 1 second ago lastUpdate = Date.now(); await edit({ - content: `${data.result}<${loadingIndicator.emoji.animated ? "a" : ""}:${loadingIndicator.emoji.name}:${ - loadingIndicator.emoji.id - }>`, + content: `${data.result}<${loadingIndicator.emoji.animated ? "a" : ""}:${loadingIndicator.emoji.name}:${loadingIndicator.emoji.id + }>`, }); } } else {