Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 'hide_author' param for confirmation #29

Merged
merged 1 commit into from
Jan 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions disputils/confirmation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ def confirmed(self) -> bool:
return self._confirmed

async def confirm(
self, text: str, user: discord.User, channel: discord.TextChannel = None
self,
text: str,
user: discord.User,
channel: discord.TextChannel = None,
hide_author: bool = False,
) -> bool or None:
"""
Run the confirmation.
Expand All @@ -45,13 +49,17 @@ async def confirm(
if ``self.message`` is None.
:type channel: :class:`discord.TextChannel`, optional

:param hide_author: Whether or not the ``user`` should be set as embed author.
:type hide_author: bool, optional

:return: True when it's been confirmed, otherwise False. Will return None when a
timeout occurs.
:rtype: :class:`bool`, optional
"""

emb = discord.Embed(title=text, color=self.color)
emb.set_author(name=str(user), icon_url=user.avatar_url)
if not hide_author:
emb.set_author(name=str(user), icon_url=user.avatar_url)

self._embed = emb

Expand Down Expand Up @@ -101,7 +109,11 @@ def __init__(
super().__init__(ctx.bot, color, message)

async def confirm(
self, text: str, user: discord.User = None, channel: discord.TextChannel = None
self,
text: str,
user: discord.User = None,
channel: discord.TextChannel = None,
hide_author: bool = False,
) -> bool or None:

if user is None:
Expand All @@ -110,4 +122,4 @@ async def confirm(
if self.message is None and channel is None:
channel = self._ctx.channel

return await super().confirm(text, user, channel)
return await super().confirm(text, user, channel, hide_author=hide_author)