Reputation: 128
I'm trying to code a command in discord.py that when called, will give you a role called "DJ"
Here's my current code:
@client.command
async def role(ctx):
user = ctx.message.author
role = discord.utils.get(user.server.roles, name="DJ")
await client.add_roles(user, role)
It is also worth noting that this bot is in 2 servers, one of which does not have the DJ role in the server. Is that a problem?
Thank you
Upvotes: 0
Views: 126
Reputation: 600
You should be able to do something similar to
@client.command()
async def role(ctx, *, role: discord.Role):
await ctx.author.add_roles(role)
Upvotes: 1