如何使不和谐的bot从另一个服务器中的命令离开服务器? [英] How to make a discord bot leave a server from a command in another server?

查看:101
本文介绍了如何使不和谐的bot从另一个服务器中的命令离开服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

im目前正在开发Discord .Py机器人;我希望能够在服务器所有者滥用机器人的情况下强迫我的机器人离开服务器;现在我所面临的是

im currently developing a Discord .Py bot; and im wanting to to be able to force my bot to leave a server if the server owner is abusing the bot; now the whole issue i have is;

1)我将如何从另一台服务器执行此操作?如说Server1(我的命令发布):这是完成所有admin / dev cmds的服务器...所以说有人要滥用Server2(随机服务器)中的机器人,我想输入Server1!离开服务器名它会说服务器中的一条消息创建者已要求我离开该服务器,然后离开...

1) How would i go about doing this from another server? as in say Server1(my command post): This is the server where ALL admin/dev cmds are done... so say someone is abusing the bot in Server2(random server) i would like to type in Server1 !leave 'servername' it would say a message in the server "I have been requested to leave this server by the creator" and then leave...

2)甚至可能吗? ?

2) is this even possible???

在此项目之前,感谢您提供任何帮助:)

Thanks in advance for any help towards this project :)

推荐答案

由于 client.leave_server()需要 Server 作为输入,因此您需要首先获取该服务器。假设您希望有一个命令根据给出的ID离开服务器,这应该可以解决问题:

As client.leave_server() takes a Server as input, you will need to get that server first. Assuming you want to have a command that leaves a server based on the id that is given, this should do the trick:

toleave = client.get_server("id")
await client.leave_server(toleave)

id 是要离开的服务器的ID。

where id is the ID of the server to leave.

这篇关于如何使不和谐的bot从另一个服务器中的命令离开服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