-
Notifications
You must be signed in to change notification settings - Fork 2
Updated user info to include users activity #64
base: master
Are you sure you want to change the base?
Conversation
Added a way to see the users activity in the user info command. This requires the lastest version of discord.py rewrite branch
@@ -152,14 +152,17 @@ def get_image(item, channel): | |||
@commands.command() | |||
@check_reddit | |||
async def headpat(self, ctx): | |||
''' Gets a random headpat image from /headpats ''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be /r/headpats
, not /headpats
?
f'Duration: {str(activity.duration).split(".")[0]}', | ||
] | ||
embed.add_field(name='Listening to:', value='\n'.join(actitivty_info)) | ||
embed.color = 1947988 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of magic constant colors, they should be constants, like STREAMING_COLOR
or something.
for member in guild.members: | ||
if member.id == user_id: | ||
return member | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can see if you like the discord.utils.get()
implementation instead:
def _get_member(self, user_id):
for guild in self.bot.guilds:
member = discord.utils.get(guild, id=user_id)
if member is not None:
return member
return None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also it should explicitly return None
if no member is found.
@@ -28,6 +28,7 @@ | |||
CHANNEL_REGEX = re.compile(r'<#([0-9]+)>') | |||
MENTION_REGEX = re.compile(r'<@!?([0-9]+)>') | |||
EMOJI_REGEX = re.compile(r'<:([A-Za-z~\-0-9]+):([0-9]+)>') | |||
SPOTIFY_OPEN_URL = 'http://open.spotify.com/track/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should have an empty space between the "regex constants" and the "url constants".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, given that you have this constant, is it worth making the other profile links (e.g. facebook, twitch) also be *_URL
constants?
|
||
member = self._get_member(user.id) | ||
activity = member.activity | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand removing user.game
stuff, but why was user.voice
and similar code removed?
await self.safe_or_react(ctx, '/r/headpats/random') | ||
|
||
@commands.command() | ||
@check_reddit | ||
async def megane(self, ctx): | ||
''' Gets a random megane image from /megane ''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
await self.safe_or_react(ctx, '/r/megane/random') | ||
|
||
@commands.command() | ||
@check_reddit | ||
async def hentai(self, ctx): | ||
''' Gets a random image from /hentai ''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
Added a way to see the users activity in the user info command. This requires the latest version of discord.py rewrite branch. This will need to be tidied up and make to look nicer
This also add doc string to the reddit commands