所以我試圖在我的機器人中創建一個設置命令,用戶可以在其中選擇他想要的。問題是我無法讓它按照我的意愿工作。我有這個作為我的代碼# Function to write changes to filedef set_adminrole(guild: Guild, *, role: Role): with open("admins.json") as f: roles = json.load(f) roles[str(guild.id)] = role.id with open("admins.json", 'w') as f: json.dump(roles, f, indent=4)# Actual command-- Not important code --await ctx.send(f"Now, mention the role you want it to be the admin role") role: Message = await bot.wait_for("message", check=check) set_adminrole(ctx.message.guild, role.content) await ctx.send(f"Admin role changed to {Role(role.content).mention}... Let's keep going")當我提到一個角色并嘗試用它調用函數時,它給了我這個錯誤: TypeError: set_adminrole() takes 1 positional argument but 2 were given 提前致謝
1 回答

守著一只汪
TA貢獻1872條經驗 獲得超4個贊
role
是僅關鍵字參數,因為它*
在參數列表中跟在 之后。您需要將值作為關鍵字參數而不是位置參數傳遞。
set_adminrole(ctx.message.guild, role=role.content)
添加回答
舉報
0/150
提交
取消