L
L
Lood3242022-02-01 18:21:20
Python
Lood324, 2022-02-01 18:21:20

How to make an error about not specifying the discord.py role?

I tried to make a command thanks to which I can issue roles on command. But I stopped at the question "How to make a mistake about not mentioning a role?" this is how I tried to do it:

@client.command()
@commands.has_permissions(administrator=True)
async def giverole(self, ctx, user: discord.Member=None, role=discord.Role):
  await user.add_roles(role)
  if user is None:
    embed = discord.Embed(
    title='**Moderation | error**',
    description="""<:None:936319127247806497>|•**Member not specified!**
<:None:936319127247806497>|•**Участник не указан**""", timestamp=ctx.message.created_at, color = discord.Colour.dark_red()
  )
  embed.set_footer(text="Modertion | error", icon_url=ctx.author.avatar_url)
  elif role == None:
    embed = discord.Embed(
    title='**Moderation | error**',
    description="""<:None:936319127247806497>|•**discord role not specified!**
<:None:936319127247806497>|•**Не указана дискорд роль**""", timestamp=ctx.message.created_at, color = discord.Colour.dark_red()
  )
  embed.set_footer(text="Modertion | error", icon_url=ctx.author.avatar_url)
  else:
    embed = discord.Embed(
    title="moderation",
    description="""the role was given! 
Роль была выдона"""
    timestamp=ctx.message.created_at, color discord.Colour.green()
  )
  embed.set_footer(text="Modertion | /giverole", icon_url=ctx.author.avatar_url)
  await ctx.send(embed=embed)

And if you want, you can give me a couple of tips "How to make a better team"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Georgy Kharitonov, 2022-02-02
@Lood324

Just like with the user:

...role: discord.Role=None):
...
    if role == None:
        ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question