所以我有一个用Python和Discord.py编写的不和谐机器人,现在我的问题是,有没有可能做这样的事情:
Server_ID = 'TheServerID'
if ServerID = Server_ID:
leave发布于 2020-06-25 22:06:51
为了获得服务器id,你可以使用int类型的ctx.guild.id,然后你可以将它与任何你想要的int进行比较。
如果你想让机器人离开服务器,你必须使用guild.leave(),这是一个协程,所以一定要把await。
你的代码应该是这样的:
server_id = <the id you want to compare>
if ctx.guild.id == server_id:
await ctx.guild.leave()确保将此代码放入异步函数中,该函数可能是一个事件或命令。
如果您在处理discord.py时遇到麻烦,请重新访问the documentation。
https://stackoverflow.com/questions/62576760
复制相似问题