Ejemplo n.º 1
0
	async def inventory(self, ctx):
		'''Description:
		Bring up a display with all your items.
		Use:
		`%sinventory`
		Aliases:
		`inv`'''

		inv_embed = discord.Embed(title=f'{ctx.author.name}\'s Inventory', description=r'\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_', color=discord.Color.purple())
		
		users = get_users()

		if ctx.author.name not in users:
			add_user_to_milk(ctx.author.name)
			users = get_users()

		for item, amount in users[ctx.author.name]['items'].items():
			if item == 'calcium':
				inv_embed.add_field(name=f':rock: Calcium - {amount}', value='Mineral dug from the calcium mines.', inline=False)
				continue

			it = self.items[self.item_strs.index(item.lower())]
			inv_embed.add_field(name=f'{it.emoji} {it.name} - {amount}', value=it.description, inline=False)
		
		await ctx.send('', embed=inv_embed)
Ejemplo n.º 2
0
	async def buy(self, ctx, *item):
		'''Description:
		Buy items from the shop.
		Use:
		`%sbuy {item} [amount]`'''

		if not item:
			embed = discord.Embed(title='You have not specified an item to buy.', color=discord.Color.red())
			await ctx.send('', embed=embed)
			return

		try:
			amount = int(item[-1])
			item = item[:-1]
		except ValueError:
			amount = 1
		
		item = ' '.join(item)

		if item.lower() in self.item_strs:
			item_idx = self.item_strs.index(item.lower())
			it = self.items[item_idx]

			users = get_users()
			
			if ctx.author.name not in users:
				add_user_to_milk(ctx.author.name)
				users = get_users()
			
			if users[ctx.author.name]['balance'] >= it.cost * amount:
				edit_user_milk(ctx.author.name, -it.cost * amount)
				users = get_users()

				if amount == 1:
					article = 'an' if it.name.startswith(('a', 'e', 'i', 'o', 'u')) else 'a'
					bought_embed = discord.Embed(title=f'You have bought {article} {it.name}', color=discord.Color.green())
				else:
					bought_embed = discord.Embed(title=f'You have bought {amount} {it.name}s', color=discord.Color.green())
				
				await ctx.send('', embed=bought_embed)
				
				if it.name in users[ctx.author.name]['items']:
					users[ctx.author.name]['items'][it.name] += amount
				else:
					users[ctx.author.name]['items'][it.name] = amount
				
				dump_users(users)
			
			else:
				embed = discord.Embed(title='You do not have enough milk units to buy this item.', color=discord.Color.red())
				await ctx.send('', embed=embed)

		else:
			embed = discord.Embed(title='Error!', description='Item not found', color=discord.Color.red())
			await ctx.send('', embed=embed)
Ejemplo n.º 3
0
	async def work(self, ctx, *args):
		"""Description:
		Work at your job or choose a new job.
		
		Use:
		`%swork [job | list]`"""

		users = get_users()

		if ctx.author.name not in users:
			add_user_to_milk(ctx.author.name)
			users = get_users()
		
		if args:
			if args[0] == 'list':
				jobs = '\n\n'.join([job.name + ' - ' + str(job.salary) + f'mu\n({self.job_aliases[self.job_list.index(job)]})' for job in self.job_list])

				embed = discord.Embed(title=f'Use `{self.prefix}work [job]` to choose a job.', description=jobs, color=discord.Color.green())
				await ctx.send('', embed=embed)
				return
			
			job = ' '.join(args)

			if job.lower() in self.job_names_lower or job.lower() in self.job_aliases_lower:
				if job.lower() in self.job_aliases_lower:
					job = self.job_names[self.job_aliases.index(job.upper())]
				else:
					job = self.job_names[self.job_names_lower.index(job.lower())]

				users[ctx.author.name]['job'] = job
				dump_users(users)

				embed = discord.Embed(title=f'You are now working at {job}!', color=discord.Color.green())
				await ctx.send('', embed=embed)

			else:
				embed = discord.Embed(title='This job does not exist.', color=discord.Color.red())
				await ctx.send('', embed=embed)
		
		else:
			if not await is_on_cooldown(ctx, 3600, 'work_cd'):
				job = users[ctx.author.name]['job']
				
				if job == 'Simmons Gaming Industries':
					await self.gaming(ctx)

				elif job == 'Kangaroo Containment Facility':
					await self.kangaroo(ctx)
				
				else:
					embed = discord.Embed(title='You dont\'t have a job yet.', description='Use `.work list` to see a list of jobs.', color=discord.Color.red())
					await ctx.send('', embed=embed)

					users[ctx.author.name]['work_cd'] = 0.0
					dump_users(users)
Ejemplo n.º 4
0
	async def check_balance(self, ctx, *account):
		"""Description:
		Check the amount of milk that you have acquired
		
		Use:
		`%sbalance [account_to_check]`
		Aliases:
		`bal`"""

		account_member = None
		if account:
			account_id = int(account[0][3:-1]) if '!' in account[0] else int(account[0][2:-1])
			account_member = ctx.guild.get_member(account_id)
			if account_member is None:
				notfound_embed = discord.Embed(title='Error!', description='User not found!', color=discord.Color.red())
				await ctx.send('', embed=notfound_embed)
				return
		else:
			account_member = ctx.author
		
		account_name = account_member.name
		
		users = get_users()
		
		try:
			balance = int_to_str(users[account_member.name]['balance'])
			bal_embed = discord.Embed(title=f'{account_name}\'s Balance', description=f'{balance} milk units', color=discord.Color.green())
			await ctx.send('', embed=bal_embed)
		except KeyError:
			add_user_to_milk(account_name)
			
			bal = discord.Embed(title=f'{account_name}\'s Balance', description='0 milk units', color=discord.Color.green())
			await ctx.send('', embed=bal)
Ejemplo n.º 5
0
	async def use(self, ctx, *item):
		'''Description:
		Use an item in your inventory.
		Use:
		`%suse {item}`'''

		if not item:
			embed = discord.Embed(title='You have not specified an item to use.', color=discord.Color.red())
			await ctx.send('', embed=embed)
			return
		
		item = ' '.join(item)


		users = get_users()

		if ctx.author.name not in users:
			add_user_to_milk(ctx.author.name)
			users = get_users()

		if item.lower() in map(str.lower, users[ctx.author.name]['items']):
			it = self.items[self.item_strs.index(item.lower())]

			amount = users[ctx.author.name]['items'][it.name]

			if it.use == functions[2]:
				amount += 1

			if amount > 1:
				amount -= 1
				users[ctx.author.name]['items'][it.name] = amount
			else:
				del users[ctx.author.name]['items'][it.name]

			dump_users(users)
			
			if it.use == functions[3]:
				await it.use(ctx, ctx.author.name, self.bot)
			else:
				await it.use(ctx, ctx.author.name)

		else:
			embed = discord.Embed(title='Error!', description='You don\'t have this item or the item is invalid.', color=discord.Color.red())
			await ctx.send('', embed=embed)
Ejemplo n.º 6
0
async def drink_milk(ctx, user):
    users = get_users()

    users[user]['cdstate'] = 'off'

    dump_users(users)

    embed = discord.Embed(
        title=
        'You drank the milk carton. You feel power flowing through your veins.',
        description='Command cooldowns have been disabled.',
        color=discord.Color.green())
    await ctx.send('', embed=embed)
Ejemplo n.º 7
0
	async def dig(self, ctx):
		'''Description:
		Dig in the calcium mines for calcium to sell.
		Use:
		`%sdig`'''

		users = get_users()
		
		if ctx.author.name not in users:
			add_user_to_milk(ctx.author.name)
			users = get_users
		
		if 'Shovel' not in users[ctx.author.name]['items']:
			embed = discord.Embed(title='You don\'t have a shovel to dig with!', color=discord.Color.red())
			await ctx.send('', embed=embed)
			return

		amount = random.randint(1, 200)

		outcome = random.randint(49, 50)

		if outcome < 50:
			embed = discord.Embed(title=f'You have successfully mined {amount}mg of calcium!', color=discord.Color.green())

			if 'calcium' not in users[ctx.author.name]['items']:
				users[ctx.author.name]['items']['calcium'] = amount

			else:
				users[ctx.author.name]['items']['calcium'] += amount
			
		else:
			embed = discord.Embed(title='Alas! Your shovel broke while mining.', description='You lost your shovel and didn\'t gain any calcium either.', color=discord.Color.red())

			if users[ctx.author.name]['items']['Shovel'] > 1:
				users[ctx.author.name]['items']['Shovel'] -= 1
			else:
				del users[ctx.author.name]['items']['Shovel']
		
		dump_users(users)

		await ctx.send('', embed=embed)
Ejemplo n.º 8
0
	async def leaderboard(self, ctx):
		"""Description:
		Check the users with the top 5 milk amounts
		
		Use:
		`%sleaderboard`"""
		users = get_users()
		
		balance_list = {}
		for user, val in users.items():
			balance_list[user] = val['balance']
		
		new_balances = sorted(balance_list.items(), key=lambda kv: kv[1], reverse=True)[:5]
		
		desc = ''
		for i in new_balances:
			bal = int_to_str(i[1])
			new_list = [i[0], bal]
			desc += ' - '.join(new_list) + 'mu' + '\n'

		message = discord.Embed(title='Top 5 Milk Owners', description=desc, color=discord.Color.gold())
		await ctx.send('', embed=message)
