python - 代码停止执行 Ban discord bot, python
问题描述
我有一个代码:
@commands.has_permissions(ban_members=True)
@Client.command()
async def Ban (ctx, member:discord.User=None, reason="Nie podano"):
if member == None or member == ctx.message.author:
await ctx.channel.send("Nie możesz zbanować sam siebie")
return
message = f"Zostałeś zbanowany na serwerze {ctx.guild.name}\nPowód: {reason}"
await member.send(message)
await ctx.channel.purge(limit = 1)
await ctx.channel.send(f"{member} Został zbanowany!\nPowód: {reason}")
print('a')
await member.ban(reason = reason)
print('b')
一切都完成了,但是在控制台中显示字母“a”后,脚本停止运行
解决方案
如果您有任何错误,我看不出您的代码有任何问题,请提及它们,或者如果您有错误处理程序,请尝试通过评论将其删除,然后尝试获取错误。
await ctx.guild.ban(member, reason=reason)
我做了很多 discord.py,但从未遇到过代码停止的问题。最后(我认为这不是问题)您可能需要检查您拥有的 python 版本和 discord.py 需要的版本。
推荐阅读
- mariadb - openstack中nova的数据库同步期间出错
- javascript - 将带有循环的 Songtext 中的所有元音更改为“a”
- xml - Apache FOP 如何使用换行符限制字符长度/在哪里实现所需的功能
- postgresql - 使用 GORM + Postgres + Go Gin + Graphql 在创建前自动生成 UUID
- firefox - 使用 XSLT 列出 Firefox 中的所有命名空间
- google-analytics - 使用可变参数聚合路径上的综合浏览量
- javascript - Angular 9->10 迁移。类型错误:core_1.virtualFs.createSyncHost 不是函数
- java - 为什么 Struts 验证不能正常工作?
- android - Flutter:在flutter dart中按日期初始化和过滤listview
- python - 在 statsmodel 中出现未对齐的值错误