Exemplo n.º 1
0
    async def sell(self, ctx, item_id):
        _item = Item(item_id)
        _user = User(ctx.message.author.id)

        if _user.is_Registered is False:
            await self.bot.say(self.errors.USER_NOT_IN_DB)
            return

        if _item.exists is False:
            await self.bot.say(self.errors.ITEM_NOT_EXIST)
            return

        if len(_user.get_user_item(item_id)) == 0:
            await self.bot.say(self.errors.ITEM_DONT_OWN)
            return

        if _item.kind == 3:
            await self.bot.say("❌ | Badges cannot be sold.")

        cost = _item.cost
        give_back = cost * 0.20

        _user.delete_user_item(item_id)
        _user.add_money(int(give_back))

        await self.bot.say(self.msg.SELL_STR.format(int(give_back)))
Exemplo n.º 2
0
    async def fish(self, ctx):
        author = ctx.message.author
        _user = User(author.id)

        if _user.is_Registered is False:
            await self.bot.say(self.errors.USER_NOT_IN_DB)
            return
        
        win = [True, False]

        if random.choice(win):
            pool = ['🦈', '🐡', '🐠', '🐟']
            draw = random.choice(pool)

            if draw == pool[0]:
                prize = random.randint(50, 75)
                fish = pool[0]
            elif draw == pool[1]:
                prize = random.randint(10, 30)
                fish = pool[1]
            elif draw == pool[2]:
                prize = random.randint(50, 100)
                fish = pool[2]
            elif draw == pool[3]:
                prize = random.randint(1, 60)
                fish = pool[3]
            
            _user.add_money(prize)

            await self.bot.say(f"🎣 | You caught a fish `{fish}` and sold it for `{prize}` coins!")
        else:
            await self.bot.say("😢 | You only caught some piece of shi- junks in the ocean.")
Exemplo n.º 3
0
    async def gamble(self, ctx, bet: int = 50):
        author = ctx.message.author

        _user = User(author.id)

        if _user.is_Registered is False:
            await self.bot.say(self.errors.USER_NOT_IN_DB)
            return

        if _user.money < bet:
            await self.bot.say(self.errors.INSUF_MONEY)
            return
        
        if bet < 50:
            await self.bot.say(self.errors.BET_INSUF.format("50"))
            return

        probabilities = [True, False]

        draw = random.choice(probabilities)

        ratio = [0.25, 0.5, 0.75]

        rate = random.choice(ratio)

        if draw:
            value = random.randint(1, int(bet * rate))

            await self.bot.say(self.msg.GAMBLE_WON.format(bet, value))
        else:
            value = -bet
            await self.bot.say(self.msg.GAMBLE_LOSE.format(bet))
        
        _user.add_money(value)
Exemplo n.º 4
0
    async def ticketbuy(self, ctx, first: int, second: int, bet: int = 50):
        global current_pool
        author_id = ctx.message.author.id
        server_id = ctx.message.server.id
        _user = User(author_id)
        _server = Server(server_id)

        if _user.is_Registered is False:
            await self.bot.say(self.errors.USER_NOT_IN_DB)
            return

        if _user.money < bet:
            await self.bot.say(self.errors.INSUF_MONEY)
            return

        if _server.is_Registered is False:
            await self.bot.say(self.errors.SRV_NOT_IN_DB)
            return

        if _server.cmd_channel is None:
            await self.bot.say("❌ | Please register a commands spam channel.")
            return

        if bet < 50:
            await self.bot.say("❌ | Minimum bet is 50 coins!")
            return

        if first > 30 or second > 30:
            await self.bot.say(
                "❌ | Numbers allowed are only in the range 1-30.")
            return

        user_draw = []
        user_draw.append(first)
        user_draw.append(second)

        try:
            _checker = server_bets[server_id]
        except:
            server_bets[server_id] = {}

        _user.add_money(-bet)

        if len(server_bets[server_id]) == 0:
            server_bets[server_id] = {author_id: user_draw}
            await self.bot.say(
                f"🎰 | You bought a ticket to the lottery with the numbers `{first}` and `{second}` respectively."
            )
            await self.startlottery(ctx, bet * 3)
        else:
            if author_id in server_bets[server_id]:
                await self.bot.say(self.errors.TICKET_DUPLICATE)
                return
            else:
                await self.bot.say(
                    f"🎰 | You bought a ticket to the lottery with the numbers `{first}` and `{second}` respectively."
                )
                server_bets[server_id][author_id] = user_draw
                current_pool[ctx.message.server.id] += bet
