2018-07-31 23:02:44 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# encoding: utf-8
|
|
|
|
|
2018-08-10 13:01:15 +00:00
|
|
|
import contextlib
|
|
|
|
|
2018-07-31 23:02:44 +00:00
|
|
|
import discord
|
|
|
|
from discord.ext import commands
|
|
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
def __init__(self, bot):
|
|
|
|
self.bot = bot
|
|
|
|
|
|
|
|
@commands.command(aliases=['inv'])
|
|
|
|
async def invite(self, context):
|
|
|
|
"""Gives you a link to add me to your server."""
|
|
|
|
permissions = discord.Permissions()
|
|
|
|
permissions.update(**dict.fromkeys((
|
|
|
|
'read_messages',
|
|
|
|
'send_messages',
|
|
|
|
'add_reactions',
|
|
|
|
'external_emojis',
|
|
|
|
'manage_emojis',
|
|
|
|
'embed_links',
|
|
|
|
), True))
|
|
|
|
|
|
|
|
await context.send('<%s>' % discord.utils.oauth_url(self.bot.user.id, permissions))
|
|
|
|
|
2018-08-10 13:01:15 +00:00
|
|
|
@commands.command()
|
|
|
|
async def support(self, context):
|
|
|
|
"""Directs you to the support server."""
|
|
|
|
try:
|
|
|
|
await context.author.send(self.bot.config['support_server_invite'])
|
|
|
|
with contextlib.suppress(discord.HTTPException):
|
2018-08-22 15:27:35 +00:00
|
|
|
await context.message.add_reaction('📬') # TODO make this emoji configurable too
|
2018-08-10 13:01:15 +00:00
|
|
|
except discord.Forbidden:
|
|
|
|
with contextlib.suppress(discord.HTTPException):
|
2018-08-22 15:27:35 +00:00
|
|
|
await context.message.add_reaction(utils.SUCCESS_EMOJIS[True])
|
2018-08-10 13:01:15 +00:00
|
|
|
await context.send('Unable to send invite in DMs. Please allow DMs from server members.')
|
|
|
|
|
2018-07-31 23:02:44 +00:00
|
|
|
def setup(bot):
|
|
|
|
bot.add_cog(Meta(bot))
|
2018-08-10 13:01:15 +00:00
|
|
|
|
|
|
|
if not bot.config.get('support_server_invite'):
|
|
|
|
bot.remove_command('support')
|