Compare commits
No commits in common. "main" and "dev-prodId" have entirely different histories.
main
...
dev-prodId
|
|
@ -111,82 +111,12 @@ class IdaCogs(commands.Cog):
|
|||
print(f"[{datetime.isoformat(datetime.now())}]{author} delivery of {quantity} of {commodity} to a {target}")
|
||||
await helpers.writeDeliveryToCommandFile(author, data)
|
||||
else:
|
||||
await ctx.followup.send(f"Google returned an error. (HTTP {response}). But your delivery may have gone through. Maybe. Maybe not? who knows? Not fucking Google apparently. ")
|
||||
|
||||
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"Something broke. Why do you keep breaking the bot, uh? :(")
|
||||
channel = self.bot.get_channel(self.debugChannel)
|
||||
await channel.send(f"{author} generated the following exception : {traceback.format_exc()}")
|
||||
|
||||
## bulk delivery
|
||||
|
||||
# delivery command
|
||||
# guild IDs are both IDA servers
|
||||
@discord.slash_command(
|
||||
name="bulk",
|
||||
# guild_ids=[401372086746087425],
|
||||
description="sends your delivery to the bot!"
|
||||
)
|
||||
|
||||
@option("commodity",required=True,
|
||||
description = "The Commodity you want to deliver",
|
||||
choices = [
|
||||
"Aluminium",
|
||||
"Ceramic Composites",
|
||||
"CMM Composite",
|
||||
"Computer Components",
|
||||
"Copper",
|
||||
"Food Cartridges",
|
||||
"Fruit and Vegetables",
|
||||
"Insulating Membrane",
|
||||
"Liquid Oxygen",
|
||||
"Medical Diagnostic Equipment",
|
||||
"Non-Lethal Weapons",
|
||||
"Polymers",
|
||||
"Power Generators",
|
||||
"Semiconductors",
|
||||
"Steel",
|
||||
"Superconductors",
|
||||
"Titanium",
|
||||
"Water",
|
||||
"Water Purifiers"
|
||||
])
|
||||
|
||||
@option("quantity",required=True,
|
||||
description="Please be nice and input a value between 1 and 25000",
|
||||
type=int, min_value=1, max_value=25000)
|
||||
@option("target", required=True,
|
||||
description="Are you delivering to a carrier or the target station?",
|
||||
type=str, choices=['Station', 'Carrier'])
|
||||
|
||||
async def bulk(self, ctx,commodity, quantity,target):
|
||||
|
||||
author = str(ctx.author)
|
||||
author = author[:author.find(" ")]
|
||||
|
||||
await ctx.defer()
|
||||
|
||||
data = {
|
||||
"postType":"delivery",
|
||||
"username":author,
|
||||
"commodity": commodity,
|
||||
"quantity": quantity,
|
||||
"target": target
|
||||
}
|
||||
|
||||
try:
|
||||
response = await helpers.postToSheet(self.session, data, self.gsheetToken)
|
||||
if response == 200:
|
||||
await ctx.followup.send(f"your delivery of {quantity} of {commodity} to a {target} has been added to the sheet!")
|
||||
print(f"[{datetime.isoformat(datetime.now())}]{author} delivery of {quantity} of {commodity} to a {target}")
|
||||
await helpers.writeDeliveryToCommandFile(author, data)
|
||||
else:
|
||||
await ctx.followup.send(f"Google returned an error. (HTTP {response}). But your delivery has probably been recorded on the sheet. I'm just not able to know for sure. Please check the sheet before double logging it.")
|
||||
|
||||
except Exception as e:
|
||||
await ctx.followup.send(f"Something broke. Why do you keep breaking the bot, uh? :(")
|
||||
channel = self.bot.get_channel(self.debugChannel)
|
||||
await channel.send(f"{author} generated the following exception : {traceback.format_exc()}")
|
||||
|
||||
|
||||
# delivery command for misc commodity only
|
||||
|
|
@ -209,7 +139,7 @@ class IdaCogs(commands.Cog):
|
|||
data = {
|
||||
"postType":"delivery",
|
||||
"username":author,
|
||||
"commodity": "Miscellaneous",
|
||||
"commodity": "Misc",
|
||||
"quantity": quantity,
|
||||
"target": target
|
||||
}
|
||||
|
|
@ -221,7 +151,7 @@ class IdaCogs(commands.Cog):
|
|||
print(f"[{datetime.isoformat(datetime.now())}]{author} delivery of {quantity} of Miscellaneous to a {target}")
|
||||
await helpers.writeDeliveryToCommandFile(author, data)
|
||||
else:
|
||||
await ctx.followup.send(f"Google returned an error. (HTTP {response}). But your delivery has probably been recorded on the sheet. I'm just not able to know for sure. Please check the sheet before double logging it.")
|
||||
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}")
|
||||
|
||||
|
|
@ -253,7 +183,7 @@ class IdaCogs(commands.Cog):
|
|||
print(f"[{datetime.isoformat(datetime.now())}] delivery of {data['quantity']} of {data['commodity']} to a {data['target']}")
|
||||
await helpers.writeDeliveryToCommandFile(author, data)
|
||||
else:
|
||||
await ctx.followup.send(f"Google returned an error. (HTTP {response}). But your delivery has probably been recorded on the sheet. I'm just not able to know for sure. Please check the sheet before double logging it.")
|
||||
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}")
|
||||
else:
|
||||
|
|
@ -366,7 +296,7 @@ class IdaCogs(commands.Cog):
|
|||
|
||||
response = await helpers.getFromSheet(self.session, self.gsheetToken, "commodity")
|
||||
|
||||
#print(response)
|
||||
print(response)
|
||||
commodity, values, initial = response.split("|")
|
||||
|
||||
commodity = commodity.split(",")
|
||||
|
|
@ -436,7 +366,7 @@ class IdaCogs(commands.Cog):
|
|||
await channel.send(embeds=[embed, embed2])
|
||||
|
||||
except Exception as e:
|
||||
print(f"Something bad happened in the whatlefttohaul function :( Error: {e}")
|
||||
print("Something bad happened in the whatlefttohaul function :(")
|
||||
|
||||
|
||||
|
||||
|
|
@ -474,7 +404,7 @@ class IdaCogs(commands.Cog):
|
|||
if not found:
|
||||
await channel.send(embed=embed)
|
||||
except Exception as e:
|
||||
print(f"Something bad happened in the carrierState function :( Error: {e}")
|
||||
print("Something bad happened in the carrierState function :(")
|
||||
|
||||
def setup(bot): # this is called by Pycord to setup the cog
|
||||
bot.add_cog(IdaCogs(bot)) # add the cog to the bot
|
||||
|
|
@ -48,8 +48,7 @@ async def getFromSheet(session, gsheetToken, data):
|
|||
async def postToSheet(session, data, gsheetToken):
|
||||
async with session.post(gsheetToken, json=data) as response:
|
||||
text = await response.text()
|
||||
print(text)
|
||||
print(response)
|
||||
#print(text)
|
||||
#print("Status:", response.status)
|
||||
return response.status
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user