Exemplo n.º 5
0
    async def daily(self, ctx):
        _user = User(ctx.message.author.id)

        if _user.is_Registered is False:
            await self.bot.say(self.errors.USER_NOT_IN_DB)
            return

        _user.add_money(200)

        await self.bot.say(self.msg.DAILY_RECEIVED.format(200))
Exemplo n.º 6
0
    async def grantcoins(self, ctx, user: discord.Member, coins: int):
        _user = User(user.id)

        if _user.is_Registered is False:
            await self.bot.say(self.errors.USER_NOT_IN_DB)
            return

        _user.add_money(coins)

        await self.bot.say(f"You have given **{user.name}** `{coins}` coins.")
Exemplo n.º 7
0
    async def givecoins(self, ctx, user: discord.Member, value: int):
        _giver = User(ctx.message.author.id)
        _receiver = User(user.id)

        if _giver.is_Registered is False or _receiver.is_Registered is False:
            await self.bot.say(self.errors.SPEC_NOT_IN_DB)
            return

        if _giver.money < value:
            await self.bot.say(self.errors.INSUF_MONEY)
            return

        if value <= 0:
            await self.bot.say(self.errors.ZERO_GIVE)
            return

        if user == ctx.message.author:
            await self.bot.say(self.errors.COIN_GIVE_SELF)
            return

        rng = random.randint(1000, 9999)

        embed = discord.Embed(
            title="Please verify that this is right",
            description=f"Type **{rng}** to confirm. (Expires 20 seconds)",
            color=self.themes.MAIN_COL,
            timestamp=ctx.message.timestamp)
        embed.add_field(name="Giving Coins Too:", value=user.mention)
        embed.add_field(name="Amount to be Transfered:",
                        value=str(value),
                        inline=False)
        embed.add_field(name="Your Current Coins:",
                        value=str(_giver.money),
                        inline=False)
        embed.add_field(name="Your Coins After Transaction:",
                        value=str(_giver.money - value),
                        inline=False)

        await self.bot.say(embed=embed)

        msg = await self.bot.wait_for_message(author=ctx.message.author,
                                              content=str(rng),
                                              timeout=20.00)

        if msg is None:
            await self.bot.say("❌ | Confirmation timed out, please try again.")
            return

        _giver.add_money(-value)
        _receiver.add_money(value)

        await self.bot.say(self.msg.OPERATION_SUCCESSFUL)
Exemplo n.º 8
0
    async def opencrate(self, ctx, crate_id: str):
        author = ctx.message.author
        _user = User(author.id)

        if _user.is_Registered is False:
            await self.bot.say(self.errors.USER_NOT_IN_DB)
            return
        
        item = self.inventory.get_item(crate_id)
        
        if len(item) == 0:
            await self.bot.say(self.errors.ITEM_NOT_EXIST)
            return

        item_name = item[0][0]
        item_type = item[0][1]
        crate_key = item[0][4]

        if len(_user.get_user_item(item_name)) == 0:
            await self.bot.say(self.errors.ITEM_DONT_OWN)
            return
        
        if item_type is not 2:
            await self.bot.say(self.errors.NOT_CRATE)
            return
        
        if len(_user.get_user_item(crate_key)) == 0:
            await self.bot.say(self.errors.NO_KEY)
            return

        pool = []

        for heading in crates:
            if heading == crate_id:
                for given in crates[heading]:
                    pool = list(given['pool'])
                    string = given['str']
        
        draw = random.choice(pool)
        draw_str = str(draw) + string
        if draw is None:
            await self.bot.say(self.msg.CRATE_NONE)
            _user.delete_user_item(crate_key)
            _user.delete_user_item(item_name)
        else:
            await self.bot.say(self.msg.CRATE_WON.format(draw_str))
            _user.add_money(draw)
            _user.delete_user_item(crate_key)
            _user.delete_user_item(item_name)
Exemplo n.º 9
0
    async def loot(self, ctx):
        _user = User(ctx.message.author.id)

        if _user.is_Registered is False:
            await self.bot.say(self.errors.USER_NOT_IN_DB)
            return

        creds = random.randint(10, 99)

        probabilities = [True, False]

        choice = probabilities[random.randint(0, 1)]

        if choice:
            _user.add_money(creds)
            await self.bot.say(self.msg.LOOT_SUCCESSFUL.format(creds))
        else:
            await self.bot.say(self.msg.LOOT_FAIL)
