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

[Pick] Send an embed, rather than a message containing only the winner's id. #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
19 changes: 17 additions & 2 deletions pick/pick.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,28 @@ def format_help_for_context(self, ctx: commands.Context) -> str:
@commands.command()
@commands.guild_only()
@checks.mod()
async def pick(self, ctx: commands.Context, *, role: typing.Optional[discord.Role]):
async def pick(self, ctx: commands.Context, embed: typing.Optional[bool]=True, *, role: typing.Optional[discord.Role]):
"""Pick a random user. *Output is a user ID.*

I suggest using [nestedcommands by tmerc](https://github.com/tmercswims/tmerc-cogs)
Example of usage `[p]say Congratulations <@$(pick)>! You won!`"""
if not role or not role.members:
role = ctx.guild.default_role
winner = random.choice(ctx.guild.members)
else:
role = role
winner = random.choice(role.members)
await ctx.send(f"{winner.id}")
if embed:
embed: discord.Embed = discord.Embed()
embed.title = name=f"{winner}"
embed.description = f"Mention: {winner.mention} - Id: {winner.id}"
embed.color = 0xffd700
embed.set_thumbnail(url=winner.avatar_url)
embed.add_field(
name="Chosen among the members of the role:",
value=f"{role.mention} ({role.id})")
embed.set_author(name=winner, icon_url=winner.avatar_url)
embed.set_footer(text="Chosen by the cog Pick.", icon_url="https://static.vecteezy.com/ti/vecteur-libre/p1/2477187-icone-de-decoration-etoile-doree-gratuit-vectoriel.jpg")
await ctx.send(embed=embed)
else:
await ctx.send(f"{winner.id}")