Trying to parse mentions

This commit is contained in:
AllfatherHatt 2025-02-20 20:27:26 +01:00
parent dabee89145
commit 4e64b77b91

View File

@ -38,7 +38,7 @@ class ReginaldCog(commands.Cog):
@commands.command(name="reginald", help="Ask Reginald a question in shared channels") @commands.command(name="reginald", help="Ask Reginald a question in shared channels")
@commands.cooldown(1, 10, commands.BucketType.user) @commands.cooldown(1, 10, commands.BucketType.user)
async def reginald(self, ctx, *, prompt=None): async def reginald(self, ctx, *, prompt=None):
"""Handles multi-user memory tracking in shared channels""" """Handles multi-user memory tracking in shared channels, recognizing mentions properly."""
if not await self.is_admin(ctx) and not await self.is_allowed(ctx): if not await self.is_admin(ctx) and not await self.is_allowed(ctx):
await ctx.send("You do not have the required role to use this command.") await ctx.send("You do not have the required role to use this command.")
@ -53,7 +53,11 @@ class ReginaldCog(commands.Cog):
await ctx.send("OpenAI API key not set. Use `!setreginaldcogapi`.") await ctx.send("OpenAI API key not set. Use `!setreginaldcogapi`.")
return return
channel_id = str(ctx.channel.id) # ✅ Track memory per-channel channel_id = str(ctx.channel.id)
# ✅ Convert mentions into readable names
for mention in ctx.message.mentions:
prompt = prompt.replace(f"<@{mention.id}>", mention.display_name)
# ✅ Ensure only one update per channel at a time # ✅ Ensure only one update per channel at a time
if channel_id not in self.memory_locks: if channel_id not in self.memory_locks: