aaa
This commit is contained in:
parent
641c37437d
commit
78d710201c
@ -371,8 +371,23 @@ class ModLogCog(commands.Cog):
|
||||
return
|
||||
|
||||
# Fetch user objects if possible to show names
|
||||
moderator = await self.bot.fetch_user(record['moderator_id'])
|
||||
target = await self.bot.fetch_user(record['target_user_id'])
|
||||
# Special handling for AI moderator (ID 0) to avoid Discord API 404 error
|
||||
if record['moderator_id'] == 0:
|
||||
# AI moderator uses ID 0, which is not a valid Discord user ID
|
||||
moderator = None
|
||||
else:
|
||||
try:
|
||||
moderator = await self.bot.fetch_user(record['moderator_id'])
|
||||
except discord.NotFound:
|
||||
log.warning(f"Moderator with ID {record['moderator_id']} not found when viewing case {case_id}")
|
||||
moderator = None
|
||||
|
||||
try:
|
||||
target = await self.bot.fetch_user(record['target_user_id'])
|
||||
except discord.NotFound:
|
||||
log.warning(f"Target user with ID {record['target_user_id']} not found when viewing case {case_id}")
|
||||
target = None
|
||||
|
||||
duration = datetime.timedelta(seconds=record['duration_seconds']) if record['duration_seconds'] else None
|
||||
|
||||
embed = self._format_log_embed(
|
||||
@ -424,8 +439,23 @@ class ModLogCog(commands.Cog):
|
||||
log_message = await log_channel.fetch_message(original_record['log_message_id'])
|
||||
if log_message and log_message.author == self.bot.user and log_message.embeds:
|
||||
# Re-fetch users/duration to reconstruct embed accurately
|
||||
moderator = await self.bot.fetch_user(original_record['moderator_id'])
|
||||
target = await self.bot.fetch_user(original_record['target_user_id'])
|
||||
# Special handling for AI moderator (ID 0) to avoid Discord API 404 error
|
||||
if original_record['moderator_id'] == 0:
|
||||
# AI moderator uses ID 0, which is not a valid Discord user ID
|
||||
moderator = None
|
||||
else:
|
||||
try:
|
||||
moderator = await self.bot.fetch_user(original_record['moderator_id'])
|
||||
except discord.NotFound:
|
||||
log.warning(f"Moderator with ID {original_record['moderator_id']} not found when updating case {case_id}")
|
||||
moderator = None
|
||||
|
||||
try:
|
||||
target = await self.bot.fetch_user(original_record['target_user_id'])
|
||||
except discord.NotFound:
|
||||
log.warning(f"Target user with ID {original_record['target_user_id']} not found when updating case {case_id}")
|
||||
target = None
|
||||
|
||||
duration = datetime.timedelta(seconds=original_record['duration_seconds']) if original_record['duration_seconds'] else None
|
||||
|
||||
new_embed = self._format_log_embed(
|
||||
|
@ -292,7 +292,33 @@ async def handle_error(ctx_or_interaction, error):
|
||||
# Only send detailed error DM if the command runner is the owner
|
||||
if is_owner:
|
||||
try:
|
||||
owner = await ctx_or_interaction.bot.fetch_user(user_id)
|
||||
# Get the bot instance - handle both Context and Interaction objects
|
||||
bot_instance = None
|
||||
if isinstance(ctx_or_interaction, commands.Context):
|
||||
bot_instance = ctx_or_interaction.bot
|
||||
elif hasattr(ctx_or_interaction, 'bot'):
|
||||
bot_instance = ctx_or_interaction.bot
|
||||
elif hasattr(ctx_or_interaction, 'client'):
|
||||
bot_instance = ctx_or_interaction.client
|
||||
|
||||
# If we couldn't get the bot instance, try to get it from the global accessor
|
||||
if not bot_instance:
|
||||
try:
|
||||
# Import here to avoid circular imports
|
||||
from global_bot_accessor import get_bot_instance
|
||||
bot_instance = get_bot_instance()
|
||||
except ImportError:
|
||||
print("Failed to import global_bot_accessor")
|
||||
except Exception as e:
|
||||
print(f"Error getting bot instance from global_bot_accessor: {e}")
|
||||
|
||||
# If we still don't have a bot instance, we can't send a DM
|
||||
if not bot_instance:
|
||||
print(f"Failed to send error DM to owner: No bot instance available")
|
||||
return
|
||||
|
||||
# Now fetch the owner user
|
||||
owner = await bot_instance.fetch_user(user_id)
|
||||
if owner:
|
||||
full_error = f"Full error details:\n```\n{str(error)}\n"
|
||||
if hasattr(error, '__dict__'):
|
||||
|
Loading…
x
Reference in New Issue
Block a user