helper method for matching bot embeds to users, improve helper method docs/formatting

This commit is contained in:
Xevion
2021-01-24 18:10:14 -06:00
parent e0e5636c5c
commit f2768df33f
2 changed files with 9 additions and 10 deletions

View File

@@ -54,7 +54,7 @@ class UnbelievaClient(discord.Client):
if message.author.id == self.bot_id and len(message.embeds) > 0: if message.author.id == self.bot_id and len(message.embeds) > 0:
embed = message.embeds[0] embed = message.embeds[0]
is_self = embed.author.name == f'{self.user.name}#{self.user.discriminator}' is_self = helpers.embed_author_matches(embed, self.user)
if is_self: if is_self:
if parsers.TaskCooldownMessage.check_valid(message): if parsers.TaskCooldownMessage.check_valid(message):

View File

@@ -1,15 +1,14 @@
from pprint import pprint from pprint import pprint
from typing import Union
import discord import discord
def print_embed(embed: discord.Embed) -> None: def print_embed(embed: discord.Embed) -> None:
pprint(( """Helper method for printing out a complex Embed's entire set of possible attributes."""
embed.title, pprint((embed.title, embed.description, embed.footer, embed.color, embed.fields, embed.author, embed.timestamp))
embed.description,
embed.footer,
embed.color, def embed_author_matches(embed: discord.Embed, user: Union[discord.User, discord.ClientUser]):
embed.fields, """Returns if the Unbelievabot Embed relates to the given user."""
embed.author, return embed.author != discord.embeds.EmptyEmbed and embed.author.name == f'{user.name}#{user.discriminator}'
embed.timestamp
))