import asyncio


async def delete_option(bot, ctx, message, delete_emoji, timeout=20):
	"""Utility function that allows for you to add a delete option to the end of a command.
	This makes it easier for users to control the output of commands, esp handy for random output ones.

	Params
	=======
	bot: discord.ext.commands.Bot
		The current bot client
	ctx: discord.ext.commands.Context
		The context of the command
	message: discord.Message
		Output message from Roxbot
	delete_emoji: discord.Emoji or str if unicode emoji
		Used as the reaction for the user to click on.
	timeout: int (Optional)
		Amount of time in seconds for the bot to wait for the reaction. Deletes itself after the timer runes out.
		Set to 20 by default
	"""
	await message.add_reaction(delete_emoji)

	def check(r, u):
		return str(r) == str(delete_emoji) and u == ctx.author and r.message.id == message.id

	try:
		await bot.wait_for("reaction_add", timeout=timeout, check=check)
		await message.remove_reaction(delete_emoji, bot.user)
		await message.remove_reaction(delete_emoji, ctx.author)
		await message.edit(content="{} requested output be deleted.".format(ctx.author), embed=None)
	except asyncio.TimeoutError:
		await message.remove_reaction(delete_emoji, bot.user)