Answer the question
In order to leave comments, you need to log in
Discord.py bot role error?
Good day!
I wrote a discord bot in python and an error occurred when adding new functions.
The function should return roles, but for now it returns this:
Traceback (most recent call last):
File "C:\Users\gafig.DESKTOP-B4N254S\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\bot.py", line 892, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\gafig.DESKTOP-B4N254S\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\core.py", line 790, in invoke
await self.prepare(ctx)
File "C:\Users\gafig.DESKTOP-B4N254S\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\core.py", line 751, in prepare
await self._parse_arguments(ctx)
File "C:\Users\gafig.DESKTOP-B4N254S\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\core.py", line 670, in _parse_arguments
transformed = await self.transform(ctx, param)
File "C:\Users\gafig.DESKTOP-B4N254S\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\core.py", line 516, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: member is a required argument that is missing.
@bot.command(pass_context=True)
async def вип(ctx,member:discord.Member):
await ctx.channel.purge(limit = 1)
vip_role = discord.utils.get(ctx.message.guild.roles,name = 'VIP')
await member.add_roles(vip_role)
retStr = (f"""```{member} получил VIP от администрации сервера!```""")
embed=discord.Embed(title="Новый VIP",colour = discord.Colour.orange())
embed.add_field(name="VIP",value=retStr)
await ctx.send(embed=embed)
Answer the question
In order to leave comments, you need to log in
MissingRequiredArgument means that the command did not receive the required argument.
The command written in your example requires you to specify a user.
Note: [p]
- the prefix specified for your bot
[p]вип
- will return an error
[p]вип DiscordTag#0000
- will not return if a user with the DiscordTag#0000 tag exists on the server command is always Note: - I assume that this piece of code is used by you to delete the message with the command. If so, I recommend replacing it with to avoid the (possible) "racing condition"
pass_context=True
await ctx.channel.purge(limit = 1)
await ctx.message.delete()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question