From e965bc29133b863615505e737c5c381f333d3a83 Mon Sep 17 00:00:00 2001 From: Ske Date: Sat, 14 Jul 2018 21:39:51 +0200 Subject: [PATCH] Add command to show invite link --- bot/pluralkit/commands.py | 21 ++++++++++++++++++++- docker-compose.yml | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bot/pluralkit/commands.py b/bot/pluralkit/commands.py index 087b1150..d2689e6d 100644 --- a/bot/pluralkit/commands.py +++ b/bot/pluralkit/commands.py @@ -1,9 +1,11 @@ from datetime import datetime import itertools +import os import re from urllib.parse import urlparse import discord +from discord.utils import oauth_url import humanize from pluralkit import db @@ -581,4 +583,21 @@ async def import_tupperware(conn, message, args): await db.update_member_field(conn, member_id=existing_member["id"], field="birthday", value=member_birthdate) await db.update_member_field(conn, member_id=existing_member["id"], field="description", value=member_description) - return True, "System information imported. Try using `pk;system` now.\nYou should probably remove your members from Tupperware to avoid double-posting." \ No newline at end of file + return True, "System information imported. Try using `pk;system` now.\nYou should probably remove your members from Tupperware to avoid double-posting." + +@command(cmd="invite", description="Generates an invite link for this bot.") +async def invite_link(conn, message, args): + client_id = os.environ["CLIENT_ID"] + + permissions = discord.Permissions() + permissions.manage_webhooks = True + permissions.send_messages = True + permissions.manage_messages = True + permissions.embed_links = True + permissions.attach_files = True + permissions.read_message_history = True + permissions.add_reactions = True + + url = oauth_url(client_id, permissions) + logger.debug("Sending invite URL: {}".format(url)) + return True, url \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index e047caf7..36b0487f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,7 @@ services: depends_on: - db environment: + - CLIENT_ID - TOKEN db: image: postgres:alpine