Created
April 20, 2017 18:36
-
-
Save owenselles/50531d14652a1a5355a119bc5fe3ca2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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