diff --git a/ClemBot.Api/ClemBot.Api.Core/Features/Messages/Bot/Create.cs b/ClemBot.Api/ClemBot.Api.Core/Features/Messages/Bot/Create.cs index f450bf62..fbbefa77 100644 --- a/ClemBot.Api/ClemBot.Api.Core/Features/Messages/Bot/Create.cs +++ b/ClemBot.Api/ClemBot.Api.Core/Features/Messages/Bot/Create.cs @@ -1,16 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using ClemBot.Api.Common.Utilities; using ClemBot.Api.Data.Contexts; using ClemBot.Api.Data.Models; using ClemBot.Api.Services.Caching.Channels.Models; using ClemBot.Api.Services.Caching.Guilds.Models; using ClemBot.Api.Services.Caching.Users.Models; -using FluentValidation; -using MediatR; using NodaTime.Text; namespace ClemBot.Api.Core.Features.Messages.Bot; diff --git a/ClemBot.Bot/bot/api/message_route.py b/ClemBot.Bot/bot/api/message_route.py index cc8bd893..2eb528ac 100644 --- a/ClemBot.Bot/bot/api/message_route.py +++ b/ClemBot.Bot/bot/api/message_route.py @@ -1,4 +1,5 @@ import typing as t +from datetime import datetime from bot.api.api_client import ApiClient from bot.api.base_route import BaseRoute @@ -16,6 +17,7 @@ async def create_message( guild_id: int, author_id: int, channel_id: int, + time: datetime, **kwargs: t.Any, ) -> None: json = { @@ -26,6 +28,7 @@ async def create_message( "GuildId": guild_id, "UserId": author_id, "ChannelId": channel_id, + "Time": time.strftime("%Y-%m-%dT%H:%M:%S.%f"), } ] } diff --git a/ClemBot.Bot/bot/services/emote_board_service.py b/ClemBot.Bot/bot/services/emote_board_service.py index 1ec86453..554525fc 100644 --- a/ClemBot.Bot/bot/services/emote_board_service.py +++ b/ClemBot.Bot/bot/services/emote_board_service.py @@ -84,6 +84,20 @@ async def on_reaction_add(self, event: RawReactionActionEvent) -> None: post = await self.bot.emote_board_route.get_post_from_board(guild, message, board) + # if the user is a bot, it's very likely we did not store their message in the db... + if message.author.bot: + stored_message = await self.bot.message_route.get_message(message.id) + if stored_message is None: + await self.bot.message_route.create_message( + message.id, + message.content, + guild.id, + message.author.id, + channel.id, + message.created_at, + raise_on_error=True, + ) + if not post: await self._create_post(board, message, users) return