英文:
Discord.py Guild.bans() missing 1 required positional argument: 'self'
问题
Code:
@tree.command(name="unban", description="Unbans a member.", guild=discord.Object(id=guildid))
async def unban(ctx, member: str):
bannedusers = await discord.Guild.bans()
membername, memberdiscriminator = member.split("#")
for banentry in bannedusers:
user = banentry.user
if (user.name, user.discriminator) == (membername, memberdiscriminator):
await ctx.guild.unban(user)
Error:
Guild.bans() missing 1 required positional argument: 'self'
I tried also use discord.Guild.unban and discord.Member.unban, both give the same error.
英文:
Code:
@tree.command(name="unban",description="Unbans a member.",guild=discord.Object(id=guildid))
async def unban(ctx,member:str):
bannedusers = await discord.Guild.bans()
membername,memberdiscriminator = member.split("#")
for banentry in bannedusers:
user = banentry.user
if (user.name, user.discriminator) == (membername, memberdiscriminator):
await ctx.guild.unban(user)
Error:
Guild.bans() missing 1 required positional argument: 'self'
I tried also use discord.Guild.unban and discord.Member.unban, both give the same error
答案1
得分: 0
尝试 ctx.guild.bans()
。
API 参考链接: https://discordpy.readthedocs.io/en/stable/api.html?highlight=guild#discord.Guild.bans
英文:
You're calling discord.Guild
which is a class and thus not instantiated. Try ctx.guild.bans()
API Reference: https://discordpy.readthedocs.io/en/stable/api.html?highlight=guild#discord.Guild.bans
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论