Ejemplo n.º 9
0
	async def sell(self, ctx, *item):
		"""Description:
		Sell your items for milk units.
		Use:
		`%ssell {item} [amount]`
		"""

		if not item:
			embed = discord.Embed(title='Error!', description='No item listed to sell.', color=discord.Color.red())
			await ctx.send('', embed=embed)
			return

		try:
			amount = int(item[-1])
			item = item[:-1]
		except ValueError:
			amount = 1

		if amount < 1:
			embed = discord.Embed(title='Error!', description='You can\'t sell fewer than 1 item.', color=discord.Color.red())
			await ctx.send('', embed=embed)
			return
		
		name = ' '.join(item)

		users = get_users()

		if ctx.author.name not in users:
			add_user_to_milk(ctx.author.name)
			users = get_users()

		items = users[ctx.author.name]['items']

		if name.lower() not in map(str.lower, items):
			embed = discord.Embed(title='Error!', description='You do not own this item.', color=discord.Color.red())
			await ctx.send('', embed=embed)
			return
		
		if name.lower() == 'calcium':
			if amount > items['calcium']:
				embed = discord.Embed(title='Error!', description='You can\'t sell more calcium than you have.', color=discord.Color.red())
				await ctx.send('', embed=embed)
				return
			
			items['calcium'] -= amount

			users[ctx.author.name]['balance'] += amount * 10

			embed = discord.Embed(title=f'You have successfully sold {amount}mg of calcium!', description=f'You have received {amount * 10}mu!', color=discord.Color.green())

			if items['calcium'] == 0:
				del items['calcium']

		else:
			item = self.items[self.item_strs.index(name.lower())]

			if amount > items[item.name]:
				embed = discord.Embed(title='Error!', description=f'You can\'t sell more {name}s than you have.', color=discord.Color.red())
				await ctx.send('', embed=embed)
				return

			items[item.name] -= amount
			users[ctx.author.name]['balance'] += item.sellCost * amount
			
			plural = 's' if amount > 1 else ''

			embed = discord.Embed(title=f'You have successfully sold {amount} {item.name}{plural}!', description=f'You have received {item.sellCost * amount}mu!', color=discord.Color.green())

			if items[item.name] == 0:
				del items[item.name]

		await ctx.send('', embed=embed)
		users[ctx.author.name]['items'] = items
		dump_users(users)
Ejemplo n.º 10
0
async def enter_lottery(ctx, user, bot):
    amount_embed = discord.Embed(title='How many would you like to use?',
                                 color=discord.Color.blue())
    await ctx.send('', embed=amount_embed)

    try:
        msg = await bot.wait_for('message', timeout=10, check=check_lot_msg)

        amount = int(msg.content)

        if amount < 1:
            embed = discord.Embed(
                title='Error!',
                description='You can\'t use fewer than 1 tickets.',
                color=discord.Color.red())
            await ctx.send('', embed=embed)
            return

        users = get_users()

        if amount > users[ctx.author.name]['items']['Lottery Ticket'] + 1:
            embed = discord.Embed(
                title='Error!',
                description='You dont\'t have this many tickets.',
                color=discord.Color.red())
            await ctx.send('', embed=embed)
            users[ctx.author.name]['items']['Lottery Ticket'] += 1
            dump_users(users)
            return

        num_list = [random.randint(1, 200) for _ in range(amount)]

        if 69 in num_list:
            edit_user_milk(ctx.author.name, 100000)

            embed = discord.Embed(title='You won!',
                                  description='You have received 100000mu!',
                                  color=discord.Color.green())
            await ctx.send('', embed=embed)

        else:
            embed = discord.Embed(title='You lost.',
                                  description='Better luck next time.',
                                  color=discord.Color.red())
            await ctx.send('', embed=embed)

        users[ctx.author.name]['items']['Lottery Ticket'] -= (amount - 1)

        if users[ctx.author.name]['items']['Lottery Ticket'] == 0:
            del users[ctx.author.name]['items']['Lottery Ticket']

        dump_users(users)

    except asyncio.TimeoutError:
        embed = discord.Embed(title='Timed out.',
                              description='You didn\'t respond in time.',
                              color=discord.Color.red())
        await ctx.send('', embed=embed)
        users = get_users()
        users[ctx.author.name]['items']['Lottery Ticket'] += 1
        dump_users(users)