fix action string being renamed, added activitylog stats to welcome

This commit is contained in:
brandons209 2020-01-31 19:35:59 -05:00
parent 43caca92c2
commit e7f2598a03
3 changed files with 18 additions and 7 deletions

View file

@ -270,11 +270,11 @@ class ActivityLogger(commands.Cog):
kicks = 0
mutes = 0
for case in cases:
if "mute" in case.action_str.lower():
if "mute" in case.action_type.lower():
mutes += 1
elif "ban" in case.action_str.lower():
elif "ban" in case.action_type.lower():
bans += 1
elif "kick" in case.action_str.lower():
elif "kick" in case.action_type.lower():
kicks += 1
msg = "Total Number of Messages: `{}`\n".format(num_messages)
@ -1349,6 +1349,10 @@ class ActivityLogger(commands.Cog):
else:
entry = "Member leave: @{0} (id {0.id})".format(member)
# don't clear stats right away if welcome cog is install so it can pull user stats
if self.bot.get_cog("Welcome"):
await asyncio.sleep(1)
await self.config.member(member).clear()
await self.log(member.guild, entry)

View file

@ -4,4 +4,4 @@ from .welcome import Welcome
def setup(bot: Red):
bot.add_cog(Welcome())
bot.add_cog(Welcome(bot=bot))

View file

@ -69,8 +69,8 @@ class Welcome(commands.Cog):
}
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
super().__init__()
self.bot = kwargs["bot"]
self.config = Config.get_conf(self, 86345009)
self.config.register_guild(**self.guild_defaults)
@ -784,9 +784,16 @@ class Welcome(commands.Cog):
else:
roles = []
actlog = self.bot.get_cog("ActivityLogger")
if actlog:
stats = await actlog.userstats(guild, user)
stats = stats[0]
else:
stats = ""
try:
return await channel.send(
format_str.format(member=user, server=guild, bot=user, count=count or "", plural=plural, roles=roles)
format_str.format(member=user, server=guild, bot=user, count=count or "", plural=plural, roles=roles, stats=stats)
)
except discord.Forbidden:
log.error(