From 08a43beea7dc83270cd393178b9f3612e2aa4e4d Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Thu, 30 Jul 2026 19:48:41 +0200 Subject: [PATCH 1/3] added catch all exception to deal with google being a pain in the ass. Will fix later --- cogs/IdaCogs.py | 146 +++++++++++++++++++++++++----------------------- 1 file changed, 76 insertions(+), 70 deletions(-) diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py index 28f27a8..0da3744 100644 --- a/cogs/IdaCogs.py +++ b/cogs/IdaCogs.py @@ -286,115 +286,121 @@ class IdaCogs(commands.Cog): #writes to the whats left to haul channel ever 60 seconds about.. the stuff left to haul. #also updates the current commodity List - @tasks.loop(seconds=60) + @tasks.loop(seconds=120) async def writeToWhatsLeftToHaul(self): + try: + response = await helpers.getFromSheet(self.session, self.gsheetToken, "commodity") - response = await helpers.getFromSheet(self.session, self.gsheetToken, "commodity") + print(response) + commodity, values, initial = response.split("|") - print(response) - commodity, values, initial = response.split("|") - - commodity = commodity.split(",") - values = values.split(",") - initial = initial.split(",") + commodity = commodity.split(",") + values = values.split(",") + initial = initial.split(",") - values = [int(i) for i in values] - initial = [int (i) for i in initial] + values = [int(i) for i in values] + initial = [int (i) for i in initial] - finalDict = {} - progressDict = {} - neededCommodity = [] + finalDict = {} + progressDict = {} + neededCommodity = [] - for i in range(len(commodity)): - finalDict[commodity[i]] = values[i] + for i in range(len(commodity)): + finalDict[commodity[i]] = values[i] - if initial[i] > 0: - progressDict[commodity[i]] = await helpers.createProgressBar(values[i],initial[i]) - else: - progressDict[commodity[i]] = await helpers.createProgressBar(1,1) + if initial[i] > 0: + progressDict[commodity[i]] = await helpers.createProgressBar(values[i],initial[i]) + else: + progressDict[commodity[i]] = await helpers.createProgressBar(1,1) - if values[i] > 0: - neededCommodity.append(commodity[i]) + if values[i] > 0: + neededCommodity.append(commodity[i]) - #finalDict = dict(sorted(finalDict.items(), key=lambda item: item[1], reverse=True)) + #finalDict = dict(sorted(finalDict.items(), key=lambda item: item[1], reverse=True)) - self.commodities = neededCommodity + self.commodities = neededCommodity - embed = discord.Embed(title="Estimated remaining amounts", - colour=discord.Colour(0xffdd55), - timestamp=datetime.now()) - embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/536647643367997492.png") + embed = discord.Embed(title="Estimated remaining amounts", + colour=discord.Colour(0xffdd55), + timestamp=datetime.now()) + embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/536647643367997492.png") - embed2 = discord.Embed(title="Current progress", - colour=discord.Colour(0x002f80), - timestamp=datetime.now()) - embed2.set_thumbnail(url="https://cdn.discordapp.com/emojis/536647643367997492.png") + embed2 = discord.Embed(title="Current progress", + colour=discord.Colour(0x002f80), + timestamp=datetime.now()) + embed2.set_thumbnail(url="https://cdn.discordapp.com/emojis/536647643367997492.png") - for key in finalDict: - if finalDict[key] > 0: - embed.add_field(name=key, value=finalDict[key], inline=True) - embed2.add_field(name=key, value=str(progressDict[key]), inline=True) + for key in finalDict: + if finalDict[key] > 0: + embed.add_field(name=key, value=finalDict[key], inline=True) + embed2.add_field(name=key, value=str(progressDict[key]), inline=True) - embed2.set_footer(text="This message updates every 60 seconds(ish). Last updated") - embed.set_author(name=u'\U0001F517 ' + self.stationName + u' \U0001F517', - url=self.stationUrl) - embed2.set_author(name=u'\U0001F517 ' + self.stationName + u' \U0001F517', - url=self.stationUrl) + embed2.set_footer(text="This message updates every 120 seconds(ish). Last updated") + embed.set_author(name=u'\U0001F517 ' + self.stationName + u' \U0001F517', + url=self.stationUrl) + embed2.set_author(name=u'\U0001F517 ' + self.stationName + u' \U0001F517', + url=self.stationUrl) - channel = self.bot.get_channel(self.whatsLeftToHaulChannelId) + channel = self.bot.get_channel(self.whatsLeftToHaulChannelId) - found = False - async for oldmsg in channel.history(limit=2): - if oldmsg.author == self.bot.user: - found = True - await oldmsg.edit(embeds=[embed, embed2]) - break - if not found: - await channel.send(embeds=[embed, embed2]) + found = False + async for oldmsg in channel.history(limit=2): + if oldmsg.author == self.bot.user: + found = True + await oldmsg.edit(embeds=[embed, embed2]) + break + if not found: + await channel.send(embeds=[embed, embed2]) + + except Exception as e: + print("Something bad happened in the whatlefttohaul function :(") #writes the carriers state to... the carrier state channel. Seriously, who is writing this? - @tasks.loop(seconds=60) + @tasks.loop(seconds=120) async def writeTocarrierState(self): - response = await helpers.getInternalCarrierState(self.session, self.gsheetToken) - carrierState = await helpers.parseCarrierState(response) + try: + response = await helpers.getInternalCarrierState(self.session, self.gsheetToken) + carrierState = await helpers.parseCarrierState(response) - channel = self.bot.get_channel(self.carrierStatsChannel) + channel = self.bot.get_channel(self.carrierStatsChannel) - embed = discord.Embed(title="Carriers State", - colour=discord.Colour(0x29ac08), - timestamp=datetime.now()) - embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/536647643367997492.png") - embed.set_author(name=u'\U0001F517 ' + self.stationName + u' \U0001F517', - url=self.stationUrl) + embed = discord.Embed(title="Carriers State", + colour=discord.Colour(0x29ac08), + timestamp=datetime.now()) + embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/536647643367997492.png") + embed.set_author(name=u'\U0001F517 ' + self.stationName + u' \U0001F517', + url=self.stationUrl) - embed.set_footer(text="This message updates every 60 seconds(ish). Last updated") + embed.set_footer(text="This message updates every 120 seconds(ish). Last updated") - for carrier, state in carrierState.items(): - embed.add_field(name=carrier, value=state, inline=True) + for carrier, state in carrierState.items(): + embed.add_field(name=carrier, value=state, inline=True) - found = False - async for oldmsg in channel.history(limit=2): - if oldmsg.author == self.bot.user: - found = True - await oldmsg.edit(embed=embed) - break - if not found: - await channel.send(embed=embed) + found = False + async for oldmsg in channel.history(limit=2): + if oldmsg.author == self.bot.user: + found = True + await oldmsg.edit(embed=embed) + break + if not found: + await channel.send(embed=embed) + except Exception as 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 \ No newline at end of file From 26d6c393690a340962886aa4cc0fc75e1dc5b29d Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Thu, 30 Jul 2026 19:48:41 +0200 Subject: [PATCH 2/3] added catch all exception to deal with google being a pain in the ass. Will fix later --- cogs/IdaCogs.py | 146 +++++++++++++++++++++++++----------------------- 1 file changed, 76 insertions(+), 70 deletions(-) diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py index 28f27a8..0da3744 100644 --- a/cogs/IdaCogs.py +++ b/cogs/IdaCogs.py @@ -286,115 +286,121 @@ class IdaCogs(commands.Cog): #writes to the whats left to haul channel ever 60 seconds about.. the stuff left to haul. #also updates the current commodity List - @tasks.loop(seconds=60) + @tasks.loop(seconds=120) async def writeToWhatsLeftToHaul(self): + try: + response = await helpers.getFromSheet(self.session, self.gsheetToken, "commodity") - response = await helpers.getFromSheet(self.session, self.gsheetToken, "commodity") + print(response) + commodity, values, initial = response.split("|") - print(response) - commodity, values, initial = response.split("|") - - commodity = commodity.split(",") - values = values.split(",") - initial = initial.split(",") + commodity = commodity.split(",") + values = values.split(",") + initial = initial.split(",") - values = [int(i) for i in values] - initial = [int (i) for i in initial] + values = [int(i) for i in values] + initial = [int (i) for i in initial] - finalDict = {} - progressDict = {} - neededCommodity = [] + finalDict = {} + progressDict = {} + neededCommodity = [] - for i in range(len(commodity)): - finalDict[commodity[i]] = values[i] + for i in range(len(commodity)): + finalDict[commodity[i]] = values[i] - if initial[i] > 0: - progressDict[commodity[i]] = await helpers.createProgressBar(values[i],initial[i]) - else: - progressDict[commodity[i]] = await helpers.createProgressBar(1,1) + if initial[i] > 0: + progressDict[commodity[i]] = await helpers.createProgressBar(values[i],initial[i]) + else: + progressDict[commodity[i]] = await helpers.createProgressBar(1,1) - if values[i] > 0: - neededCommodity.append(commodity[i]) + if values[i] > 0: + neededCommodity.append(commodity[i]) - #finalDict = dict(sorted(finalDict.items(), key=lambda item: item[1], reverse=True)) + #finalDict = dict(sorted(finalDict.items(), key=lambda item: item[1], reverse=True)) - self.commodities = neededCommodity + self.commodities = neededCommodity - embed = discord.Embed(title="Estimated remaining amounts", - colour=discord.Colour(0xffdd55), - timestamp=datetime.now()) - embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/536647643367997492.png") + embed = discord.Embed(title="Estimated remaining amounts", + colour=discord.Colour(0xffdd55), + timestamp=datetime.now()) + embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/536647643367997492.png") - embed2 = discord.Embed(title="Current progress", - colour=discord.Colour(0x002f80), - timestamp=datetime.now()) - embed2.set_thumbnail(url="https://cdn.discordapp.com/emojis/536647643367997492.png") + embed2 = discord.Embed(title="Current progress", + colour=discord.Colour(0x002f80), + timestamp=datetime.now()) + embed2.set_thumbnail(url="https://cdn.discordapp.com/emojis/536647643367997492.png") - for key in finalDict: - if finalDict[key] > 0: - embed.add_field(name=key, value=finalDict[key], inline=True) - embed2.add_field(name=key, value=str(progressDict[key]), inline=True) + for key in finalDict: + if finalDict[key] > 0: + embed.add_field(name=key, value=finalDict[key], inline=True) + embed2.add_field(name=key, value=str(progressDict[key]), inline=True) - embed2.set_footer(text="This message updates every 60 seconds(ish). Last updated") - embed.set_author(name=u'\U0001F517 ' + self.stationName + u' \U0001F517', - url=self.stationUrl) - embed2.set_author(name=u'\U0001F517 ' + self.stationName + u' \U0001F517', - url=self.stationUrl) + embed2.set_footer(text="This message updates every 120 seconds(ish). Last updated") + embed.set_author(name=u'\U0001F517 ' + self.stationName + u' \U0001F517', + url=self.stationUrl) + embed2.set_author(name=u'\U0001F517 ' + self.stationName + u' \U0001F517', + url=self.stationUrl) - channel = self.bot.get_channel(self.whatsLeftToHaulChannelId) + channel = self.bot.get_channel(self.whatsLeftToHaulChannelId) - found = False - async for oldmsg in channel.history(limit=2): - if oldmsg.author == self.bot.user: - found = True - await oldmsg.edit(embeds=[embed, embed2]) - break - if not found: - await channel.send(embeds=[embed, embed2]) + found = False + async for oldmsg in channel.history(limit=2): + if oldmsg.author == self.bot.user: + found = True + await oldmsg.edit(embeds=[embed, embed2]) + break + if not found: + await channel.send(embeds=[embed, embed2]) + + except Exception as e: + print("Something bad happened in the whatlefttohaul function :(") #writes the carriers state to... the carrier state channel. Seriously, who is writing this? - @tasks.loop(seconds=60) + @tasks.loop(seconds=120) async def writeTocarrierState(self): - response = await helpers.getInternalCarrierState(self.session, self.gsheetToken) - carrierState = await helpers.parseCarrierState(response) + try: + response = await helpers.getInternalCarrierState(self.session, self.gsheetToken) + carrierState = await helpers.parseCarrierState(response) - channel = self.bot.get_channel(self.carrierStatsChannel) + channel = self.bot.get_channel(self.carrierStatsChannel) - embed = discord.Embed(title="Carriers State", - colour=discord.Colour(0x29ac08), - timestamp=datetime.now()) - embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/536647643367997492.png") - embed.set_author(name=u'\U0001F517 ' + self.stationName + u' \U0001F517', - url=self.stationUrl) + embed = discord.Embed(title="Carriers State", + colour=discord.Colour(0x29ac08), + timestamp=datetime.now()) + embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/536647643367997492.png") + embed.set_author(name=u'\U0001F517 ' + self.stationName + u' \U0001F517', + url=self.stationUrl) - embed.set_footer(text="This message updates every 60 seconds(ish). Last updated") + embed.set_footer(text="This message updates every 120 seconds(ish). Last updated") - for carrier, state in carrierState.items(): - embed.add_field(name=carrier, value=state, inline=True) + for carrier, state in carrierState.items(): + embed.add_field(name=carrier, value=state, inline=True) - found = False - async for oldmsg in channel.history(limit=2): - if oldmsg.author == self.bot.user: - found = True - await oldmsg.edit(embed=embed) - break - if not found: - await channel.send(embed=embed) + found = False + async for oldmsg in channel.history(limit=2): + if oldmsg.author == self.bot.user: + found = True + await oldmsg.edit(embed=embed) + break + if not found: + await channel.send(embed=embed) + except Exception as 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 \ No newline at end of file From a18978077cf136b09b8a5ccb6340de742b792db5 Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Fri, 31 Jul 2026 20:43:50 +0200 Subject: [PATCH 3/3] added debug to delivery exception --- cogs/IdaCogs.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py index 0da3744..5c57b13 100644 --- a/cogs/IdaCogs.py +++ b/cogs/IdaCogs.py @@ -3,6 +3,7 @@ from discord import option from discord.ext import commands, tasks import aiohttp import helpers +import traceback from datetime import datetime class IdaCogs(commands.Cog): @@ -112,7 +113,9 @@ class IdaCogs(commands.Cog): 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}") + 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()}") @@ -156,6 +159,7 @@ class IdaCogs(commands.Cog): + @discord.slash_command( name="last", # guild_ids=[401372086746087425],