Пример #1
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)
Пример #2
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)
Пример #3
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)
Пример #4
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)
Пример #5
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)
Пример #6
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)
Пример #7
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)