Hey, I would like my bot to give a role via command. I did it but it does not work. I would ask for help.
code:
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
@bot.command(pass_context=True)#?
async def role (ctx, userName: discord.User):
await bot.add_roles(userName, name='test')
bot.run()
Add_roles does not take in a kwarg "name", it takes in an argument list of role objects. You can get these by iterating through server.roles- discord.utils.get() is helpful for this.
discord.Role is a converter in which you can pass as an argument in your command to add a role to persay, a bot or a user: For instance:
async def role(ctx, user: discord.User, role: discord.Role):
Most helpful comment
discord.Role is a converter in which you can pass as an argument in your command to add a role to persay, a bot or a user: For instance:
async def role(ctx, user: discord.User, role: discord.Role):