2 回答

TA贡献1786条经验 获得超11个赞
Member.roles是一个Role对象列表,而不是字符串。您可以使用discord.utils.getid(作为 int)来搜索该列表。
from discord.utils import get
@client.command(aliases=['Ban'])
async def ban(ctx, member: discord.Member, days: int = 1):
if get(ctx.author.roles, id=548841535223889923):
await member.ban(delete_message_days=days)
await ctx.send("Banned {}".format(ctx.author))
else:
await ctx.send("{}, you don't have permission to use this command.".format(ctx.author))
await ctx.send(ctx.author.roles)
也不再有Client.ban协程,附加参数Member.ban必须作为关键字参数传递。

TA贡献1887条经验 获得超5个赞
async def ban(ctx, member: discord.Member=None, *, reason=None):
if reason:
await member.send(f'You got banned from {ctx.guild.name} by {ctx.author}, reason: ```{reason}```')
await member.ban()
await ctx.send(f'{member.mention} got banned by {ctx.author.mention} with reason: ```{reason}```')
if reason is None:
await ctx.send("please specify a reason")
添加回答
举报