Ejemplo n.º 1
0
 async def message(self, message):
     # Check the message and see if we should allow it
     ctx = await self.bot.get_context(message)
     if not ctx.guild:
         # Don't restrict in pm
         return
     if not ctx.command:
         # No command - no need to check
         return
     # Get the list of blocked commands
     dis_com = self.settings.getServerStat(ctx.guild, "DisabledCommands")
     if ctx.command.name in dis_com:
         # Check if we're going to override
         admin_allow = self.settings.getServerStat(ctx.guild,
                                                   "AdminDisabledAccess")
         badmin_allow = self.settings.getServerStat(ctx.guild,
                                                    "BAdminDisabledAccess")
         # Check if we're admin and bot admin
         is_admin = Utils.is_admin(ctx)
         is_badmin = Utils.is_bot_admin_only(ctx)
         # Check if we override
         if (is_admin and admin_allow) or (is_badmin and badmin_allow):
             return
         # React if needed
         to_react = self.settings.getServerStat(ctx.guild,
                                                "DisabledReactions")
         if to_react:
             await message.add_reaction("🚫")
         # We have a disabled command - ignore it
         return {'Ignore': True, 'Delete': False}
Ejemplo n.º 2
0
 async def _can_run(self, ctx, reply=True):
     # Check if we're admin - and if not, check if bot admins can run this
     # and if we're bot admin
     if Utils.is_admin(ctx): return True
     if self.settings.getServerStat(ctx.guild,"BotAdminAsAdmin",False) and Utils.is_bot_admin_only(ctx): return True
     msg = "┐( ̄ヘ ̄;)┌\nKamu tidak memiliki hak untuk menggunakan command ini."
     em = discord.Embed(color = 0XFF8C00, description = msg)
     em.set_footer(text = "{}".format(ctx.author), icon_url = "{}".format(ctx.author.avatar_url))
     if reply: await ctx.send(embed = em)
     return False
Ejemplo n.º 3
0
 async def _can_run(self, ctx, reply=True):
     # Check if we're admin - and if not, check if bot admins can run this
     # and if we're bot admin
     if Utils.is_admin(ctx): return True
     if self.settings.getServerStat(ctx.guild, "BotAdminAsAdmin",
                                    False) and Utils.is_bot_admin_only(ctx):
         return True
     if reply:
         await ctx.send(
             "You do not have sufficient privileges to access this command."
         )
     return False
