diff --git a/main.py b/main.py index 08003f4..724c615 100644 --- a/main.py +++ b/main.py @@ -20,7 +20,7 @@ def readToken(filePath): async def postToSheet(data, gsheetToken): async with aiohttp.ClientSession() as session: async with session.post(gsheetToken, json=data) as response: - print("Status:", response.status) + # print("Status:", response.status) return response.status @@ -38,13 +38,11 @@ async def writeDeliveryToCommandFile(author, command): jsonContent = json.loads("{}") else: - print("loading from file") jsonContent = json.load(f) with open(lastCommandFile, 'w') as f: - print(jsonContent) jsonContent[author] = command json.dump(jsonContent, f) @@ -143,6 +141,44 @@ async def delivery(ctx, +# delivery command for misc commodity only +# guild IDs are both IDA servers +@bot.slash_command( + name="misc", + # guild_ids=[401372086746087425], + description= "Used for the commodities we're too lazy to create a sheet for" +) +async def misc(ctx, + quantity: discord.Option(discord.SlashCommandOptionType.integer, description="Please be nice and input a value between 1 and 1326 (new rack update!!!!1!1)", min_value=1, max_value=1326), + target: discord.Option(str, choices=['Station', 'Carrier']) + ): + + author = str(ctx.author) + author = author[:author.find(" ")] + + await ctx.defer() + + data = { + "username":author, + "commodity": "Miscellaneous", + "quantity": quantity, + "target": target + } + + try: + response = await postToSheet(data, gsheetToken) + if response == 200: + await ctx.followup.send(f"your delivery of {quantity} of Miscellaneous stuff to a {target} has been added to the sheet!") + print(f"[{dt.isoformat(dt.now())}]{author} delivery of {quantity} of Miscellaneous to a {target}") + await writeDeliveryToCommandFile(author, data) + else: + await ctx.followup.send(f"Failed to log delivery (HTTP {response}). Please contact the yellow people if that keeps happening") + except Exception as e: + await ctx.followup.send(f"help : Error: {e}") + + + + @bot.slash_command( name="last", # guild_ids=[401372086746087425],