Exemplo n.º 10
0
    async def slots(self, ctx, bet: int = 50):
        if bet < 50:
            await self.bot.say(self.errors.BET_INSUF.format("50"))
            return

        user = ctx.message.author

        _user = User(user.id)

        if _user.is_Registered is False:
            await self.bot.say(self.errors.USER_NOT_IN_DB)
            return

        if _user.money < bet:
            await self.bot.say(self.errors.INSUF_MONEY)
            return

        if bet <= 100 and bet > 0:
            bet_win_ratio = 0.5
        elif bet <=500 and bet > 100:
            bet_win_ratio = 1.25
        elif bet <= 1000 and bet > 500:
            bet_win_ratio = 1.5
        else:
            bet_win_ratio = 2.25

        event = self.helpers.getSlotsScreen()

        await self.bot.say(event[0])

        if event[1] == 3:
            win_value = int(1000000 * bet_win_ratio)
            await self.bot.say(f"🎇🎉🎊 | YOU WON **{win_value}** coins from the slot!")
        elif event[1] == 2:
            win_value = int(bet * bet_win_ratio)
            await self.bot.say(f"👏👌 | You won **{win_value}** coins from the slot!")
        elif event[1] == 1:
            win_value = bet
            await self.bot.say(f"👍 | You won back your bet.")
        else:
            win_value = -bet
            await self.bot.say(f"\n 😢 | You lost your bet.")

        _user.add_money(win_value)
Exemplo n.º 11
0
    async def reward_user(self, bot, user_id):
        _user = User(user_id)

        if quizzes[user_id][1] == "easy":
            prize = 50
        elif quizzes[user_id][1] == "medium":
            prize = 125
        elif quizzes[user_id][1] == "hard":
            prize = 200

        _user.add_money(prize)

        channel = discord.utils.get(self.bot.get_all_channels(),
                                    id=quizzes[user_id][2])

        await bot.send_message(
            channel,
            f"✅ | You answered the question correctly! You received **{prize}** coins."
        )
Exemplo n.º 12
0
    async def coinflip(self, ctx, guess: str, bet: int = 50):
        guess = guess.lower()

        author = ctx.message.author

        options = ["heads", "tails"]

        if guess not in options:
            await self.bot.say(self.errors.OPTION_ERR.format("heads or tails"))
            return
        
        _user = User(author.id)

        if _user.is_Registered is False:
            await self.bot.say(self.errors.USER_NOT_IN_DB)
            return

        if _user.money < bet:
            await self.bot.say(self.errors.INSUF_MONEY)
            return
        
        if bet <= 100 and bet > 0:
            bet_win_ratio = 0.25
        elif bet <=500 and bet > 100:
            bet_win_ratio = 0.5
        elif bet <= 1000 and bet > 500:
            bet_win_ratio = 0.75
        else:
            bet_win_ratio = 1.25

        draw = random.choice(options)

        win_value = int(bet * bet_win_ratio)

        if guess == draw:
            await self.bot.say(self.msg.COIN_WIN.format(draw, guess, win_value))
            _user.add_money(win_value)
        else:
            await self.bot.say(self.msg.COIN_LOSE.format(draw, guess, bet))
Exemplo n.º 13
0
    async def buy(self, ctx, item_id):
        _user = User(ctx.message.author.id)
        _item = Item(item_id)

        if _user.is_Registered is False:
            await self.bot.say(self.errors.USER_NOT_IN_DB)
            return

        if _item.exists is False:
            await self.bot.say(self.errors.ITEM_NOT_EXIST)
            return

        try:
            if item_id == _user.get_user_item(item_id)[0][1]:
                await self.bot.say(self.errors.ALREADY_OWNED)
                return
        except:
            try:
                if item_id == _user.get_user_badge(item_id)[0][1]:
                    await self.bot.say(self.errors.ALREADY_OWNED)
                    return
            except:
                pass

        cost = _item.cost

        if _user.money < cost:
            await self.bot.say(self.errors.INSUF_MONEY)
            return

        if _item.kind == 3:
            _user.store_badge(item_id)
        else:
            _user.put_background(item_id)

        _user.add_money(-cost)

        await self.bot.say(self.msg.ITEM_INV)