Ejemplo n.º 4
0
    async def feed(self, ctx, food: int = None):
        """Memberi makan bot dengan XP yang kalian miliki!"""
        # feed the bot, and maybe you'll get something in return!
        msg = '`{}feed [Jumlah XP]`'.format(ctx.prefix)
        em = discord.Embed(
            color=0XFF8C00,
            description="> Memberi makan bot dengan XP yang kalian miliki!"
            "> **Panduan**"
            "> {}".format(msg))
        if food == None:
            return await channel.send(embed=em)

        if not type(food) == int:
            return await channel.send(embed=em)

        isAdmin = Utils.is_admin(ctx)
        isBotAdmin = Utils.is_bot_admin_only(ctx)
        botAdminAsAdmin = self.settings.getServerStat(ctx.guild,
                                                      "BotAdminAsAdmin")
        adminUnlim = self.settings.getServerStat(ctx.guild, "AdminUnlimited")
        reserveXP = self.settings.getUserStat(ctx.author, ctx.guild,
                                              "XPReserve")
        minRole = self.settings.getServerStat(ctx.guild, "MinimumXPRole")
        requiredXP = self.settings.getServerStat(ctx.guild, "RequiredXPRole")
        isKill = self.settings.getServerStat(ctx.guild, "Killed")
        hunger = int(self.settings.getServerStat(ctx.guild, "Hunger"))
        xpblock = self.settings.getServerStat(ctx.guild, "XpBlockArray")

        approve = True
        decrement = True

        # Check Food

        if food > int(reserveXP):
            approve = False
            msg = '┐( ̄ヘ ̄;)┌\nKamu tidak dapat memberi ku makan dengan xp *{:,}*\nKamu hanya memiliki *{:,}* xp tersimpan!'.format(
                food, reserveXP)

        if food < 0:
            msg = '(҂⌣̀_⌣́) kamu tidak bisa memberiku makan dengan xp kurang dari 0.\nKamu pikir itu lucu?!'
            approve = False
            # Avoid admins gaining xp
            decrement = False

        if food == 0:
            msg = '┐( ̄ヘ ̄;)┌\nKamu tidak dapat memberi ku makan dengan xp *0*'
            approve = False

        # RequiredXPRole
        if not self._can_xp(ctx.author, ctx.guild):
            approve = False
            msg = '┐( ̄ヘ ̄;)┌\nKamu tidak memiliki permission untuk memberiku makan.'

        # Check bot admin
        if isBotAdmin and botAdminAsAdmin:
            # Approve as admin
            approve = True
            if adminUnlim:
                # No limit
                decrement = False
            else:
                if food < 0:
                    # Don't decrement if negative
                    decrement = False
                if food > int(reserveXP):
                    # Don't approve if we don't have enough
                    msg = '┐( ̄ヘ ̄;)┌\nKamu tidak dapat memberi ku makan dengan xp *{:,}*\nKamu hanya memiliki *{:,}* xp tersimpan!'.format(
                        food, reserveXP)
                    approve = False

        # Check admin last - so it overrides anything else
        if isAdmin:
            # No limit - approve
            approve = True
            if adminUnlim:
                # No limit
                decrement = False
            else:
                if food < 0:
                    # Don't decrement if negative
                    decrement = False
                if food > int(reserveXP):
                    # Don't approve if we don't have enough
                    msg = '┐( ̄ヘ ̄;)┌\nKamu tidak dapat memberi ku makan dengan *{:,} xp*\nKamu hanya memiliki *{:,}* xp tersimpan!'.format(
                        food, reserveXP)
                    approve = False

        # Check if we're blocked
        if ctx.author.id in xpblock:
            msg = "┐( ̄ヘ ̄;)┌\nKamu tidak dapat memberi makan bot!"
            approve = False
        else:
            if any(x for x in ctx.author.roles if x.id in xpblock):
                msg = "┐( ̄ヘ ̄;)┌\nRole kamu tidak dapat memberi makan bot!"
                approve = False

        if approve:
            # Feed was approved - let's take the XPReserve right away
            # Apply food - then check health
            hunger -= food

            self.settings.setServerStat(ctx.guild, "Hunger", hunger)
            takeReserve = -1 * food
            if decrement:
                self.settings.incrementStat(ctx.author, ctx.guild, "XPReserve",
                                            takeReserve)

            if isKill:
                # Bot's dead...
                msg = '*{}* Secara perlahan memberikan *{:,} xp* kepada *{}* yang telah mati...\nApakah mungkin akan bangkit suatu saat nanti?'.format(
                    DisplayName.name(ctx.author), food,
                    DisplayName.serverNick(self.bot.user, ctx.guild))
                em = discord.Embed(color=0XFF8C00,
                                   description="{}".format(msg))
                return await ctx.send(embed=em)

            # Bet more, less chance of winning, but more winnings!
            chanceToWin = 50
            payout = int(food * 2)

            # 1/chanceToWin that user will win - and payout is double the food
            randnum = random.randint(1, chanceToWin)
            if randnum == 1:
                # YOU WON!!
                self.settings.incrementStat(ctx.author, ctx.guild, "XP",
                                            int(payout))
                msg = '*{}* Secara perlahan memberikan *{:,} xp* kepada *{}* yang telah mati...\nApakah mungkin akan bangkit suatu saat nanti?*'.format(
                    DisplayName.name(ctx.author), food, int(payout))

                # Got XP - let's see if we need to promote
                await CheckRoles.checkroles(ctx.author, ctx.channel,
                                            self.settings, self.bot)
            else:
                msg = '*{}* Memberi ku makan dengan *{:,} xp!*\nTerima kasih banyak!!'.format(
                    ctx.author, food)

            if hunger <= -150:
                # Kill the bot here
                self.settings.setServerStat(ctx.guild, "Killed", True)
                self.settings.setServerStat(ctx.guild, "KilledBy",
                                            ctx.author.id)
                msg = '{}\n\nAku dibunuh...\n\n*{}* pelakunya...'.format(
                    msg, DisplayName.name(ctx.author.id))
            elif hunger <= -100:
                msg = '{}\n\nApakah kamu mencoba membunuh ku?\nBerhentilah jika kamu memiliki hati!'.format(
                    msg)
            elif hunger <= -75:
                msg = '{}\n\n(; ̄д ̄)\nAku sudah terlalu gemuk sekarangdan kesehatan ku menurun.\n Apa kamu memikirkan kesehatan ku??'.format(
                    msg)
            elif hunger <= -50:
                msg = '{}\n\n(; ̄д ̄) Aku obesitas.\nMakanan adalah musuh ku sekarang.'.format(
                    msg)
            elif hunger <= -25:
                msg = '{}\n\n(; ̄д ̄)\nAku gemuk.\noke waktunya diet?'.format(
                    msg)
            elif hunger <= -10:
                msg = '{}\n\n(; ̄д ̄)\nAku gemuk.\nAku akan bertambah semakin gemuk jika kamu terus memberiku makan.'.format(
                    msg)
            elif hunger <= -1:
                msg = '{}\n\n(;*´Д`)ノ\nAku sudah kenyang.\nAku harus berhenti makan untuk sejenak...'.format(
                    msg)
            elif hunger == 0:
                msg = '{}\n\n(;*´Д`)ノ\nJika kamu terus memberiku makan, aku akan menjadi gemuk...'.format(
                    msg)
        em = discord.Embed(color=0XFF8C00, description="{}".format(msg))
        em.set_footer(text="{}#{}".format(ctx.author.name,
                                          ctx.author.discriminator),
                      icon_url="{}".format(ctx.author.avatar_url))
        await ctx.send(embed=em)
