diff --git a/activitylog/activitylog.py b/activitylog/activitylog.py index d747121..65101cd 100644 --- a/activitylog/activitylog.py +++ b/activitylog/activitylog.py @@ -214,10 +214,11 @@ async def get_audit_entry( cached_entries = self.audit_logs[guild.id] # it seems that cached entries wont contain the updated audit event right when it happens, it seems to fire after the event handler that is in question, may help with high traffic bots though for entry in cached_entries: - if all(cond(entry) for cond in conditions): - return entry + if entry is not None: + if all(cond(entry) for cond in conditions): + return entry - # fallback to look at audit log for the guild + # fallback to look at audit log for qthe guild # print("firing get_audit_entry") # print(len(conditions)) if self.cache["check_audit"]: @@ -3210,6 +3211,12 @@ async def on_thread_create(self, thread: discord.Thread): if not self.should_log(thread.guild): return + # try to join the thread so we can log + try: + await thread.join() + except: + pass + audit_entry = await self.get_audit_entry( thread.guild, lambda e: e.action == discord.AuditLogAction.thread_create, diff --git a/chatbotassistant/chatbot.py b/chatbotassistant/chatbot.py index 3f10103..09d2495 100644 --- a/chatbotassistant/chatbot.py +++ b/chatbotassistant/chatbot.py @@ -502,7 +502,11 @@ def format_response(self, content: str, guild: discord.Guild): A string where emoji names and user display names (with or without leading '@') become proper Discord mentions. """ - emoji_map: Dict[str, str] = {emoji.name.lower(): str(emoji) for emoji in guild.emojis} + # allow pulling for multiple guilds + emoji_map: Dict[str, str] = {} + for e_guild in self.bot.guilds: + for emoji in e_guild.emojis: + emoji_map[emoji.name.lower()] = str(emoji) # user_map: Dict[str, str] = {member.display_name.lower(): member.mention for member in guild.members} # remove possible system bot name prefix n the response: @@ -2342,10 +2346,6 @@ async def on_message(self, message: discord.Message): ) ) - # TODO: for testing, remove - if channel.id not in [1367715420081229855, 532724833981562890, 703281764923211846]: - return - lock = self.channel_lock[channel.id] # if the lock is already taken, end after updating history if lock.locked(): @@ -2397,7 +2397,7 @@ async def on_message(self, message: discord.Message): except: pass else: - msg = await channel.send(response) + msg = await channel.send(response, reference=message, mention_author=False) @commands.Cog.listener() async def on_reaction_add(self, reaction: discord.Reaction, member: Union[discord.Member, discord.User]): diff --git a/mayhemmaker/mayhemmaker.py b/mayhemmaker/mayhemmaker.py index a224401..1125b74 100644 --- a/mayhemmaker/mayhemmaker.py +++ b/mayhemmaker/mayhemmaker.py @@ -210,22 +210,22 @@ async def check_cooldown( target_level: int = await self.level_cog.get_level(target) # check level cooldowns, default to global cooldowns otherwise lvl_usage_cooldowns = (await self.config.guild(guild).level_integration_usage_cooldowns())[action] - lvls = sorted(list(lvl_usage_cooldowns.keys())) + lvls = sorted([int(k) for k in lvl_usage_cooldowns.keys()]) member_usage_cooldown = 0 if lvl_usage_cooldowns: - member_usage_cooldown = bisect.bisect_left(lvls, str(member_level)) + member_usage_cooldown = bisect.bisect_left(lvls, member_level) if member_usage_cooldown != len( lvl_usage_cooldowns ): # if false then member has a higher level then configured - member_usage_cooldown = lvl_usage_cooldowns[lvls[member_usage_cooldown]] + member_usage_cooldown = lvl_usage_cooldowns[str(lvls[member_usage_cooldown])] lvl_applied_cooldowns = (await self.config.guild(guild).level_integration_applied_cooldowns())[action] - lvls = sorted(list(lvl_applied_cooldowns.keys())) + lvls = sorted([int(k) for k in lvl_applied_cooldowns.keys()]) target_applied_cooldown = 0 if lvl_applied_cooldowns: - target_applied_cooldown = bisect.bisect_left(lvls, str(target_level)) + target_applied_cooldown = bisect.bisect_left(lvls, target_level) if target_applied_cooldown != len(lvl_applied_cooldowns): - target_applied_cooldown = lvl_applied_cooldowns[lvls[target_applied_cooldown]] + target_applied_cooldown = lvl_applied_cooldowns[str(lvls[target_applied_cooldown])] if member_usage_cooldown: usage_cooldown = member_usage_cooldown @@ -292,12 +292,12 @@ async def apply_mayhem( max_duration = await self.config.guild(member.guild).max_duration() if self.level_cog is not None: lvl_maxduration = await self.config.guild(member.guild).level_integration_max_duration() - lvls = sorted(list(lvl_maxduration.keys())) + lvls = sorted([int(k) for k in lvl_maxduration.keys()]) member_level = await self.level_cog.get_level(ctx.author) if lvl_maxduration: - idx = bisect.bisect_left(lvls, str(member_level)) + idx = bisect.bisect_left(lvls, member_level) if idx != len(lvl_maxduration): - max_duration = lvl_maxduration[lvls[idx]] + max_duration = lvl_maxduration[str(lvls[idx])] if action != "shut": time = parse_timedelta(duration)