From ea07e931fcc6a4716bc77ac20fdb6dafe765eb29 Mon Sep 17 00:00:00 2001 From: Ske Date: Tue, 11 Dec 2018 20:52:43 +0100 Subject: [PATCH] Replace environment variable for TW instance ID with optional parameter --- docker-compose.yml | 1 - src/pluralkit/bot/commands/import_commands.py | 14 ++++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index ed78b337..28cc9519 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,6 @@ services: - CLIENT_ID - TOKEN - LOG_CHANNEL - - TUPPERWARE_ID - "DATABASE_USER=postgres" - "DATABASE_PASS=postgres" - "DATABASE_NAME=postgres" diff --git a/src/pluralkit/bot/commands/import_commands.py b/src/pluralkit/bot/commands/import_commands.py index 852fafe2..ee699d9b 100644 --- a/src/pluralkit/bot/commands/import_commands.py +++ b/src/pluralkit/bot/commands/import_commands.py @@ -1,4 +1,3 @@ -import os from datetime import datetime from pluralkit.bot.commands import * @@ -13,12 +12,19 @@ async def import_tupperware(ctx: CommandContext): # Check if there's a Tupperware bot on the server # Main instance of TW has that ID, at least tupperware_id = 431544605209788416 - if "TUPPERWARE_ID" in os.environ: - tupperware_id = int(os.environ["TUPPERWARE_ID"]) + if ctx.has_next(): + try: + id_str = ctx.pop_str() + tupperware_id = int(id_str) + except ValueError: + raise CommandError("'{}' is not a valid ID.".format(id_str)) tupperware_member = ctx.message.guild.get_member(tupperware_id) if not tupperware_member: - raise CommandError("This command only works in a server where the Tupperware bot is also present.") + raise CommandError( + """This command only works in a server where the Tupperware bot is also present. + +If you're trying to import from a Tupperware instance other than the main one (which has the ID 431544605209788416), pass the ID of that instance as a parameter.""") # Make sure at the bot has send/read permissions here channel_permissions = ctx.message.channel.permissions_for(tupperware_member)