import discord
import discord.ext
from discord.ext import commands
from discord.ext.commands import Bot
import asyncio
bot=commands.Bot(command_prefix='v.')
@bot.event
async def on_ready():
print(bot.user.name)
@bot.command(pass_context=True)
async def role(ctx):
user_role=ctx.message.author.roles
print(user_role)
bot.run('bot token')
我想让使用该命令的用户的角色名称能够从用户删除命令,但我得到了这个回复
[<discord.role.Role object at 0x067A83B0>, <discord.role.Role object at 0x067A8530>, <discord.role.Role object at 0x067A84B0>, <discord.role.Role object at 0x067A8630>]
如何处理不和谐对象?
答案 0 :(得分:1)
您可以查看discord.Role
对象here的所有属性。所以你可以做到
@bot.command(pass_context=True)
async def role(ctx):
user_role=ctx.message.author.roles
for r in user_role:
print(r.name)