diff options
author | 2019-03-31 17:04:45 -0400 | |
---|---|---|
committer | 2019-03-31 17:04:45 -0400 | |
commit | 979160b9a8f41c3c99b9c4eb1ccb600695bcfc25 (patch) | |
tree | fef9ad798ad436fda6e62bc59e0172f66ed9345c | |
parent | Merge pull request #156 from python-discord/hotfix (diff) | |
parent | Add lemon counter (diff) |
Merge pull request #175 from python-discord/lemonstats
Add lemon counter
-rw-r--r-- | bot/seasons/evergreen/lemonstats.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/bot/seasons/evergreen/lemonstats.py b/bot/seasons/evergreen/lemonstats.py new file mode 100644 index 00000000..b23c65a4 --- /dev/null +++ b/bot/seasons/evergreen/lemonstats.py @@ -0,0 +1,31 @@ +import logging + +from discord.ext import commands + + +log = logging.getLogger(__name__) + + +class LemonStats(commands.Cog): + """A cog for generating useful lemon-related statistics.""" + + def __init__(self, bot): + self.bot = bot + + @commands.command() + async def lemoncount(self, ctx: commands.Context): + """Count the number of users on the server with `'lemon'` in their nickname.""" + + async with ctx.typing(): + lemoncount = sum( + ['lemon' in server_member.display_name.lower() for server_member in self.bot.guilds[0].members] + ) + + await ctx.send(f"There are currently {lemoncount} lemons on the server.") + + +def setup(bot): + """Load LemonStats Cog.""" + + bot.add_cog(LemonStats(bot)) + log.info("LemonStats cog loaded") |