[V3] Cleanup

This commit is contained in:
aikaterna
2018-08-08 21:54:06 -07:00
parent aabe0cd6a5
commit be13d0f686
21 changed files with 431 additions and 175 deletions

View File

@@ -1,11 +1,12 @@
{
"author": [
"aikaterna and Paddo"
"aikaterna"
],
"description": "Check when the user was last active on a server.",
"description": "Check when the user was last active on a server. Originally made by Paddo.",
"short": "Check when the user was last active on a server.",
"tags": [
"seen", "activity"
"seen",
"activity"
],
"type": "COG"
}

View File

@@ -11,43 +11,43 @@ class Seen:
self.bot = bot
self.config = Config.get_conf(self, 2784481001, force_registration=True)
default_member = {
"member_seen": []
}
default_member = {"member_seen": []}
self.config.register_member(**default_member)
@commands.guild_only()
@commands.command(name='seen')
@commands.command(name="seen")
async def _seen(self, ctx, author: discord.Member):
'''Shows last time a user was seen in chat'''
"""Shows last time a user was seen in chat"""
member_seen = await self.config.member(author).member_seen()
now = int(time.time())
try:
time_elapsed = int(now - member_seen)
except TypeError:
embed = discord.Embed(colour=discord.Color.red(), title='I haven\'t seen that user yet.')
embed = discord.Embed(
colour=discord.Color.red(), title="I haven't seen that user yet."
)
return await ctx.send(embed=embed)
output = self._dynamic_time(time_elapsed)
if output[2] < 1:
ts = 'just now'
ts = "just now"
else:
ts = ''
ts = ""
if output[0] == 1:
ts += '{} day, '.format(output[0])
ts += "{} day, ".format(output[0])
elif output[0] > 1:
ts += '{} days, '.format(output[0])
ts += "{} days, ".format(output[0])
if output[1] == 1:
ts += '{} hour, '.format(output[1])
ts += "{} hour, ".format(output[1])
elif output[1] > 1:
ts += '{} hours, '.format(output[1])
ts += "{} hours, ".format(output[1])
if output[2] == 1:
ts += '{} minute ago'.format(output[2])
ts += "{} minute ago".format(output[2])
elif output[2] > 1:
ts += '{} minutes ago'.format(output[2])
ts += "{} minutes ago".format(output[2])
em = discord.Embed(colour=discord.Color.green())
avatar = author.avatar_url if author.avatar else author.default_avatar_url
em.set_author(name='{} was seen {}'.format(author.display_name, ts), icon_url=avatar)
em.set_author(name="{} was seen {}".format(author.display_name, ts), icon_url=avatar)
await ctx.send(embed=em)
def _dynamic_time(self, time_elapsed):
@@ -57,7 +57,10 @@ class Seen:
return (d, h, m)
async def on_message(self, message):
if not isinstance(message.channel, discord.abc.PrivateChannel) and self.bot.user.id != message.author.id:
if (
not isinstance(message.channel, discord.abc.PrivateChannel)
and self.bot.user.id != message.author.id
):
prefixes = await self.bot.get_prefix(message)
if not any(message.content.startswith(n) for n in prefixes):
author = message.author