#!/usr/bin/env python3
# encoding: utf-8

from datetime import datetime
import time

import discord
from discord.ext.commands import command


class Meta:
	"""Commands about the bot itself."""

	def __init__(self, bot):
		self.bot = bot
		bot.remove_command('help')

	@command()
	async def help(self, context):
		"""This message yer lookin' at right here, pardner."""
		embed = discord.Embed(
			title='Help for Reactor',
			timestamp=datetime.utcfromtimestamp(1515291012))

		embed.add_field(
			name='Poll',
			value='Usage: `poll: <your message here>`\n'
				+ '👍, 👎, and 🤷 will be added as reactions to your message, '
				+ 'unless "noshrug" is found in the message.')
		embed.add_field(
			name='Multi poll',
			value='Usage: ```poll: [poll title]\n'
				+ '<emoji> [option 1]\n'
				+ '<emoji> [option 2]\n<emoji> [option 3]...```\n'
				+ '`<emoji>` can be a custom emote, a number, or a letter.'
				+ '\nAll the emoji you specified will be added to the message,'
				+ 'as well as :shrug:. '
				+ 'However, if you add "noshrug" or "⛔shrug" or similar, '
				+ 'anywhere in the message, :shrug: will *not* be sent.')
		embed.add_field(
			name='Poll maker',
			value='Usage: `poll:make`\n'
				+ 'The bot will ask you everything it needs to know '
				+ 'about the poll, and then send it for you.\n'
				+ "Useful if you're not sure how to use the bot yet.")
		embed.add_field(
			name='invite',
			value='Usage: `poll:invite`\n'
				+ 'Sends you an invite link '
				+ 'so you can add the bot to your own server')
		embed.add_field(
			name='ping',
			value='Usage: `poll:ping`\n'
				+ "Shows the bots latency to Discord's servers")

		await context.send(embed=embed)

	@command()
	async def invite(self, context):
		"""Sends you a link so you can add the bot to your own server.
		Thanks! 😊
		"""
		permission_names = (
			'manage_messages', # needed to remove reactions on message edit
			'send_messages', # needed for help message
			# in case the user supplies an external emoji in a poll
			'external_emojis',
			'read_messages', # needed to act on commands
			'add_reactions', # needed to add poll options
			'embed_links') # needed to send the help message
		permissions = discord.Permissions()
		permissions.update(**dict.fromkeys(permission_names, True))

		await context.send(
			'<%s>' % discord.utils.oauth_url(self.bot.client_id, permissions))


def setup(bot):
	bot.add_cog(Meta(bot))

@@ -1834,14 +1834,12 @@
 %09%09%09'
-manage
+read
 _mes
@@ -1837,32 +1837,33 @@
 'read_messages',
+ 
  # needed to rem
@@ -1863,49 +1863,87 @@
  to 
-remove re
 act
-ions on message edit%0A%09%09%09'send
+ on commands%0A%09%09%09'send_messages',  # needed to send error messages%0A%09%09%09'manage
 _mes
@@ -1941,32 +1941,33 @@
 anage_messages',
+ 
  # needed for he
@@ -1964,28 +1964,67 @@
 ded 
-for help message%0A%09%09%09
+to remove reactions on message edit%0A%09%09%09'external_emojis',  
 # in
@@ -2079,78 +2079,8 @@
 oll%0A
-%09%09%09'external_emojis',%0A%09%09%09'read_messages', # needed to act on commands%0A
 %09%09%09'
@@ -2094,16 +2094,17 @@
 ctions',
+ 
  # neede
@@ -2142,16 +2142,17 @@
 _links')
+ 
  # neede

reorganize permissions