Skip to content

Instantly share code, notes, and snippets.

@owenselles
Created April 20, 2017 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save owenselles/50531d14652a1a5355a119bc5fe3ca2d to your computer and use it in GitHub Desktop.
Save owenselles/50531d14652a1a5355a119bc5fe3ca2d to your computer and use it in GitHub Desktop.
from discord.ext import commands
from .utils import checks
class Tomanybots:
def __init__(self, bot):
self.bot = bot
@commands.command()
@checks.is_owner()
async def tomanybots(self):
"""Checks all servers if there are servers with more than 25 Bots i will auto leave."""
await self.bot.say("I left {} servers.".format(await self.check_servers()))
async def on_server_join(self, server):
await self.check_servers()
async def check_servers(self):
counter = 0
for server in self.bot.servers:
if len([m for m in server.members if m.bot]) > 25:
try:
await self.bot.send_message(server.default_channel, "Sorry, but this bot is not made for Bot-Servers.\n It's ridiculous and an unnecessary load on the servers!\n **Bye**")
except:
pass
await self.bot.leave_server(server)
counter += 1
return counter
def setup(bot):
bot.add_cog(Tomanybots(bot))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment