Example #1
0
 async def add(self, ctx, user: discord.Member=None, amount : int=None):
     GID = str(ctx.guild.id)
     if ctx.author is ctx.guild.owner or ctx.author.id in config.admins:
         if user and amount:
             if self.account_check(GID, user.id):
                 if self.account_check(GID, ctx.author.id):
                     await ctx.send(embed=lib.Editable("Some kind of wizardry", f"Added {amount} credits to {user.mention}'s balance!", "Devo Bank"), delete_after=config.deltimer)
                     self.add_money(GID, user.id, amount)
                 else:
                     await ctx.send(embed=lib.Editable_E("You dont have a bank account", f"Run {ctx.prefix}bank register to open an account.", "Devo Bank"), delete_after=config.deltimer)
             else:
                 await ctx.send(embed=lib.Editable_E(f"{user.name} has no bank account.", "", "Devo Bank"), delete_after=config.deltimer)
         else:
             await ctx.send(embed=lib.Editable_E("Invalid Arguments", f"Usage Example:\n\n{ctx.prefix}bank add @someone (amount)", "Usage"), delete_after=config.deltimer)
     else:
         await ctx.send(embed=lib.NoPerm(), delete_after=config.deltimer)
Example #2
0
 async def balance(self, ctx, user: discord.Member=None):
     GID = str(ctx.guild.id)
     if user is None:
         UID = str(ctx.author.id)
         if self.account_check(GID, UID):
             await ctx.send(embed=lib.Editable(f"{ctx.author.name}, Your balance is {self.get_balance(GID, UID)}", "", "Devo Bank"), delete_after=config.deltimer)
         else:
             await ctx.send(embed=lib.Editable_E("You dont have a bank account", f"Run {ctx.prefix}bank register to open an account.", "Devo Bank"), delete_after=config.deltimer)
     else:
         UID = str(user.id)
         if self.bank_exists(GID):
             if self.account_check(GID, UID):
                 await ctx.send(embed=lib.Editable(f"{user.name}'s balance is {self.get_balance(GID, UID)}", "", "Devo Bank"), delete_after=config.deltimer)
             else:
                 await ctx.send(embed=lib.Editable_E(f"{user.name} has no bank account.", "", "Devo Bank"), delete_after=config.deltimer)
         else:
             await ctx.send(embed=lib.Editable_E("There is no bank", f"Run {ctx.prefix}bank register to start.", "Devo Bank"), delete_after=config.deltimer)
Example #3
0
 async def benefits(self, ctx):
     GID = str(ctx.guild.id)
     UID = str(ctx.author.id)
     if self.account_check(GID, UID):
         if UID in self.benefits_register:
             seconds = abs(self.benefits_register[UID] - int(time.perf_counter()))
             if seconds >= self.settings["BENEFITS_TIME"]:
                 await ctx.send(embed=lib.Editable(f"{ctx.author.name} collected their benefits", "{} has been added to your account!".format(self.settings["BENEFITS_CREDITS"]), "Devo Bank"), delete_after=config.deltimer)
                 self.add_money(GID, UID, self.settings["BENEFITS_CREDITS"])
                 self.benefits_register[UID] = int(time.perf_counter())
             else:
                 await ctx.send(embed=lib.Editable_E("Uh oh", "You need to wait another {} seconds until you can get more benefits.".format(self.display_time(self.settings["BENEFITS_TIME"] - seconds)), "Devo Bank"), delete_after=config.deltimer)
         else:
             self.benefits_register[UID] = int(time.perf_counter())
             await ctx.send(embed=lib.Editable(f"{ctx.author.name} collected their benefits", "{} has been added to your account!".format(self.settings["BENEFITS_CREDITS"]), "Devo Bank"), delete_after=config.deltimer)
             self.add_money(GID, UID, self.settings["BENEFITS_CREDITS"])
     else:
         await ctx.send(embed=lib.Editable_E("Uh oh", f"{ctx.author.mention}, You dont have a bank account at the Devo Bank. Type !bank register to open one.", "Devo Bank"), delete_after=config.deltimer)
Example #4
0
 async def gifr(self, ctx, *keywords):
     url = (
         f"http://api.giphy.com/v1/gifs/random?&api_key=dc6zaTOxFJmzC&tag={keywords}"
     )
     async with aiohttp.ClientSession() as cs:
         async with cs.get(url) as r:
             result = await r.json()
             if r.status == 200:
                 if result["data"]:
                     g = result["data"]["url"]
                     await ctx.send(g)
                 else:
                     await ctx.send(embed=lib.Editable_E(
                         "No search results found", "", "Error"),
                                    delete_after=config.deltimer)
             else:
                 await ctx.send(embed=lib.Editable_E(
                     "Error Contacting API", "", "Error"),
                                delete_after=config.deltimer)
Example #5
0
 async def transfer(self, ctx, user: discord.Member=None, amount : int=None):
     GID = str(ctx.guild.id)
     if self.account_check(GID, ctx.author.id):
         if user and amount and not ctx.author == user:
             if amount > 1:
                 if self.account_check(GID, user.id):
                     if self.enough_money(GID, ctx.author.id, amount):
                         await ctx.send(embed=lib.Editable(f"**{user.name}**'s in Luck!", f"**{ctx.author.name}** transferred {amount} credits to **{user.name}**'s account.", "Devo Bank"), delete_after=config.deltimer)
                         self.withdraw_money(GID, ctx.author.id, amount)
                         self.add_money(GID, user.id, amount)
                     else:
                         await ctx.send(embed=lib.Editable_E("You're too poor to do that", "", "Devo Bank"), delete_after=config.deltimer)
                 else:
                     await ctx.send(embed=lib.Editable_E(f"{user.name} has no bank account", "", "Devo Bank"), delete_after=config.deltimer)
             else:
                 await ctx.send(embed=lib.Editable_E("Transfer at least 1 credit", "", "Devo Bank"), delete_after=config.deltimer)
         else:
             await ctx.send(embed=lib.Editable_E("Invalid Arguments", f"Usage Example:\n\n{ctx.prefix}bank transfer @someone (amount)", "Usage"), delete_after=config.deltimer)
     else:
         await ctx.send(embed=lib.Editable_E("You dont have a bank account", f"Run {ctx.prefix}bank register to open an account.", "Devo Bank"), delete_after=config.deltimer)
Example #6
0
 async def benefitscredits(self, ctx, credits : int=None):
     if ctx.author is ctx.guild.owner:
         if credits:
             self.settings["BENEFITS_CREDITS"] = credits
             await ctx.send("Every benefits claim will now give " + str(credits) + " credits.", delete_after=config.deltimer)
             with open("./data/economy/settings.json", "w") as s:
                 json.dump(self.settings, s)
         else:
             await ctx.send(embed=lib.Editable_E("You Missed Something", "You need to enter an amount", "Economy"), delete_after=config.deltimer)
     else:
         await ctx.send(embed=lib.NoPerm(), delete_after=config.deltimer)
Example #7
0
 async def benefitstime(self, ctx, seconds : int=None):
     if ctx.author is ctx.guild.owner:
         if seconds:
             self.settings["BENEFITS_TIME"] = seconds
             await ctx.send("Value modified. At least " + str(seconds) + " seconds must pass between each benefits claim.", delete_after=config.deltimer)
             with open("./data/economy/settings.json", "w") as s:
                 json.dump(self.settings, s)
         else:
             await ctx.send(embed=lib.Editable_E("You Missed Something", "You need to enter a benefits delay", "Economy"), delete_after=config.deltimer)
     else:
         await ctx.send(embed=lib.NoPerm(), delete_after=config.deltimer)
Example #8
0
 async def slottime(self, ctx, seconds : int=None):
     if ctx.author is ctx.guild.owner:
         if seconds:
             self.settings["SLOT_TIME"] = seconds
             await ctx.send("Cooldown is now " + str(seconds) + " seconds.", delete_after=config.deltimer)
             with open("./data/economy/settings.json", "w") as s:
                 json.dump(self.settings, s)
         else:
             await ctx.send(embed=lib.Editable_E("You Missed Something", "You need to enter a slot time.", "Economy"), delete_after=config.deltimer)
     else:
         await ctx.send(embed=lib.NoPerm(), delete_after=config.deltimer)
Example #9
0
 async def slotmax(self, ctx, bid : int=None):
     if ctx.author is ctx.guild.owner:
         if bid:
             self.settings["SLOT_MAX"] = bid
             await ctx.send("Maximum bid is now " + str(bid) + " credits.", delete_after=config.deltimer)
             with open("./data/economy/settings.json", "w") as s:
                 json.dump(self.settings, s)
         else:
             await ctx.send(embed=lib.Editable_E("You Missed Something", "You need to enter a maximum amount", "Economy"), delete_after=config.deltimer)
     else:
         await ctx.send(embed=lib.NoPerm(), delete_after=config.deltimer)
Example #10
0
    async def blackjack(self, ctx, bet:int=None):
        global is_active, creator, gameover, is_active, STOOD_WHEN_LESS_HOUSE_WINS, bet_amount, STAND, HOUSE_STAND, startmsg, bet_amount, UID
        GID = str(ctx.guild.id)
        UID = str(ctx.author.id)
        creator = ctx.author
        gameover = False
        if bet:
            if self.account_check(GID, UID):
                if self.enough_money(GID, UID, bet):
                    bet_amount = bet
                    await ctx.message.delete()
                    channel = ctx.message.channel
                    blackjack_start = await ctx.send(embed=self.BJ_START())
                    is_active = True
                    await asyncio.sleep(5)
                    await self.cards(channel)
                    await asyncio.sleep(2)
                    await self.bot_cards(channel)
                    await blackjack_start.delete()
                    startmsg = await ctx.send(embed=self.BJ_E(0xd42c2c, "{}\n**Score:** {}".format(", ".join(players_cards), CARDS_TOTAL_WORTH), f"{bot_cards[0]}", "**Options**: hit, stand, double?"))
                    while is_active is True:
                        await self.win(ctx)
                        if gameover is False:
                            await self.player(ctx)
                            if is_active is True:
                                await self.win(ctx)
                                if gameover is False:
                                    await self.blackjack_math(ctx)
                                    if is_active is False:
                                        break
                                else:
                                    break
                        else:
                            break

                else:
                    await ctx.send(embed=lib.Editable_E("You're Skint!", f"{ctx.author.mention} You're too poor to play that bet!", "Blackjack"), delete_after=config.deltimer)
            else:
                await ctx.send(embed=lib.Editable_E("Uh oh", f"This guild doesnt have the bank setup! Type `{ctx.prefix}bank register` to start!", "Devo Bank"), delete_after=config.deltimer)
        else:
            await ctx.send(embed=lib.Editable_E("Oops", "Please enter an amount to bet.", "Blackjack"), delete_after=config.deltimer)
Example #11
0
 async def register(self, ctx):
     user = ctx.author
     UID = str(user.id)
     GID = str(ctx.guild.id)
     if self.bank_exists(GID):
         if self.create_account(GID, user):
             await ctx.send(embed=lib.Editable(f"Bank Account Created for {ctx.author}", f"Current balance: {self.get_balance(GID, UID)}", "Devo Bank"), delete_after=config.deltimer)
         else:
             await ctx.send(embed=lib.Editable_E("You can only have one bank account.", "", "Devo Bank"), delete_after=config.deltimer)
     else:
         self.bank_create(GID)
         await ctx.reinvoke()
Example #12
0
 async def slots(self, ctx, bid : int=None):
     GID = str(ctx.guild.id)
     UID = str(ctx.author.id)
     start_bid = bid
     if self.account_check(GID, UID):
         if bid:
             if self.enough_money(GID, UID, bid):
                 if bid >= self.settings["SLOT_MIN"] and bid <= self.settings["SLOT_MAX"]:
                     if UID in self.slot_register:
                         if abs(self.slot_register[UID] - int(time.perf_counter()))  >= self.settings["SLOT_TIME"]:
                             self.slot_register[UID] = int(time.perf_counter())
                             await self.slot_machine(ctx.message, bid)
                         else:
                             await ctx.send(embed=lib.Editable_E("Uh oh", "The slot machine is still cooling off! Wait {} seconds between each pull".format(self.settings["SLOT_TIME"]), "Slot Machine"), delete_after=config.deltimer)
                     else:
                         self.slot_register[UID] = int(time.perf_counter())
                         await self.slot_machine(ctx.message, bid)
                 else:
                     await ctx.send(embed=lib.Editable_E("Uh oh", "{} Bid must be between {} and {}.".format(ctx.author.mention, self.settings["SLOT_MIN"], self.settings["SLOT_MAX"]), "Slot Machine"), delete_after=config.deltimer)
             else:
                 await ctx.send(embed=lib.Editable_E("You're Skint!", f"{ctx.author.mention} You're too poor to play that bet on the slot machine!", "Slot Machine"), delete_after=config.deltimer)
         else:
             await ctx.send(embed=lib.Editable_E("Uhhh", "You need to type a bid amound", "Slot Machine"), delete_after=config.deltimer)
    async def on_command_error(self, ctx, error):
        ignored = (commands.CommandNotFound, commands.NoPrivateMessage,
                   commands.DisabledCommand, discord.NotFound,
                   commands.CheckFailure)
        error = getattr(error, "original", error)

        # Bot Error's
        if isinstance(error, ignored):
            return
        elif isinstance(error, commands.BadArgument):
            return await ctx.send(embed=lib.Editable_E(
                "Invalid Arguments", "Your command could not be processed.",
                "Error"),
                                  delete_after=config.deltimer)
        elif isinstance(error, commands.MissingPermissions):
            try:
                return await ctx.send(embed=lib.Editable_E(
                    "Im missing essential permissions", "", "Error"),
                                      delete_after=config.deltimer)
            except discord.Forbidden:
                return

        elif isinstance(error, commands.CommandOnCooldown):
            return await ctx.send(embed=lib.Editable_E(
                f"Calm down {ctx.author.name}, that command is cooling down.",
                "", "Error"),
                                  delete_after=config.deltimer)

        # Discord Error's
        elif isinstance(error, discord.Forbidden):
            try:
                return await ctx.send(embed=lib.Editable_E(
                    "I dont have permission to do that", "", "Error"),
                                      delete_after=config.deltimer)
            except discord.Forbidden:
                return
        elif isinstance(error, discord.HTTPException):
            return await ctx.send(embed=lib.Editable_E("Command Error:",
                                                       f"{error}", "Error"),
                                  delete_after=config.deltimer)

        # Asyncio Error's
        elif isinstance(error, asyncio.TimeoutError):
            return await ctx.send(embed=lib.Editable_E("Request Timed Out", "",
                                                       "Error"),
                                  delete_after=config.deltimer)

        errorfile = open("./utils/logs/Error.log", "a")
        errorfile.write("[{}]: {} \n".format(
            datetime.datetime.utcnow().strftime(
                "%d/%m/%Y at %H:%M:%S (System Time)"), error))
        errorfile.close()
        print("An error has been logged.")

        raise error
Example #14
0
 async def math(self, ctx, num1: int = 0, op=None, num2: int = 0):
     if num1 and op and num2:
         if op == "+":
             ans = num1 + num2
         elif op == "-":
             ans = num1 - num2
         elif op == "*":
             ans = num1 * num2
         elif op == "/":
             ans = num1 / num2
         await ctx.send(embed=lib.Editable(
             f"You requested {num1} {op} {num2}",
             f"{num1} {op} {num2} = {ans}", "Maths"),
                        delete_after=config.deltimer)
     else:
         await ctx.send(embed=lib.Editable_E(
             "Invalid Arguments",
             "Usage Examples:\n\n1 + 1\n1 - 1\n 1 * 1\n 1 / 1", "Error"),
                        delete_after=config.deltimer)