Ejemplo n.º 1
0
    def on_server_join(self, server):
        server_count = util.get_server_count()
        if server_count % 25 == 0:
            # Announce every 100 servers (for now)
            yield from util.say(
                gconf.announcement_channel,
                ":confetti_ball: I'm on __**%d SERVERS**__ now!!!1111" %
                server_count)

        util.logger.info("Joined server name: %s id: %s", server.name,
                         server.id)

        yield from util.set_up_roles(server)

        server_stats = self.server_stats(server)
        yield from util.duelogger.info(
            ("DueUtil has joined the server **" +
             util.ultra_escape_string(server.name) + "**!\n" +
             "``Member count →`` " + str(server_stats["member_count"]) + "\n" +
             "``Bot members →``" + str(server_stats["bot_count"]) + "\n" +
             ("**BOT SERVER**" if server_stats["bot_server"] else "")))

        # Message to help out new server admins.
        yield from self.send_message(
            server.default_channel, ":wave: __Thanks for adding me!__\n" +
            "If you would like to customize me to fit your " +
            "server take a quick look at the admins " +
            "guide at <https://dueutil.tech/howto/#adming>.\n" +
            "It shows how to change the command prefix here, and set which " +
            "channels I or my commands can be used in (along with a bunch of other stuff)."
        )
        # Update stats
        yield from servercounts.update_server_count(self)
Ejemplo n.º 2
0
    async def on_guild_join(self, guild):
        server_count = util.get_server_count()
        if server_count % 250 == 0:
            await util.say(
                gconf.announcement_channel,
                ":confetti_ball: I'm on __**%d SERVERS**__ now!1!111!\n@everyone"
                % server_count)

        util.logger.info("Joined guild name: %s id: %s", guild.name, guild.id)
        try:
            await util.set_up_roles(guild)
        except discord.Forbidden:
            util.logger.warning("Unable to setup role for new server")
        server_stats = self.server_stats(guild)
        await util.duelogger.info(
            ("BattleBanana has joined the guild **" +
             util.ultra_escape_string(guild.name) + "**!\n" +
             "``Member count →`` " + str(guild.member_count) + "\n" +
             "``Bot members →``" + str(server_stats["bot_count"]) + "\n" +
             ("**BOT SERVER**" if server_stats["bot_server"] else "")))

        # Message to help out new guild admins.
        try:
            audit = await guild.audit_logs(
                action=discord.AuditLogAction.bot_add).find(self.who_added)
            user = audit.user

            await user.create_dm()
            await user.send(
                ":wave: __Thanks for adding me!__\n" +
                "If you would like to customize me to fit your " +
                "guild take a quick look at the admins " +
                "guide at <https://battlebanana.xyz/howto/#adming>.\n" +
                "It shows how to change the command prefix here, and set which "
                +
                "channels I or my commands can be used in (along with a bunch of other stuff)."
            )
        except discord.Forbidden:
            for channel in guild.channels:
                if isinstance(channel, discord.TextChannel):
                    try:
                        await channel.send(
                            ":wave: __Thanks for adding me!__\n" +
                            "If you would like to customize me to fit your " +
                            "guild take a quick look at the admins " +
                            "guide at <https://battlebanana.xyz/howto/#adming>.\n"
                            +
                            "It shows how to change the command prefix here, and set which "
                            +
                            "channels I or my commands can be used in (along with a bunch of other stuff)."
                        )
                        break
                    except discord.Forbidden:
                        continue
        except Exception as e:
            util.logger.warning("Unable to send on join message: %s", e)

        # Update stats
        await servercounts.update_server_count(self)
Ejemplo n.º 3
0
 def on_server_remove(self, server):
     for collection in dbconn.db.collection_names():
         if collection != "Player":
             dbconn.db[collection].delete_many(
                 {'_id': {
                     '$regex': '%s.*' % server.id
                 }})
             dbconn.db[collection].delete_many({'_id': server.id})
     yield from util.duelogger.info(
         "DueUtil been removed from the server **%s**" %
         util.ultra_escape_string(server.name))
     # Update stats
     yield from servercounts.update_server_count(self)
Ejemplo n.º 4
0
 async def on_guild_remove(self, guild):
     for collection in dbconn.db.list_collection_names():
         if collection not in ("Player", "Topdogs"):
             dbconn.db[collection].delete_many(
                 {'_id': {
                     '$regex': '%s.*' % guild.id
                 }})
             dbconn.db[collection].delete_many({'_id': guild.id})
             dbconn.db[collection].delete_many({'_id': str(guild.id)})
     await util.duelogger.info(
         "BattleBanana has been removed from the guild **%s** (%s members)"
         % (util.ultra_escape_string(guild.name), guild.member_count))
     # Update stats
     await servercounts.update_server_count(self)
Ejemplo n.º 5
0
    def on_server_join(self, server):
        server_count = util.get_server_count()
        if server_count % 10000 == 0:
            # Announce every 100 servers (for now)
            yield from util.say(
                gconf.announcement_channel,
                ":confetti_ball: I'm on __**%d SERVERS**__ now!!!1111" %
                server_count)

        yield from util.set_up_roles(server)

        server_stats = self.server_stats(server)
        if random.randint(1, 3) == 2:
            util.logger.info("Joined server name: %s id: %s", server.name,
                             server.id)
            yield from util.duelogger.info(
                ("DueUtil has joined the server **" +
                 util.ultra_escape_string(server.name) + "**!\n" +
                 "``Member count →`` " + str(server_stats["member_count"]) +
                 "\n" + "``Bot members →``" + str(server_stats["bot_count"]) +
                 "\n" +
                 ("**BOT SERVER**" if server_stats["bot_server"] else "")))

        # Message to help out new server admins.
        yield from self.send_message(
            server.owner, ":wave: __Thanks for adding me!__\n" +
            "If you would like to customize me to fit your " +
            "server take a quick look at the admin " +
            "guide at <https://dueutil.weebly.com/theelgirlsdueutil.html>.\n" +
            "It shows how to change the command prefix here, and set which " +
            "channels I or my commands can be used in (along with a bunch of other stuff).\n"
            +
            "If you still need help, you can use ``!requestsupport cnf``, and a support person will join your server as soon as they can for in-person help!"
        )
        dbltoken = ""
        url = "https://top.gg/api/bots/" + "496480755728384002" + "/stats"
        headers = {"Authorization": dbltoken}
        payload = {"server_count": util.get_server_count()}
        requests.post(url, data=json.dumps(payload), headers=headers)
Ejemplo n.º 6
0
 def name_command_clean(self):
     return util.ultra_escape_string(self.name_command)