Ejemplo n.º 5
0
    async def feed(self, ctx, food: int = None):
        """Feed the bot some xp!"""
        # feed the bot, and maybe you'll get something in return!
        msg = 'Usage: `{}feed [xp reserve feeding]`'.format(ctx.prefix)
        if food == None:
            return await channel.send(msg)

        if not type(food) == int:
            return await channel.send(msg)

        isAdmin = Utils.is_admin(ctx)
        isBotAdmin = Utils.is_bot_admin_only(ctx)
        botAdminAsAdmin = self.settings.getServerStat(ctx.guild,
                                                      "BotAdminAsAdmin")
        adminUnlim = self.settings.getServerStat(ctx.guild, "AdminUnlimited")
        reserveXP = self.settings.getUserStat(ctx.author, ctx.guild,
                                              "XPReserve")
        minRole = self.settings.getServerStat(ctx.guild, "MinimumXPRole")
        requiredXP = self.settings.getServerStat(ctx.guild, "RequiredXPRole")
        isKill = self.settings.getServerStat(ctx.guild, "Killed")
        hunger = int(self.settings.getServerStat(ctx.guild, "Hunger"))
        xpblock = self.settings.getServerStat(ctx.guild, "XpBlockArray")

        approve = True
        decrement = True

        # Check Food

        if food > int(reserveXP):
            approve = False
            msg = 'You can\'t feed me *{:,}*, you only have *{:,}* xp reserve!'.format(
                food, reserveXP)

        if food < 0:
            msg = 'You can\'t feed me less than nothing! You think this is funny?!'
            approve = False
            # Avoid admins gaining xp
            decrement = False

        if food == 0:
            msg = 'You can\'t feed me *nothing!*'
            approve = False

        # RequiredXPRole
        if not self._can_xp(ctx.author, ctx.guild):
            approve = False
            msg = 'You don\'t have the permissions to feed me.'

        # Check bot admin
        if isBotAdmin and botAdminAsAdmin:
            # Approve as admin
            approve = True
            if adminUnlim:
                # No limit
                decrement = False
            else:
                if food < 0:
                    # Don't decrement if negative
                    decrement = False
                if food > int(reserveXP):
                    # Don't approve if we don't have enough
                    msg = 'You can\'t feed me *{:,}*, you only have *{:,}* xp reserve!'.format(
                        food, reserveXP)
                    approve = False

        # Check admin last - so it overrides anything else
        if isAdmin:
            # No limit - approve
            approve = True
            if adminUnlim:
                # No limit
                decrement = False
            else:
                if food < 0:
                    # Don't decrement if negative
                    decrement = False
                if food > int(reserveXP):
                    # Don't approve if we don't have enough
                    msg = 'You can\'t feed me *{:,}*, you only have *{:,}* xp reserve!'.format(
                        food, reserveXP)
                    approve = False

        # Check if we're blocked
        if ctx.author.id in xpblock:
            msg = "You can't feed the bot!"
            approve = False
        else:
            if any(x for x in ctx.author.roles if x.id in xpblock):
                msg = "Your role cannot feed the bot!"
                approve = False

        if approve:
            # Feed was approved - let's take the XPReserve right away
            # Apply food - then check health
            hunger -= food

            self.settings.setServerStat(ctx.guild, "Hunger", hunger)
            takeReserve = -1 * food
            if decrement:
                self.settings.incrementStat(ctx.author, ctx.guild, "XPReserve",
                                            takeReserve)

            if isKill:
                # Bot's dead...
                msg = '*{}* carelessly shoves *{:,} xp* into the carcass of *{}*... maybe resurrect them first next time?'.format(
                    DisplayName.name(ctx.author), food,
                    DisplayName.serverNick(self.bot.user, ctx.guild))
                return await ctx.send(msg)

            # Bet more, less chance of winning, but more winnings!
            chanceToWin = 50
            payout = int(food * 2)

            # 1/chanceToWin that user will win - and payout is double the food
            randnum = random.randint(1, chanceToWin)
            if randnum == 1:
                # YOU WON!!
                self.settings.incrementStat(ctx.author, ctx.guild, "XP",
                                            int(payout))
                msg = '*{}\'s* offering of *{:,}* has made me feel *exceptionally* generous.  Please accept this *magical* package with *{:,} xp!*'.format(
                    DisplayName.name(ctx.author), food, int(payout))

                # Got XP - let's see if we need to promote
                await CheckRoles.checkroles(ctx.author, ctx.channel,
                                            self.settings, self.bot)
            else:
                msg = '*{}* fed me *{:,} xp!* Thank you, kind soul! Perhaps I\'ll spare you...'.format(
                    DisplayName.name(ctx.author), food)

            if hunger <= -150:
                # Kill the bot here
                self.settings.setServerStat(ctx.guild, "Killed", True)
                self.settings.setServerStat(ctx.guild, "KilledBy",
                                            ctx.author.id)
                msg = '{}\n\nI am kill...\n\n*{}* did it...'.format(
                    msg, DisplayName.name(ctx.author))
            elif hunger <= -100:
                msg = '{}\n\nYou *are* going to kill me...  Stop *now* if you have a heart!'.format(
                    msg)
            elif hunger <= -75:
                msg = '{}\n\nI\'m looking fat to an extremely unhealthy degree... maybe you should think about *my* health?'.format(
                    msg)
            elif hunger <= -50:
                msg = '{}\n\nI\'m obese :( ... Eating is my enemy right now.'.format(
                    msg)
            elif hunger <= -25:
                msg = '{}\n\nI\'m kinda fat... Diet time?'.format(msg)
            elif hunger <= -10:
                msg = '{}\n\nI\'m getting pudgy... I may get fat if you keep going.'.format(
                    msg)
            elif hunger <= -1:
                msg = '{}\n\nI\'m getting stuffed... maybe I should take a break from eating...'.format(
                    msg)
            elif hunger == 0:
                msg = '{}\n\nIf you keep feeding me, I *may* get fat...'.format(
                    msg)

        await ctx.send(msg)