3434from core import auxiliary , cogs , custom_errors , extensionconfig
3535from discord import app_commands
3636from discord .ext import commands
37+ from functions import logger as function_logger
3738
3839if TYPE_CHECKING :
3940 import bot
@@ -873,7 +874,9 @@ async def response(
873874
874875 try :
875876 # define the message and send it
876- await ctx .reply (content = content , embed = embed , mention_author = not mentions )
877+ sent_message = await ctx .reply (
878+ content = content , embed = embed , mention_author = not mentions
879+ )
877880 # log it in the logging channel with type info and generic content
878881 config = self .bot .guild_configs [str (ctx .guild .id )]
879882 log_channel = config .get ("logging_channel" )
@@ -898,12 +901,15 @@ async def response(
898901 exception = exception ,
899902 )
900903 # Sends the raw factoid instead of the embed as fallback
901- await ctx .reply (
904+ sent_message = await ctx .reply (
902905 f"{ mentions + ' ' if mentions else '' } { factoid .message } " ,
903906 mention_author = not mentions ,
904907 )
905908
906909 await self .send_to_irc (ctx .channel , ctx .message , factoid .message )
910+ await self .send_to_logger (
911+ sent_message , ctx .author , ctx .channel , factoid .message
912+ )
907913
908914 async def send_to_irc (
909915 self : Self ,
@@ -929,6 +935,44 @@ async def send_to_irc(
929935 factoid_message = factoid_message ,
930936 )
931937
938+ async def send_to_logger (
939+ self : Self ,
940+ factoid_message_object : discord .Message ,
941+ factoid_caller : discord .Member ,
942+ channel : discord .abc .GuildChannel | discord .Thread ,
943+ factoid_message : str ,
944+ ) -> None :
945+ """Send a factoid call to the logger function
946+
947+ Args:
948+ factoid_message_object (discord.Message): The message that the factoid is sent in
949+ factoid_caller (discord.Member): The person who called the factoid
950+ channel (discord.abc.GuildChannel | discord.Thread): The channel the
951+ factoid was sent in
952+ factoid_message (str): The plaintext message content of the factoid
953+ """
954+ config = self .bot .guild_configs [str (channel .guild .id )]
955+
956+ # Don't allow logging if extension is disabled
957+ if "logger" not in config .enabled_extensions :
958+ return
959+
960+ target_logging_channel = await function_logger .pre_log_checks (
961+ self .bot , config , channel
962+ )
963+ if not target_logging_channel :
964+ return
965+
966+ await function_logger .send_message (
967+ self .bot ,
968+ factoid_message_object ,
969+ factoid_caller ,
970+ channel ,
971+ target_logging_channel ,
972+ content_override = factoid_message ,
973+ special_flags = ["Factoid call" ],
974+ )
975+
932976 @factoid_app_group .command (
933977 name = "call" ,
934978 description = "Calls a factoid from the database and sends it publicy in the channel." ,
@@ -1054,6 +1098,11 @@ async def factoid_call_command(
10541098 interaction .channel , interaction .message , factoid .message
10551099 )
10561100
1101+ sent_message = await interaction .original_response ()
1102+ await self .send_to_logger (
1103+ sent_message , interaction .user , interaction .channel , factoid .message
1104+ )
1105+
10571106 # -- Factoid job related functions --
10581107 async def kickoff_jobs (self : Self ) -> None :
10591108 """Gets a list of cron jobs and starts them"""
@@ -1230,6 +1279,7 @@ async def cronjob(
12301279 message = await channel .send (content = factoid .message )
12311280
12321281 await self .send_to_irc (channel , message , factoid .message )
1282+ await self .send_to_logger (message , ctx .author , ctx .channel , factoid .message )
12331283
12341284 @commands .group (
12351285 brief = "Executes a factoid command" ,
0 commit comments