Replace environment variable for TW instance ID with optional parameter
This commit is contained in:
		| @@ -11,7 +11,6 @@ services: | ||||
|     - CLIENT_ID | ||||
|     - TOKEN | ||||
|     - LOG_CHANNEL | ||||
|     - TUPPERWARE_ID | ||||
|     - "DATABASE_USER=postgres" | ||||
|     - "DATABASE_PASS=postgres" | ||||
|     - "DATABASE_NAME=postgres" | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user