如何获得用户角色

时间:2019-05-16 23:29:45

标签: python discord discord.py

我正在尝试为我的机器人制作票务系统。它曾经可以工作,但是现在不再起作用了,我不确定为什么。

过去,我曾尝试使用discord.Role(role_id),但遇到以下错误。

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: __init__() takes 1 positional argument but 2 were given

这是我当前的代码。

@client.command(pass_context=True)
async def maketicket(ctx):
    server = ctx.message.server
    author = ctx.message.author
    reason = ctx.message.content[12:] #subject of ticket


    everyone = discord.PermissionOverwrite(read_messages=False)
    staff = discord.PermissionOverwrite(read_messages=True)


    eyedee = random.randrange(1,99999) #assigns id number
    name = "ticket-" + str(eyedee)

    await client.create_channel(server, name, (server.default_role, everyone), (ctx.message.author, staff))
    ticket = discord.utils.get(client.get_all_channels(), name = "ticket-" + str(eyedee)) #makes variable to easily call on the channel

    admin = discord.utils.get(server.roles, name="Administrator")
    await client.edit_channel_permissions(ticket, admin, staff)

运行上面显示的代码时,出现此错误。

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: InvalidArgument: target parameter must be either Member or Role

0 个答案:

没有答案