Example #1
0
async def pay(ctx, amount: float, target: discord.Member, *reasons):
    juser = user.JUser(ctx.author.id)
    target_user = user.JUser(target.id)
    reason = ' '.join(reasons)

    if amount <= 0:
        await ctx.send('You can only send a positive amount of JBucks')
        return

    if juser.jbucks < amount:
        await ctx.send(
            'You are too poor for this request (You have {} Jbucks)'.format(
                juser.jbucks))
        return

    juser.add_jbucks(round(-1. * amount, 2))
    target_user.add_jbucks(amount)
    db.transactions.insert_one({
        'ts': datetime.now(),
        'from': juser.user_id,
        'to': target_user.user_id,
        'amount': amount,
        'reason': reason,
    })
    juser.save()
    target_user.save()
    await ctx.send(
        'You have paid {} Jbucks to {}#{}. You now have {} Jbucks and they have {}.'
        .format(amount, target.name, target.discriminator,
                round(juser.jbucks, 2), round(target_user.jbucks, 2)))
Example #2
0
async def tickets(ctx, usr: discord.Member = None):
    if usr:
        juser = user.JUser(usr.id)
        await ctx.send('{}#{} has {} raffle tickets'.format(
            usr.name, usr.discriminator, round(juser.raffle_tickets, 2)))
    else:
        juser = user.JUser(ctx.author.id)
        await ctx.send('You have {} raffle tickets'.format(
            round(juser.raffle_tickets, 2)))
Example #3
0
async def bal(ctx, usr: discord.Member = None):
    if usr:
        juser = user.JUser(usr.id)
        await ctx.send('{}#{}\'s current balance is {} Jbucks'.format(
            usr.name, usr.discriminator, round(juser.jbucks, 2)))
    else:
        juser = user.JUser(ctx.author.id)
        await ctx.send('Your current balance is {} Jbucks'.format(
            round(juser.jbucks, 2)))
Example #4
0
async def gift(ctx, usr: discord.Member, amt: float):
    juser = user.JUser(usr.id)
    juser.jbucks += amt
    juser.save()
    await ctx.send(
        '{} Jbucks have been generously gifted to {}#{} by the Jelly gods'.
        format(amt, usr.name, usr.discriminator))
Example #5
0
async def daily(ctx):
    juser = user.JUser(ctx.author.id)
    if juser.daily_available:
        await ctx.send(juser.daily())
    else:
        await ctx.send('You are attempting to gain more than ur alloted Jbucks'
                       )
    juser.save()
Example #6
0
async def raffle(ctx):
    await ctx.send(
        "our grand prize is {} jbux :) isn't that a lot. good job team...".
        format(round(utils.get_prize_pool(), 2)))
    user_list = []
    ticket_list = []
    for usr in db.user.find({'raffle_tickets': {'$gt': 0}}):
        user_list.append(await utils.get_user(ctx, usr.get('user_id')))
        ticket_list.append(int(100 * usr.get('raffle_tickets')))
    ticket_list = np.array(ticket_list)
    ticket_list = np.divide(ticket_list, ticket_list.sum())
    await asyncio.sleep(2)

    [first, second,
     third] = np.random.default_rng().choice(user_list, 3, False, ticket_list)

    await ctx.send('in third place (so close yet so far.....)....')
    await asyncio.sleep(2)
    await ctx.send('{} :) u get half a jbuck. congrat'.format(third.mention))
    third_juser = user.JUser(third.id)
    third_juser.jbucks += .5
    third_juser.save()
    await asyncio.sleep(2)

    await ctx.send('in second place (sorry ur the worst loser here).....')
    await asyncio.sleep(2)
    await ctx.send('{} ! one jbuck for u'.format(second.mention))
    second_juser = user.JUser(second.id)
    second_juser.jbucks += 1
    second_juser.save()
    await asyncio.sleep(2)

    jpp = round(utils.get_prize_pool(), 2)
    await ctx.send('and in first place (the most winner jelly).....')
    await asyncio.sleep(2)
    await ctx.send(
        '{} ^___^ congrat on {} jbuck !! remember to reinvest it into the jellyconomy!'
        .format(first.mention, jpp))
    first_juser = user.JUser(first.id)
    first_juser.jbucks += jpp
    first_juser.save()

    db.globals.update_one({'key': 'prize_pool'}, {'$set': {'value': 0}})
    db.user.update_many({}, {'$set': {'raffle_tickets': 0}})
