Reputation:
I have a command that makes the bot leave a server, but, they can make the bot rejoin which i don't want and i also don't want to enable code grant as i want other servers to use my bot. and i have to keep on resting the script each time the bot joins a server i want the bot to leave just after it joins after all there isn't a way to ban it from the server. So here is my script.
@client.event
async def on_ready():
my_server = client.get_server('520354830472970270')
await client.leave_server(my_server)
print('left server')`
Upvotes: 1
Views: 1939
Reputation: 98
@client.event
async def on_server_join(server):
"""So we basically check if the server id equals the id you've sent, and you want it to leave exactly after it joined to that server."""
if server.id not != "520354830472970270": # We're checking if the ID is not unequal to 520354830472970270
await client.leave_server(server) # The server parameter of this event returns us a server object, so we don't have to get it separately.
Upvotes: 0
Reputation: 26
You can have the bot leave the server immediately after it joins by using the on_server_join
event.
@client.event
async def on_server_join(server):
if server.id == "id":
await client.leave_server(server)
Upvotes: 1