Eating my own dogfood. Using the embed method for the avatar function

This commit is contained in:
Luke Robles 2018-03-12 12:51:56 -07:00
parent 87995bd2fc
commit 90616bbe25

View File

@ -66,14 +66,6 @@ async def on_message(message):
""" """
return m.author == message.author return m.author == message.author
if client.user.mentioned_in(message):
await client.send_message(
message.channel,
"{} ```{}```".format(
message.author.mention,
questions.answer_question(message.content)
)
)
def generate_embed(embed_url, embed_title=None, embed_description=None): def generate_embed(embed_url, embed_title=None, embed_description=None):
@ -96,13 +88,22 @@ async def on_message(message):
embed.set_image(url=image) embed.set_image(url=image)
return embed return embed
if client.user.mentioned_in(message):
await client.send_message(
message.channel,
"{} ```{}```".format(
message.author.mention,
questions.answer_question(message.content)
)
)
if message.content.startswith('!8ball'): if message.content.startswith('!8ball'):
await client.send_message( await client.send_message(
message.channel, message.channel,
eight_ball.check_8ball(message.content) eight_ball.check_8ball(message.content)
) )
if message.content.startswith('!avatar'): if message.content.startswith('!avatar'):
profile = [message.author] profile = [message.author]
if len(message.mentions): if len(message.mentions):
@ -111,13 +112,14 @@ async def on_message(message):
# Code stolen from this reddit post # Code stolen from this reddit post
# https://www.reddit.com/r/discordapp/comments/74bb4z/retrieve_a_mentioned_users_avatar_using_discordpy # https://www.reddit.com/r/discordapp/comments/74bb4z/retrieve_a_mentioned_users_avatar_using_discordpy
for user in profile: for user in profile:
embed = discord.Embed( await client.send_message(
title="{}#{}".format(user.name, user.discriminator), message.channel,
description="[Direct Link]({})".format(user.avatar_url.replace('.webp', '.png')), embed=generate_embed(
type='rich' embed_title="{}#{}".format(user.name, user.discriminator),
embed_url=user.avatar_url.replace('.webp', '.png'),
embed_description="[Direct Link]({})".format(user.avatar_url.replace('.webp', '.png'))
)
) )
embed.set_image(url=user.avatar_url.replace('.webp', '.png'))
await client.send_message(message.channel, embed=embed)
if message.content.startswith('!clap'): if message.content.startswith('!clap'):
await client.delete_message(message) await client.delete_message(message)