Example #7
0
async def accept(ctx, job_id: int):
    job_doc = db.jobs.find_one({'_id': job_id})
    if not job_doc:
        await ctx.send("Could not find job")
        return

    juser = user.JUser(ctx.author.id)
    juser.save()

    job = jobs.Job()
    job.load(job_doc)

    if job.accepted:
        await ctx.send("Job is already taken")
        return

    employer = await bot.fetch_user(job.employer)
    embed = discord.Embed()
    embed.add_field(name=job.name, value=await get_job_output(job))
    if (job.income <= 0 and juser.jbucks < -1 * job.income):
        await ctx.send(
            'Sorry, you do not have enough jbux for this service (You have {} jbux)'
            .format(juser.jbucks))
        return
    if (job.income > 0 and employer.jbucks < job.income):
        await ctx.send(
            'Sorry, your employer does not have enough jbux to hire you (They have {} jbux)'
            .format(employer.jbucks))
        return

    await ctx.send('Hey {}, {} has accepted your job:'.format(
        employer.mention if employer else job.employer, ctx.author.mention),
                   embed=embed)

    if job.repeats == 'never':
        await transfer(ctx, user.JUser(job.employer), employer.mention, juser,
                       ctx.author.mention, job.income)
    else:
        db.jobs.update_one({'_id': job_id},
                           {'$set': {
                               'accepted': ctx.author.id
                           }})
Example #8
0
async def award(ctx, usr: discord.Member):
    amt = db.globals.find_one({'key': 'prize_pool'}).get('value', 0)
    if amt > 0:
        juser = user.JUser(usr.id)
        juser.jbucks += amt
        juser.save()

        db.globals.update_one({'key': 'prize_pool'}, {'$set': {'value': 0}})

        await ctx.send(
            '{} Jbucks have been awarded to {}#{} from the prize pool, which is now empty'
            .format(amt, usr.name, usr.discriminator))
Example #9
0
async def pay(ctx, amount: float, target: discord.Member, *reasons):
    juser = user.JUser(ctx.author.id)
    target_user = user.JUser(target.id)
    reason = ' '.join(reasons)

    if amount <= 0:
        await ctx.send('You can only send a positive amount of JBucks')
        return

    if juser.jbucks < amount:
        await ctx.send(
            'You are too poor for this request (You have {} Jbucks)'.format(
                juser.jbucks))
        return

    await utils.transfer(ctx,
                         juser,
                         ctx.author.mention,
                         target_user,
                         target.mention,
                         amount,
                         reason=reason)
Example #10
0
async def quitjob(ctx, job_id: int):
    juser = user.JUser(ctx.author.id)
    job_doc = db.jobs.find_one({'_id': job_id})

    if not job_doc:
        await ctx.send("Could not find job")
        return

    job = jobs.Job()
    job.load(job_doc)

    if job.accepted != ctx.author.id:
        await ctx.send("This is not your job")
        return

    juser.save()
    db.jobs.update_one({'_id': job_id}, {'$set': {'accepted': 0}})

    embed = discord.Embed()
    job.accepted = 0
    embed.add_field(name=job.name, value=await utils.get_job_output(ctx, job))
    await ctx.send('You have quit your job:', embed=embed)
Example #11
0
async def view(ctx, type, mine=None):
    fil = {}
    fil['income'] = {'$gt': 0} if type == 'jobs' else {'$lte': 0}
    if mine == 'posted':
        fil['accepted'] = 0
        fil['employer'] = ctx.author.id
    elif mine == 'accepted':
        juser = user.JUser(ctx.author.id)
        fil['accepted'] = juser.user_id
    elif mine == 'all':
        pass
    else:
        fil['accepted'] = 0

    embed = discord.Embed(title='Current {}'.format(type))
    if db.jobs.count_documents(fil) == 0:
        await ctx.send("No jobs found")
        return
    for j in db.jobs.find(fil):
        job = jobs.Job()
        job.load(j)
        embed.add_field(name=job.name, value=await get_job_output(job))
    await ctx.send(embed=embed)
Example #12
0
async def view(ctx, type, mine=None):
    fil = {}
    fil['income'] = {'$gt': 0} if type == 'requests' else {'$lte': 0}
    if mine == 'posted':
        fil['accepted'] = 0
        fil['employer'] = ctx.author.id
    elif mine == 'accepted':
        juser = user.JUser(ctx.author.id)
        fil['accepted'] = juser.user_id
    elif mine == 'all':
        pass
    else:
        fil['accepted'] = 0

    if db.jobs.count_documents(fil) == 0:
        await ctx.send("No {} found".format(type))
        return

    data = []
    for j in db.jobs.find(fil).sort('_id', -1):
        job = jobs.Job()
        job.load(j)
        data.append({'name': job.name, 'value': await get_job_output(ctx, job)})
    await paginate(ctx, 'Current {}'.format(type), data)