Skip to content Skip to sidebar Skip to footer

How To Make A Discord Bot Leave A Server From A Command In Another Server?

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)

Solution 1:

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)

where id is the ID of the server to leave.


Solution 2:

To make the bot leave from the server that the command was used from, use:

await client.leave_server(message.server)

For rewrite:

await message.server.leave()

Post a Comment for "How To Make A Discord Bot Leave A Server From A Command In Another Server?"