From 7a7f853cccad7f45f26ef4bfdc676113041d50bc Mon Sep 17 00:00:00 2001 From: brandons209 Date: Mon, 14 Jun 2021 15:50:09 -0400 Subject: [PATCH] add reply to activity log, minor change to birthday embed --- activitylog/activitylog.py | 23 ++++++++++++++++++++++- birthday/birthday.py | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/activitylog/activitylog.py b/activitylog/activitylog.py index 25108e1..fe989b1 100644 --- a/activitylog/activitylog.py +++ b/activitylog/activitylog.py @@ -30,9 +30,18 @@ TIMESTAMP_FORMAT = "%Y-%m-%d %X" # YYYY-MM-DD HH:MM:SS AUTHOR_TEMPLATE = "@{0.author.name}#{0.author.discriminator}(id:{0.author.id})" MESSAGE_TEMPLATE = AUTHOR_TEMPLATE + ": {0.clean_content}" +# 0 is Message object, 1 is the message replied too +REPLY_TEMPLATE = ( + AUTHOR_TEMPLATE + + " replied to @{1.author.name}#{1.author.discriminator}(id:{1.author.id}): {1.clean_content} [with]: {0.clean_content}" +) + # 0 is Message object, 1 is attachment URL ATTACHMENT_TEMPLATE = AUTHOR_TEMPLATE + ": {0.clean_content} (attachment url(s): {1})" +# 0 is Message object, 1 is sticker URL +STICKER_TEMPLATE = AUTHOR_TEMPLATE + ": {0.clean_content} (sticker url(s): {1})" + # 0 is Message object, 1 is attachment path DOWNLOAD_TEMPLATE = AUTHOR_TEMPLATE + ": {0.clean_content} (attachment(s) saved to {1})" @@ -88,6 +97,8 @@ class ActivityLogger(commands.Cog): h.close() async def initialize(self): + await self.bot.wait_until_ready() + guild_data = await self.config.all_guilds() channel_data = await self.config.all_channels() self.cache = await self.config.attrs() @@ -1334,7 +1345,17 @@ class ActivityLogger(commands.Cog): urls = ",".join(a.url for a in message.attachments) entry = ATTACHMENT_TEMPLATE.format(message, urls) else: - entry = MESSAGE_TEMPLATE.format(message) + if message.reference: + ref_channel = message.guild.get_channel(message.reference.channel_id) + ref_message = None + if ref_channel: + ref_message = await ref_channel.fetch_message(message.reference.message_id) + if ref_message: + entry = REPLY_TEMPLATE.format(message, ref_message) + else: + entry = MESSAGE_TEMPLATE.format(message) + else: + entry = MESSAGE_TEMPLATE.format(message) # don't calculate bot stats and make sure this isnt dm message if message.author.id != self.bot.user.id and isinstance(message.author, discord.Member): diff --git a/birthday/birthday.py b/birthday/birthday.py index 1b40915..f40bfab 100644 --- a/birthday/birthday.py +++ b/birthday/birthday.py @@ -99,6 +99,7 @@ class Birthday(commands.Cog): embed.description = f"{member.mention} is now **{age} years old!**" else: embed.description = f"Happy Birthday to {member.mention}!" + embed.set_footer("Add your birthday using the `bday` command!") try: await channel.send(embed=embed, allowed_mentions=discord.AllowedMentions.all()) except: