From 08e0d41a092e2fdfad9b5381339e7f7573820f45 Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Mon, 22 Jun 2026 00:23:27 +0200 Subject: [PATCH 01/22] initial commit for automated carrier control (w/ bugs) --- main.py | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 184 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 524ba6e..032c150 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,6 @@ import discord from discord.ext import commands +from discord.commands import option import requests import json from datetime import datetime as dt @@ -15,15 +16,70 @@ def readToken(filePath): +### sends a get request to the sheet +async def getFromSheet(gsheetToken): + async with aiohttp.ClientSession() as session: + async with session.get(gsheetToken) as response: + print("Status:", response.status) + text = await response.text() + + return text + ### takes a json, returns a http code async def postToSheet(data, gsheetToken): async with aiohttp.ClientSession() as session: async with session.post(gsheetToken, json=data) as response: - # print("Status:", response.status) + text = await response.text() + print(text) + print("Status:", response.status) return response.status +### carrier state parser, takes the values from the sheet and turn it into something we can use + +async def parseCarrierState(state): + tupleList = [] + splitState = state.split(",") + + for i in range(0,len(splitState),2): + carrier = splitState[i] + state = splitState[i+1] + if carrier != "" and state != "": + tupleList.append((carrier, state)) + + return tupleList + +### converts a list of tuple back to the sheet syntax (CSV) +async def toRawState(tupleList): + rawState = [] + for value in tupleList: + for subval in value: + rawState.append([subval]) + rawLen = len(rawState) + + for i in range(rawLen, 41): + rawState.append([""]) + + return rawState + + +async def getListOfCarriers(state): + splitState = state.split(",") + carrierList = [] + for i in range(0,len(splitState),2): + carrier = splitState[i] + if carrier != "": + carrierList.append(carrier) + + return carrierList + +### used to query the carrier state internally +async def getInternalCarrierState(): + response = await getFromSheet(gsheetToken) + return response + + #creates the file if it doesn't exist. stores last command used by... users on this delivery. @@ -71,6 +127,7 @@ async def delLastCommandFile(): + bot = commands.Bot() # various tokens @@ -122,6 +179,7 @@ async def delivery(ctx, await ctx.defer() data = { + "postType":"delivery", "username":author, "commodity": commodity, "quantity": quantity, @@ -159,8 +217,9 @@ async def misc(ctx, await ctx.defer() data = { + "postType":"delivery", "username":author, - "commodity": "Miscellaneous", + "commodity": commodity, "quantity": quantity, "target": target } @@ -179,6 +238,7 @@ async def misc(ctx, + @bot.slash_command( name="last", # guild_ids=[401372086746087425], @@ -211,9 +271,6 @@ async def last(ctx): - - - #change url command @bot.slash_command( name="change-sheet-url", @@ -235,6 +292,128 @@ async def changeSheetUrl(ctx, print("deleted command.last file content") except Exception as e: await ctx.followup.send(f"something shat the bed") + + + + + + + + +@bot.slash_command( + name="getcarrierstate", + # guild_ids=[401372086746087425], + description= "gets the carriers state from the sheet" +) +async def getCarrierState(ctx): + response = await getInternalCarrierState() + carrierState = await parseCarrierState(response) + await ctx.defer() + + text = "Current Carrier State : \n" + + for carrier, state in carrierState: + text += f"{carrier} is {state}\n" + + await ctx.followup.send(text) + + +async def getCarriers(ctx: discord.AutocompleteContext): + state = await getInternalCarrierState() + carrierList = await getListOfCarriers(state) + # print(carrierList) + # return [carrier for carriers in carrierList] + return carrierList + + +@bot.slash_command( + name="setcarrierstate", + # guild_ids=[401372086746087425], + description= "Sets a carrier state on the sheet" +) +@option("carrier", description="The carrier you want to edit", autocomplete=getCarriers) +@option("state",required=True, description="The carrier you want to edit", choices=["Loading","Unloading","Full","Empty","Inactive"]) +async def setCarrierState(ctx, carrier, state): + response = await getFromSheet(gsheetToken) + carrierState = await parseCarrierState(response) + + newCarrierState = [] + + print(f"requested values: {carrier} to {state}") + + print(f"current values : {carrierState}") + + for carrierS, stateS in carrierState: + if carrier == carrierS: + newCarrierState.append((carrier,state)) + else: + newCarrierState.append((carrierS,stateS)) + + print(f"new values : {newCarrierState}") + + rawState = await toRawState(newCarrierState) + + print(rawState) + + await ctx.defer() + i = 1 + text = "Current Carrier State : \n" + + + data = { + "postType":"carrier", + "carrierState": rawState + + } + + + try: + response = await postToSheet(data, gsheetToken) + if response == 200: + await ctx.followup.send(f"hey") + else: + await ctx.followup.send(f"i fucked up ") + except Exception as e: + await ctx.followup.send(f"help : Error: {e}") + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.20.1 From 8aa61a109e84a2cfb7391949f7fc31d0fd417e87 Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Thu, 25 Jun 2026 00:32:09 +0200 Subject: [PATCH 02/22] added bugs, lefttohaul, revamped http get, many more things that will break in fun ways --- main.py | 126 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 108 insertions(+), 18 deletions(-) diff --git a/main.py b/main.py index 032c150..d1756fe 100644 --- a/main.py +++ b/main.py @@ -1,12 +1,13 @@ import discord -from discord.ext import commands +from discord.ext import commands, tasks from discord.commands import option import requests import json -from datetime import datetime as dt +from datetime import datetime import aiohttp import os import asyncio +from math import floor ### reads token files @@ -17,23 +18,24 @@ def readToken(filePath): ### sends a get request to the sheet -async def getFromSheet(gsheetToken): - async with aiohttp.ClientSession() as session: - async with session.get(gsheetToken) as response: - print("Status:", response.status) - text = await response.text() +async def getFromSheet(gsheetToken, data): - return text + params = {"type":data} + print(params) + async with session.get(gsheetToken, params=params) as response: + print("Status:", response.status) + text = await response.text() + print(text) + return text ### takes a json, returns a http code async def postToSheet(data, gsheetToken): - async with aiohttp.ClientSession() as session: - async with session.post(gsheetToken, json=data) as response: - text = await response.text() - print(text) - print("Status:", response.status) - return response.status + async with session.post(gsheetToken, json=data) as response: + text = await response.text() + print(text) + print("Status:", response.status) + return response.status ### carrier state parser, takes the values from the sheet and turn it into something we can use @@ -76,7 +78,7 @@ async def getListOfCarriers(state): ### used to query the carrier state internally async def getInternalCarrierState(): - response = await getFromSheet(gsheetToken) + response = await getFromSheet(gsheetToken, "carrier") return response @@ -135,10 +137,21 @@ discordToken = readToken("discord.token") gsheetToken = readToken("sheet.token") lastCommandFile = "command.last" + + # default command to see if the bot has lived @bot.listen() async def on_connect(): + global session print("I'm alive, bitch") + session = aiohttp.ClientSession() + +@bot.event +async def on_ready(): + print("I'm ready, bitch") + writeToWhatsLeftToHaul.start() + + # delivery command # guild IDs are both IDA servers @@ -190,7 +203,7 @@ async def delivery(ctx, response = await postToSheet(data, 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"[{dt.isoformat(dt.now())}]{author} delivery of {quantity} of {commodity} to a {target}") + print(f"[{datetime.isoformat(datetime.now())}]{author} delivery of {quantity} of {commodity} 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") @@ -228,7 +241,7 @@ async def misc(ctx, 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}") + print(f"[{datetime.isoformat(datetime.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") @@ -259,7 +272,7 @@ async def last(ctx): response = await postToSheet(data, gsheetToken) if response == 200: await ctx.followup.send(f"your delivery of {data['quantity']} of {data['commodity']} to a {data['target']} has been added to the sheet!") - print(f"[{dt.isoformat(dt.now())}] delivery of {data['quantity']} of {data['commodity']} to a {data['target']}") + print(f"[{datetime.isoformat(datetime.now())}] delivery of {data['quantity']} of {data['commodity']} to a {data['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") @@ -383,9 +396,86 @@ async def setCarrierState(ctx, carrier, state): +@bot.slash_command( + name="lefttohaul", + # guild_ids=[401372086746087425], + description= "gets the what's left to haul from the sheet" +) +async def lefttohaul(ctx): + response = await getFromSheet(gsheetToken, "commodity") + + await ctx.defer() + + text = "\n\n\n### Here's what's left to haul! Get to work!\n" + + commodity, values = response.split("|") + + commodity = commodity.split(",") + values = values.split(",") + finalDict = {} + + for i in range(len(commodity)): + finalDict[commodity[i]] = int(values[i]) + + finalDict = dict(sorted(finalDict.items(), key=lambda item: item[1], reverse=True)) + + + for key in finalDict: + if finalDict[key] > 0: + text += f"{key} : {finalDict[key]}\n" + + await ctx.followup.send(text) +@tasks.loop(seconds=60) +async def writeToWhatsLeftToHaul(): + response = await getFromSheet(gsheetToken, "commodity") + print("test") + text = "```" + + commodity, values = response.split("|") + + commodity = commodity.split(",") + values = values.split(",") + finalDict = {} + + for i in range(len(commodity)): + finalDict[commodity[i]] = int(values[i]) + + finalDict = dict(sorted(finalDict.items(), key=lambda item: item[1], reverse=True)) + + + for key in finalDict: + if finalDict[key] > 0: + text += f"{key} : {finalDict[key]}\n" + + channel = bot.get_channel(1519457137234022460) + # await channel.purge(limit=1) + + text += "```" + + embed = discord.Embed(title="Estimated remaining amounts and where to get them", + colour=discord.Colour(0x29ac08), + description=text, + timestamp=datetime.now()) + embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/536647643367997492.png") + + embed.set_footer(text="This message updates every 60 seconds(ish). Last updated at") + # if 'station_name' in config.config and 'station_link' in config.config: + # embed.set_author(name=u'\U0001F517 ' + config.config['station_name'] + u' \U0001F517', + # url=config.config['station_link']) + + + channel = bot.get_channel(1519457137234022460) + found = False + async for oldmsg in channel.history(limit=2): + if oldmsg.author == bot.user: + found = True + await oldmsg.edit(embed=embed) + break + if not found: + await channel.send(embed=embed) -- 2.20.1 From 3415b38e4ed33beb39932784a62bbd6fea0d0233 Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Mon, 29 Jun 2026 23:47:18 +0200 Subject: [PATCH 03/22] tested new way to present left to haul data. --- main.py | 65 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/main.py b/main.py index d1756fe..cfb5b5b 100644 --- a/main.py +++ b/main.py @@ -81,6 +81,16 @@ async def getInternalCarrierState(): response = await getFromSheet(gsheetToken, "carrier") return response +###creates a nice progress bar from two values +async def createProgressBar(a,b): + print(a, b) + ratio = floor(((b-a)/b) * 10) + + print(ratio) + + progressBar = f"{'⣿'* ratio}{'.'*(10-ratio)} ({ratio*10}%)" + + return progressBar @@ -232,7 +242,7 @@ async def misc(ctx, data = { "postType":"delivery", "username":author, - "commodity": commodity, + "commodity": "Misc", "quantity": quantity, "target": target } @@ -431,37 +441,56 @@ async def lefttohaul(ctx): @tasks.loop(seconds=60) async def writeToWhatsLeftToHaul(): response = await getFromSheet(gsheetToken, "commodity") - print("test") - text = "```" - commodity, values = response.split("|") + + commodity, values, initial = response.split("|") commodity = commodity.split(",") values = values.split(",") + initial = initial.split(",") + + values = [int(i) for i in values] + initial = [int (i) for i in initial] + + print(values, initial) + finalDict = {} + progressDict = {} for i in range(len(commodity)): - finalDict[commodity[i]] = int(values[i]) + finalDict[commodity[i]] = values[i] + if initial[i] > 0: + progressDict[commodity[i]] = await createProgressBar(values[i],initial[i]) + else: + progressDict[commodity[i]] = await createProgressBar(1,1) - finalDict = dict(sorted(finalDict.items(), key=lambda item: item[1], reverse=True)) + #finalDict = dict(sorted(finalDict.items(), key=lambda item: item[1], reverse=True)) - - for key in finalDict: - if finalDict[key] > 0: - text += f"{key} : {finalDict[key]}\n" + print(progressDict) channel = bot.get_channel(1519457137234022460) # await channel.purge(limit=1) - text += "```" - embed = discord.Embed(title="Estimated remaining amounts and where to get them", - colour=discord.Colour(0x29ac08), - description=text, - timestamp=datetime.now()) + + embed = discord.Embed(title="Estimated remaining amounts", + colour=discord.Colour(0x29ac08), + timestamp=datetime.now()) embed.set_thumbnail(url="https://cdn.discordapp.com/emojis/536647643367997492.png") - embed.set_footer(text="This message updates every 60 seconds(ish). Last updated at") + embed2 = discord.Embed(title="Current progress", + colour=discord.Colour(0x29ac08), + 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) + + + embed.set_footer(text="This message updates every 60 seconds(ish). Last updated") # if 'station_name' in config.config and 'station_link' in config.config: # embed.set_author(name=u'\U0001F517 ' + config.config['station_name'] + u' \U0001F517', # url=config.config['station_link']) @@ -472,10 +501,10 @@ async def writeToWhatsLeftToHaul(): async for oldmsg in channel.history(limit=2): if oldmsg.author == bot.user: found = True - await oldmsg.edit(embed=embed) + await oldmsg.edit(embeds=[embed, embed2]) break if not found: - await channel.send(embed=embed) + await channel.send(embeds=[embed, embed2]) -- 2.20.1 From 744fcb6ce7917d1602fea78b19e13125b0d308f5 Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Tue, 30 Jun 2026 21:49:21 +0200 Subject: [PATCH 04/22] carrier state & left to haul state now live in tasks. added bugs. Removed Herobrine. --- .gitignore | 4 ++ main.py | 188 +++++++++++++++++++++++++++-------------------------- 2 files changed, 99 insertions(+), 93 deletions(-) diff --git a/.gitignore b/.gitignore index 0031b90..e671378 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,10 @@ *.token # Last file *.last +# name and url files. not dangerous to share, but not needed. +*.name +*.url + # ---> Python # Byte-compiled / optimized / DLL files diff --git a/main.py b/main.py index cfb5b5b..0032d33 100644 --- a/main.py +++ b/main.py @@ -21,11 +21,11 @@ def readToken(filePath): async def getFromSheet(gsheetToken, data): params = {"type":data} - print(params) + #print(params) async with session.get(gsheetToken, params=params) as response: - print("Status:", response.status) + #print("Status:", response.status) text = await response.text() - print(text) + #print(text) return text @@ -33,8 +33,8 @@ async def getFromSheet(gsheetToken, data): async def postToSheet(data, gsheetToken): async with session.post(gsheetToken, json=data) as response: text = await response.text() - print(text) - print("Status:", response.status) + #print(text) + #print("Status:", response.status) return response.status @@ -76,19 +76,28 @@ async def getListOfCarriers(state): return carrierList -### used to query the carrier state internally +### used to query the carrier state internally. Why did I make this???? async def getInternalCarrierState(): response = await getFromSheet(gsheetToken, "carrier") return response +async def getCarriers(ctx: discord.AutocompleteContext): + state = await getInternalCarrierState() + carrierList = await getListOfCarriers(state) + # print(carrierList) + # return [carrier for carriers in carrierList] + return carrierList + + + ###creates a nice progress bar from two values async def createProgressBar(a,b): - print(a, b) + #print(a, b) ratio = floor(((b-a)/b) * 10) - print(ratio) + #print(ratio) - progressBar = f"{'⣿'* ratio}{'.'*(10-ratio)} ({ratio*10}%)" + progressBar = f"{'◼'* ratio}{'◻'*(10-ratio)} {ratio*10}%" return progressBar @@ -138,16 +147,27 @@ async def delLastCommandFile(): open(lastCommandFile, 'w').close() - - bot = commands.Bot() -# various tokens +# various tokens and global vars discordToken = readToken("discord.token") gsheetToken = readToken("sheet.token") lastCommandFile = "command.last" +#there's a small chance the files don't exist. If they don't we create an empty file. +try: + with open("station.name", 'r') as f: + stationName = f.readline() +except FileNotFoundError: + open("station.name", 'w').close() + stationName = "REPLACEME" +try: + with open("station.url",'r') as f: + stationUrl = f.readline() +except FileNotFoundError: + open("station.url", 'w').close() + stationUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ" # default command to see if the bot has lived @bot.listen() @@ -160,6 +180,7 @@ async def on_connect(): async def on_ready(): print("I'm ready, bitch") writeToWhatsLeftToHaul.start() + writeTocarrierState.start() @@ -304,6 +325,8 @@ async def changeSheetUrl(ctx, url:discord.Option(discord.SlashCommandOptionType.string, description="the new URL") ): global gsheetToken + global stationName + global stationURL await ctx.defer() try: with open("sheet.token",'w') as f: @@ -313,6 +336,20 @@ async def changeSheetUrl(ctx, gsheetToken = readToken("sheet.token") await delLastCommandFile() print("deleted command.last file content") + + # gets the name and URL from the sheet, then store it in a file so we don't ask the sheet again. + name, url = (await getFromSheet(gsheetToken, "sheet")).split("|") + + with open("station.name", 'w') as f: + f.write(name) + stationName = name + + with open("station.url", 'w') as f: + f.write(url) + stationURL = url + + writeToWhatsLeftToHaul.restart() + except Exception as e: await ctx.followup.send(f"something shat the bed") @@ -322,33 +359,6 @@ async def changeSheetUrl(ctx, - -@bot.slash_command( - name="getcarrierstate", - # guild_ids=[401372086746087425], - description= "gets the carriers state from the sheet" -) -async def getCarrierState(ctx): - response = await getInternalCarrierState() - carrierState = await parseCarrierState(response) - await ctx.defer() - - text = "Current Carrier State : \n" - - for carrier, state in carrierState: - text += f"{carrier} is {state}\n" - - await ctx.followup.send(text) - - -async def getCarriers(ctx: discord.AutocompleteContext): - state = await getInternalCarrierState() - carrierList = await getListOfCarriers(state) - # print(carrierList) - # return [carrier for carriers in carrierList] - return carrierList - - @bot.slash_command( name="setcarrierstate", # guild_ids=[401372086746087425], @@ -357,14 +367,15 @@ async def getCarriers(ctx: discord.AutocompleteContext): @option("carrier", description="The carrier you want to edit", autocomplete=getCarriers) @option("state",required=True, description="The carrier you want to edit", choices=["Loading","Unloading","Full","Empty","Inactive"]) async def setCarrierState(ctx, carrier, state): - response = await getFromSheet(gsheetToken) + response = await getFromSheet(gsheetToken, "carrier") carrierState = await parseCarrierState(response) + author = str(ctx.author) newCarrierState = [] - print(f"requested values: {carrier} to {state}") + #print(f"requested values: {carrier} to {state}") - print(f"current values : {carrierState}") + #print(f"current values : {carrierState}") for carrierS, stateS in carrierState: if carrier == carrierS: @@ -372,11 +383,11 @@ async def setCarrierState(ctx, carrier, state): else: newCarrierState.append((carrierS,stateS)) - print(f"new values : {newCarrierState}") + #print(f"new values : {newCarrierState}") rawState = await toRawState(newCarrierState) - print(rawState) + #print(rawState) await ctx.defer() i = 1 @@ -386,58 +397,21 @@ async def setCarrierState(ctx, carrier, state): data = { "postType":"carrier", "carrierState": rawState - } try: response = await postToSheet(data, gsheetToken) if response == 200: - await ctx.followup.send(f"hey") + await ctx.followup.send(f"The carrier {carrier} has been set to {state}") + print(f"{author} set {carrier} state to {state}") else: await ctx.followup.send(f"i fucked up ") except Exception as e: await ctx.followup.send(f"help : Error: {e}") - - - - - - -@bot.slash_command( - name="lefttohaul", - # guild_ids=[401372086746087425], - description= "gets the what's left to haul from the sheet" -) -async def lefttohaul(ctx): - response = await getFromSheet(gsheetToken, "commodity") - - await ctx.defer() - - text = "\n\n\n### Here's what's left to haul! Get to work!\n" - - commodity, values = response.split("|") - - commodity = commodity.split(",") - values = values.split(",") - finalDict = {} - - for i in range(len(commodity)): - finalDict[commodity[i]] = int(values[i]) - - finalDict = dict(sorted(finalDict.items(), key=lambda item: item[1], reverse=True)) - - - for key in finalDict: - if finalDict[key] > 0: - text += f"{key} : {finalDict[key]}\n" - - await ctx.followup.send(text) - - - +#writes to the whats left to haul channel ever 60 seconds about.. the stuff left to haul. @tasks.loop(seconds=60) async def writeToWhatsLeftToHaul(): response = await getFromSheet(gsheetToken, "commodity") @@ -452,7 +426,6 @@ async def writeToWhatsLeftToHaul(): values = [int(i) for i in values] initial = [int (i) for i in initial] - print(values, initial) finalDict = {} progressDict = {} @@ -466,7 +439,6 @@ async def writeToWhatsLeftToHaul(): #finalDict = dict(sorted(finalDict.items(), key=lambda item: item[1], reverse=True)) - print(progressDict) channel = bot.get_channel(1519457137234022460) # await channel.purge(limit=1) @@ -474,12 +446,12 @@ async def writeToWhatsLeftToHaul(): embed = discord.Embed(title="Estimated remaining amounts", - colour=discord.Colour(0x29ac08), - timestamp=datetime.now()) + 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(0x29ac08), + colour=discord.Colour(0x002f80), timestamp=datetime.now()) embed2.set_thumbnail(url="https://cdn.discordapp.com/emojis/536647643367997492.png") @@ -490,10 +462,11 @@ async def writeToWhatsLeftToHaul(): embed2.add_field(name=key, value=str(progressDict[key]), inline=True) - embed.set_footer(text="This message updates every 60 seconds(ish). Last updated") - # if 'station_name' in config.config and 'station_link' in config.config: - # embed.set_author(name=u'\U0001F517 ' + config.config['station_name'] + u' \U0001F517', - # url=config.config['station_link']) + embed2.set_footer(text="This message updates every 60 seconds(ish). Last updated") + embed.set_author(name=u'\U0001F517 ' + stationName + u' \U0001F517', + url=stationUrl) + embed2.set_author(name=u'\U0001F517 ' + stationName + u' \U0001F517', + url=stationUrl) channel = bot.get_channel(1519457137234022460) @@ -510,8 +483,37 @@ async def writeToWhatsLeftToHaul(): +#writes the carriers state to... the carrier state channel. Seriously, who is writing this? +@tasks.loop(seconds=60) +async def writeTocarrierState(): + response = await getInternalCarrierState() + carrierState = await parseCarrierState(response) + channel = bot.get_channel(1521596285981819101) + + 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 ' + stationName + u' \U0001F517', + url=stationUrl) + + embed.set_footer(text="This message updates every 60 seconds(ish). Last updated") + + for carrier, state in carrierState: + embed.add_field(name=carrier, value=state, inline=True) + + + found = False + async for oldmsg in channel.history(limit=2): + if oldmsg.author == bot.user: + found = True + await oldmsg.edit(embed=embed) + break + if not found: + await channel.send(embed=embed) + -- 2.20.1 From a8d3795fdc496bb241327c02950c53247c18152a Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Wed, 1 Jul 2026 21:36:48 +0200 Subject: [PATCH 05/22] changed delivery to only show still needed commodities --- main.py | 66 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/main.py b/main.py index 0032d33..7be78f3 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,6 @@ +from idlelib import autocomplete +from random import choices + import discord from discord.ext import commands, tasks from discord.commands import option @@ -7,6 +10,7 @@ from datetime import datetime import aiohttp import os import asyncio +import ast from math import floor @@ -89,6 +93,11 @@ async def getCarriers(ctx: discord.AutocompleteContext): return carrierList +async def getCommodities(ctx: discord.AutocompleteContext): + with open("commodity.needed","r") as f: + listOfCommodities = ast.literal_eval(f.readline()) + return listOfCommodities + ###creates a nice progress bar from two values async def createProgressBar(a,b): @@ -154,6 +163,10 @@ discordToken = readToken("discord.token") gsheetToken = readToken("sheet.token") lastCommandFile = "command.last" +print("hey wassup") + + + #there's a small chance the files don't exist. If they don't we create an empty file. try: with open("station.name", 'r') as f: @@ -176,12 +189,14 @@ async def on_connect(): print("I'm alive, bitch") session = aiohttp.ClientSession() + @bot.event async def on_ready(): - print("I'm ready, bitch") writeToWhatsLeftToHaul.start() writeTocarrierState.start() + print("I'm ready, bitch") + # delivery command @@ -191,31 +206,17 @@ async def on_ready(): # guild_ids=[401372086746087425], description= "sends your delivery to the bot!" ) -async def delivery(ctx, - commodity:discord.Option(str, 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" - ]), - 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']) - ): +@option("commodity",required=True, + description="The Commodity you want to deliver", + autocomplete=getCommodities) +@option("quantity",required=True, + description="Please be nice and input a value between 1 and 1326 (new rack update!!!!1!1)", + type=int, min_value=1, max_value=1326) +@option("target", required=True, + description="Are you delivering to a carrier or the target station?", + type=str, choices=['Station', 'Carrier']) + +async def delivery(ctx,commodity, quantity,target): author = str(ctx.author) author = author[:author.find(" ")] @@ -411,9 +412,15 @@ async def setCarrierState(ctx, carrier, state): await ctx.followup.send(f"help : Error: {e}") + + + #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) async def writeToWhatsLeftToHaul(): + + response = await getFromSheet(gsheetToken, "commodity") @@ -423,22 +430,29 @@ async def writeToWhatsLeftToHaul(): values = values.split(",") initial = initial.split(",") + + values = [int(i) for i in values] initial = [int (i) for i in initial] finalDict = {} progressDict = {} + neededCommodity = [] for i in range(len(commodity)): finalDict[commodity[i]] = values[i] if initial[i] > 0: progressDict[commodity[i]] = await createProgressBar(values[i],initial[i]) + neededCommodity.append(commodity[i]) else: progressDict[commodity[i]] = await createProgressBar(1,1) #finalDict = dict(sorted(finalDict.items(), key=lambda item: item[1], reverse=True)) + with open("commodity.needed",'w') as f: + f.write(str(neededCommodity)) + print("values set") channel = bot.get_channel(1519457137234022460) # await channel.purge(limit=1) -- 2.20.1 From f175fa90ba2691134e9a22eb588db90ae426fd61 Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Wed, 1 Jul 2026 21:38:58 +0200 Subject: [PATCH 06/22] removed useless imports --- main.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/main.py b/main.py index 7be78f3..b2e7101 100644 --- a/main.py +++ b/main.py @@ -1,10 +1,8 @@ -from idlelib import autocomplete -from random import choices + import discord from discord.ext import commands, tasks from discord.commands import option -import requests import json from datetime import datetime import aiohttp -- 2.20.1 From d23b49a77ec68f4f6100a9c7658e41ba3b493fa5 Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Wed, 1 Jul 2026 21:43:03 +0200 Subject: [PATCH 07/22] added logger for bot to discord --- main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.py b/main.py index b2e7101..bf47dc8 100644 --- a/main.py +++ b/main.py @@ -404,6 +404,9 @@ async def setCarrierState(ctx, carrier, state): if response == 200: await ctx.followup.send(f"The carrier {carrier} has been set to {state}") print(f"{author} set {carrier} state to {state}") + channel = bot.get_channel(1521963883018063882) + await channel.send(f"{author} set {carrier} state to {state}") + else: await ctx.followup.send(f"i fucked up ") except Exception as e: -- 2.20.1 From b204a67eea59b9a1b2a6bf2e5b31c6e4fd903a80 Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Thu, 2 Jul 2026 00:19:21 +0200 Subject: [PATCH 08/22] refactored code into cogs for clarity and ease of use (and more bugs) --- cogs/IdaCogs.py | 358 +++++++++++++++++++++++++++++++ helpers.py | 164 ++++++++++++++ main.py | 552 ++---------------------------------------------- 3 files changed, 535 insertions(+), 539 deletions(-) create mode 100644 cogs/IdaCogs.py create mode 100644 helpers.py diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py new file mode 100644 index 0000000..69df569 --- /dev/null +++ b/cogs/IdaCogs.py @@ -0,0 +1,358 @@ +import discord +from discord import option +from discord.ext import commands, tasks +import aiohttp +import helpers +from datetime import datetime + +class IdaCogs(commands.Cog): + def __init__(self, bot): + self.bot = bot + self.commodities = [] + self.session = None + self.gsheetToken = helpers.readToken("sheet.token") + self.stationName = helpers.getStationName() + self.stationUrl = helpers.getStationUrl() + + + + print("help") + + @commands.Cog.listener() + async def on_ready(self): + self.session = aiohttp.ClientSession() + self.writeToWhatsLeftToHaul.start() + self.writeTocarrierState.start() + print("I'm ready, cog bitch") + + + + + #auto complete + async def getCarriers(self, ctx: discord.AutocompleteContext): + state = await helpers.getInternalCarrierState(self.session, self.gsheetToken) + carrierList = await helpers.getListOfCarriers(state) + # print(carrierList) + # return [carrier for carriers in carrierList] + return carrierList + + async def getCommodities(self, ctx: discord.AutocompleteContext): + return [commodity for commodity in self.commodities if commodity.lower().startswith(ctx.value.lower())] + + + + # delivery command + # guild IDs are both IDA servers + @discord.slash_command( + name="delivery", + # guild_ids=[401372086746087425], + description= "sends your delivery to the bot!" + ) + @option("commodity",required=True, + description="The Commodity you want to deliver", + autocomplete=getCommodities) + @option("quantity",required=True, + description="Please be nice and input a value between 1 and 1326 (new rack update!!!!1!1)", + type=int, min_value=1, max_value=1326) + @option("target", required=True, + description="Are you delivering to a carrier or the target station?", + type=str, choices=['Station', 'Carrier']) + + async def delivery(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"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}") + + + + # delivery command for misc commodity only + # guild IDs are both IDA servers + @discord.slash_command( + name="misc", + # guild_ids=[401372086746087425], + description= "Used for the commodities we're too lazy to create a sheet for" + ) + async def misc(self, 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 = { + "postType":"delivery", + "username":author, + "commodity": "Misc", + "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 Miscellaneous stuff to a {target} has been added to the sheet!") + 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"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}") + + + + + + @discord.slash_command( + name="last", + # guild_ids=[401372086746087425], + description= "send the last delivery you made again!" + ) + async def last(self, ctx): + + author = str(ctx.author) + author = author[:author.find(" ")] + + data = await helpers.getDataFromDeliveryFile(author) + + await ctx.defer() + + + if data is not None: + try: + response = await helpers.postToSheet(self.session, data, self.gsheetToken) + if response == 200: + await ctx.followup.send(f"your delivery of {data['quantity']} of {data['commodity']} to a {data['target']} has been added to the sheet!") + 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"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: + await ctx.followup.send(f"You haven't delivered to this build yet, or I have amnesia.") + + + + + #change url command + @discord.slash_command( + name="change-sheet-url", + # guild_ids=[401372086746087425], + description= "changes the URL of the active sheet, use with caution" + ) + async def changeSheetUrl(self, ctx, + url:discord.Option(discord.SlashCommandOptionType.string, description="the new URL") + ): + + await ctx.defer() + try: + with open("../sheet.token", 'w') as f: + f.write(url) + + await ctx.followup.send(f"URL has been set to {url}") + self.gsheetToken = helpers.readToken("../sheet.token") + await helpers.delLastCommandFile() + print("deleted command.last file content") + + # gets the name and URL from the sheet, then store it in a file so we don't ask the sheet again. + name, url = (await helpers.getFromSheet(self.gsheetToken, "sheet")).split("|") + + with open("../station.name", 'w') as f: + f.write(name) + self.stationName = name + + with open("../station.url", 'w') as f: + f.write(url) + self.stationUrl = url + + self.writeToWhatsLeftToHaul.restart() + + except Exception as e: + await ctx.followup.send(f"something shat the bed") + + + + + @discord.slash_command( + name="setcarrierstate", + # guild_ids=[401372086746087425], + description= "Sets a carrier state on the sheet" + ) + @option("carrier", description="The carrier you want to edit", autocomplete=getCarriers) + @option("state",required=True, description="The carrier you want to edit", choices=["Loading","Unloading","Full","Empty","Inactive"]) + async def setCarrierState(self, ctx, carrier, state): + response = await helpers.getFromSheet(self.session, self.gsheetToken, "carrier") + + #transforms the response into a dict (carrier : state) we can use + carrierState = await helpers.parseCarrierState(response) + author = str(ctx.author) + + carrierState[carrier] = state + + rawState = await helpers.toRawState(carrierState) + + #print(rawState) + + await ctx.defer() + i = 1 + text = "Current Carrier State : \n" + + + data = { + "postType":"carrier", + "carrierState": rawState + } + + + try: + response = await helpers.postToSheet(self.session, data, self.gsheetToken) + if response == 200: + await ctx.followup.send(f"The carrier {carrier} has been set to {state}") + print(f"{author} set {carrier} state to {state}") + channel = self.bot.get_channel(1521963883018063882) + await channel.send(f"{author} set {carrier} state to {state}") + + else: + await ctx.followup.send(f"i fucked up ") + except Exception as e: + await ctx.followup.send(f"help : Error: {e}") + + + + + + #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) + async def writeToWhatsLeftToHaul(self): + + + response = await helpers.getFromSheet(self.session, self.gsheetToken, "commodity") + + + commodity, values, initial = response.split("|") + + commodity = commodity.split(",") + values = values.split(",") + initial = initial.split(",") + + + + values = [int(i) for i in values] + initial = [int (i) for i in initial] + + + finalDict = {} + progressDict = {} + neededCommodity = [] + + + 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]) + neededCommodity.append(commodity[i]) + else: + progressDict[commodity[i]] = await helpers.createProgressBar(1,1) + + #finalDict = dict(sorted(finalDict.items(), key=lambda item: item[1], reverse=True)) + + 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") + + 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) + + + 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) + + + channel = self.bot.get_channel(1519457137234022460) + + 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]) + + + + + + #writes the carriers state to... the carrier state channel. Seriously, who is writing this? + @tasks.loop(seconds=60) + async def writeTocarrierState(self): + response = await helpers.getInternalCarrierState(self.session, self.gsheetToken) + carrierState = await helpers.parseCarrierState(response) + + + channel = self.bot.get_channel(1521596285981819101) + + 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") + + 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) + +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 diff --git a/helpers.py b/helpers.py new file mode 100644 index 0000000..51ffc5c --- /dev/null +++ b/helpers.py @@ -0,0 +1,164 @@ +import json +import os +import ast +from math import floor + +import discord + + +lastCommandFile = "command.last" + +### reads token files +def readToken(filePath): + with open(filePath, 'r') as f: + return f.readline() + + +def getStationName(): + #there's a small chance the files don't exist. If they don't we create an empty file. + try: + with open("station.name", 'r') as f: + return f.readline() + except FileNotFoundError: + open("station.name", 'w').close() + return "REPLACEME" + +def getStationUrl(): + try: + with open("station.url",'r') as f: + return f.readline() + except FileNotFoundError: + open("station.url", 'w').close() + return "https://www.youtube.com/watch?v=dQw4w9WgXcQ" + + +### sends a get request to the sheet +async def getFromSheet(session, gsheetToken, data): + + params = {"type":data} + + async with session.get(gsheetToken, params=params) as response: + #print("Status:", response.status) + text = await response.text() + #print(text) + return text + + +### takes a json, returns a http code +async def postToSheet(session, data, gsheetToken): + async with session.post(gsheetToken, json=data) as response: + text = await response.text() + #print(text) + #print("Status:", response.status) + return response.status + + +### carrier state parser, takes the values from the sheet and turn it into something we can use + +async def parseCarrierState(state): + splitState = state.split(",") + + carrierDict = {} + + for i in range(0,len(splitState),2): + carrier = splitState[i] + state = splitState[i+1] + if carrier != "" and state != "": + carrierDict[carrier] = state + + return carrierDict + +### converts a dict to the sheet syntax (CSV) +async def toRawState(carrierDict :dict[str, str]): + + rawState = [] + + for key,value in carrierDict.items(): + rawState.append([key]) + rawState.append([value]) + + rawLen = len(rawState) + + for i in range(rawLen, 41): + rawState.append([""]) + + return rawState + + +async def getListOfCarriers(state): + splitState = state.split(",") + carrierList = [] + for i in range(0,len(splitState),2): + carrier = splitState[i] + if carrier != "": + carrierList.append(carrier) + + return carrierList + +### used to query the carrier state internally. Why did I make this???? +async def getInternalCarrierState(session, gsheetToken): + response = await getFromSheet(session, gsheetToken, "carrier") + return response + + + + +###creates a nice progress bar from two values +async def createProgressBar(a,b): + #print(a, b) + ratio = floor(((b-a)/b) * 10) + + #print(ratio) + + progressBar = f"{'◼'* ratio}{'◻'*(10-ratio)} {ratio*10}%" + + return progressBar + + + +#creates the file if it doesn't exist. stores last command used by... users on this delivery. +async def writeDeliveryToCommandFile(author, command): + + #shitty hack to see if the file is empty + path = os.getcwd() + "/" + lastCommandFile + empty = os.stat(path).st_size < 1 + + with open(lastCommandFile, 'r') as f: + if empty: + jsonContent = json.loads("{}") + + else: + jsonContent = json.load(f) + + + + with open(lastCommandFile, 'w') as f: + jsonContent[author] = command + json.dump(jsonContent, f) + +async def getDataFromDeliveryFile(author): + path = os.getcwd() + "/" + lastCommandFile + empty = os.stat(path).st_size < 1 + + with open(lastCommandFile, 'r') as f: + if empty: + return None + + else: + jsonContent = json.load(f) + if author in jsonContent.keys(): + return jsonContent[author] + + else: + return None + + + + + +async def delLastCommandFile(): + open(lastCommandFile, 'w').close() + + + + diff --git a/main.py b/main.py index bf47dc8..fb69cf4 100644 --- a/main.py +++ b/main.py @@ -1,558 +1,32 @@ +from discord.ext import commands - -import discord -from discord.ext import commands, tasks -from discord.commands import option -import json -from datetime import datetime -import aiohttp -import os -import asyncio -import ast -from math import floor - - -### reads token files -def readToken(filePath): - with open(filePath, 'r') as f: - return f.readline() - - - -### sends a get request to the sheet -async def getFromSheet(gsheetToken, data): - - params = {"type":data} - #print(params) - async with session.get(gsheetToken, params=params) as response: - #print("Status:", response.status) - text = await response.text() - #print(text) - return text - - -### takes a json, returns a http code -async def postToSheet(data, gsheetToken): - async with session.post(gsheetToken, json=data) as response: - text = await response.text() - #print(text) - #print("Status:", response.status) - return response.status - - -### carrier state parser, takes the values from the sheet and turn it into something we can use - -async def parseCarrierState(state): - tupleList = [] - splitState = state.split(",") - - for i in range(0,len(splitState),2): - carrier = splitState[i] - state = splitState[i+1] - if carrier != "" and state != "": - tupleList.append((carrier, state)) - - return tupleList - -### converts a list of tuple back to the sheet syntax (CSV) -async def toRawState(tupleList): - rawState = [] - for value in tupleList: - for subval in value: - rawState.append([subval]) - rawLen = len(rawState) - - for i in range(rawLen, 41): - rawState.append([""]) - - return rawState - - -async def getListOfCarriers(state): - splitState = state.split(",") - carrierList = [] - for i in range(0,len(splitState),2): - carrier = splitState[i] - if carrier != "": - carrierList.append(carrier) - - return carrierList - -### used to query the carrier state internally. Why did I make this???? -async def getInternalCarrierState(): - response = await getFromSheet(gsheetToken, "carrier") - return response - -async def getCarriers(ctx: discord.AutocompleteContext): - state = await getInternalCarrierState() - carrierList = await getListOfCarriers(state) - # print(carrierList) - # return [carrier for carriers in carrierList] - return carrierList - - -async def getCommodities(ctx: discord.AutocompleteContext): - with open("commodity.needed","r") as f: - listOfCommodities = ast.literal_eval(f.readline()) - return listOfCommodities - - -###creates a nice progress bar from two values -async def createProgressBar(a,b): - #print(a, b) - ratio = floor(((b-a)/b) * 10) - - #print(ratio) - - progressBar = f"{'◼'* ratio}{'◻'*(10-ratio)} {ratio*10}%" - - return progressBar - - - -#creates the file if it doesn't exist. stores last command used by... users on this delivery. -async def writeDeliveryToCommandFile(author, command): - - #shitty hack to see if the file is empty - path = os.getcwd() + "/" + lastCommandFile - empty = os.stat(path).st_size < 1 - - with open(lastCommandFile, 'r') as f: - if empty: - jsonContent = json.loads("{}") - - else: - jsonContent = json.load(f) - - - - with open(lastCommandFile, 'w') as f: - jsonContent[author] = command - json.dump(jsonContent, f) - -async def getDataFromDeliveryFile(author): - path = os.getcwd() + "/" + lastCommandFile - empty = os.stat(path).st_size < 1 - - with open(lastCommandFile, 'r') as f: - if empty: - return None - - else: - jsonContent = json.load(f) - if author in jsonContent.keys(): - return jsonContent[author] - - else: - return None - - - - - -async def delLastCommandFile(): - open(lastCommandFile, 'w').close() - +import helpers bot = commands.Bot() -# various tokens and global vars -discordToken = readToken("discord.token") -gsheetToken = readToken("sheet.token") -lastCommandFile = "command.last" - -print("hey wassup") +# various tokens +discordToken = helpers.readToken("discord.token") -#there's a small chance the files don't exist. If they don't we create an empty file. -try: - with open("station.name", 'r') as f: - stationName = f.readline() -except FileNotFoundError: - open("station.name", 'w').close() - stationName = "REPLACEME" - -try: - with open("station.url",'r') as f: - stationUrl = f.readline() -except FileNotFoundError: - open("station.url", 'w').close() - stationUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ" - # default command to see if the bot has lived @bot.listen() async def on_connect(): - global session print("I'm alive, bitch") - session = aiohttp.ClientSession() + + @bot.event async def on_ready(): - writeToWhatsLeftToHaul.start() - writeTocarrierState.start() - print("I'm ready, bitch") - - - -# delivery command -# guild IDs are both IDA servers -@bot.slash_command( - name="delivery", - # guild_ids=[401372086746087425], - description= "sends your delivery to the bot!" -) -@option("commodity",required=True, - description="The Commodity you want to deliver", - autocomplete=getCommodities) -@option("quantity",required=True, - description="Please be nice and input a value between 1 and 1326 (new rack update!!!!1!1)", - type=int, min_value=1, max_value=1326) -@option("target", required=True, - description="Are you delivering to a carrier or the target station?", - type=str, choices=['Station', 'Carrier']) - -async def delivery(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 postToSheet(data, 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 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}") - - - -# 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 = { - "postType":"delivery", - "username":author, - "commodity": "Misc", - "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"[{datetime.isoformat(datetime.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], - description= "send the last delivery you made again!" -) -async def last(ctx): - - author = str(ctx.author) - author = author[:author.find(" ")] - - data = await getDataFromDeliveryFile(author) - - await ctx.defer() - - - if data is not None: - try: - response = await postToSheet(data, gsheetToken) - if response == 200: - await ctx.followup.send(f"your delivery of {data['quantity']} of {data['commodity']} to a {data['target']} has been added to the sheet!") - print(f"[{datetime.isoformat(datetime.now())}] delivery of {data['quantity']} of {data['commodity']} to a {data['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}") - else: - await ctx.followup.send(f"You haven't delivered to this build yet, or I have amnesia.") - - - - -#change url command -@bot.slash_command( - name="change-sheet-url", - # guild_ids=[401372086746087425], - description= "changes the URL of the active sheet, use with caution" -) -async def changeSheetUrl(ctx, - url:discord.Option(discord.SlashCommandOptionType.string, description="the new URL") - ): - global gsheetToken - global stationName - global stationURL - await ctx.defer() - try: - with open("sheet.token",'w') as f: - f.write(url) - - await ctx.followup.send(f"URL has been set to {url}") - gsheetToken = readToken("sheet.token") - await delLastCommandFile() - print("deleted command.last file content") - - # gets the name and URL from the sheet, then store it in a file so we don't ask the sheet again. - name, url = (await getFromSheet(gsheetToken, "sheet")).split("|") - - with open("station.name", 'w') as f: - f.write(name) - stationName = name - - with open("station.url", 'w') as f: - f.write(url) - stationURL = url - - writeToWhatsLeftToHaul.restart() - - except Exception as e: - await ctx.followup.send(f"something shat the bed") - - - - - - - -@bot.slash_command( - name="setcarrierstate", - # guild_ids=[401372086746087425], - description= "Sets a carrier state on the sheet" -) -@option("carrier", description="The carrier you want to edit", autocomplete=getCarriers) -@option("state",required=True, description="The carrier you want to edit", choices=["Loading","Unloading","Full","Empty","Inactive"]) -async def setCarrierState(ctx, carrier, state): - response = await getFromSheet(gsheetToken, "carrier") - carrierState = await parseCarrierState(response) - author = str(ctx.author) - - newCarrierState = [] - - #print(f"requested values: {carrier} to {state}") - - #print(f"current values : {carrierState}") - - for carrierS, stateS in carrierState: - if carrier == carrierS: - newCarrierState.append((carrier,state)) - else: - newCarrierState.append((carrierS,stateS)) - - #print(f"new values : {newCarrierState}") - - rawState = await toRawState(newCarrierState) - - #print(rawState) - - await ctx.defer() - i = 1 - text = "Current Carrier State : \n" - - - data = { - "postType":"carrier", - "carrierState": rawState - } - - - try: - response = await postToSheet(data, gsheetToken) - if response == 200: - await ctx.followup.send(f"The carrier {carrier} has been set to {state}") - print(f"{author} set {carrier} state to {state}") - channel = bot.get_channel(1521963883018063882) - await channel.send(f"{author} set {carrier} state to {state}") - - else: - await ctx.followup.send(f"i fucked up ") - except Exception as e: - await ctx.followup.send(f"help : Error: {e}") - - - - - -#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) -async def writeToWhatsLeftToHaul(): - - - response = await getFromSheet(gsheetToken, "commodity") - - - commodity, values, initial = response.split("|") - - commodity = commodity.split(",") - values = values.split(",") - initial = initial.split(",") - - - - values = [int(i) for i in values] - initial = [int (i) for i in initial] - - - finalDict = {} - progressDict = {} - neededCommodity = [] - - for i in range(len(commodity)): - finalDict[commodity[i]] = values[i] - if initial[i] > 0: - progressDict[commodity[i]] = await createProgressBar(values[i],initial[i]) - neededCommodity.append(commodity[i]) - else: - progressDict[commodity[i]] = await createProgressBar(1,1) - - #finalDict = dict(sorted(finalDict.items(), key=lambda item: item[1], reverse=True)) - - with open("commodity.needed",'w') as f: - f.write(str(neededCommodity)) - print("values set") - - channel = bot.get_channel(1519457137234022460) - # await channel.purge(limit=1) - - - - 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") - - - 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 ' + stationName + u' \U0001F517', - url=stationUrl) - embed2.set_author(name=u'\U0001F517 ' + stationName + u' \U0001F517', - url=stationUrl) - - - channel = bot.get_channel(1519457137234022460) - found = False - async for oldmsg in channel.history(limit=2): - if oldmsg.author == bot.user: - found = True - await oldmsg.edit(embeds=[embed, embed2]) - break - if not found: - await channel.send(embeds=[embed, embed2]) - - - - - -#writes the carriers state to... the carrier state channel. Seriously, who is writing this? -@tasks.loop(seconds=60) -async def writeTocarrierState(): - response = await getInternalCarrierState() - carrierState = await parseCarrierState(response) - - - channel = bot.get_channel(1521596285981819101) - - 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 ' + stationName + u' \U0001F517', - url=stationUrl) - - embed.set_footer(text="This message updates every 60 seconds(ish). Last updated") - - for carrier, state in carrierState: - embed.add_field(name=carrier, value=state, inline=True) - - - found = False - async for oldmsg in channel.history(limit=2): - if oldmsg.author == bot.user: - found = True - await oldmsg.edit(embed=embed) - break - if not found: - await channel.send(embed=embed) - - - - - - - - - - - - - - - - - - - - - - - - #run the damn thing -bot.run(discordToken) \ No newline at end of file + + +bot.load_extension("cogs.IdaCogs") +bot.run(discordToken) + + + -- 2.20.1 From af336c9785c12d329e102ad0e03b894ca8e508c4 Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Thu, 2 Jul 2026 00:23:54 +0200 Subject: [PATCH 09/22] fixed errored source for still needed commodities. --- cogs/IdaCogs.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py index 69df569..7b132a0 100644 --- a/cogs/IdaCogs.py +++ b/cogs/IdaCogs.py @@ -273,12 +273,15 @@ class IdaCogs(commands.Cog): 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]) - neededCommodity.append(commodity[i]) else: progressDict[commodity[i]] = await helpers.createProgressBar(1,1) + if values[i] > 0: + neededCommodity.append(commodity[i]) + #finalDict = dict(sorted(finalDict.items(), key=lambda item: item[1], reverse=True)) self.commodities = neededCommodity -- 2.20.1 From 6fdcba74890be26b32283b036e78d82eefbe41d4 Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Sat, 4 Jul 2026 21:32:35 +0200 Subject: [PATCH 10/22] removed auto complete for commodities as its simply too slow :( --- cogs/IdaCogs.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py index 7b132a0..1441fb4 100644 --- a/cogs/IdaCogs.py +++ b/cogs/IdaCogs.py @@ -48,9 +48,36 @@ class IdaCogs(commands.Cog): # guild_ids=[401372086746087425], description= "sends your delivery to the bot!" ) + + ## sadly the autocomplete is too slow and allow non-authorized values. + #@option("commodity",required=True, + # description="The Commodity you want to deliver", + # autocomplete=getCommodities) + @option("commodity",required=True, - description="The Commodity you want to deliver", - autocomplete=getCommodities) + 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 1326 (new rack update!!!!1!1)", type=int, min_value=1, max_value=1326) -- 2.20.1 From 9ff9dde701d5ac0d07524692df7a39048ff63e93 Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Sat, 4 Jul 2026 21:39:47 +0200 Subject: [PATCH 11/22] added safety for carriers name (only allow those in the list in case someone has the funny idea of ignoring the autocomplete. No fingers pointed, of course. Light. --- cogs/IdaCogs.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py index 1441fb4..7fa2832 100644 --- a/cogs/IdaCogs.py +++ b/cogs/IdaCogs.py @@ -234,8 +234,15 @@ class IdaCogs(commands.Cog): async def setCarrierState(self, ctx, carrier, state): response = await helpers.getFromSheet(self.session, self.gsheetToken, "carrier") + await ctx.defer() + #transforms the response into a dict (carrier : state) we can use carrierState = await helpers.parseCarrierState(response) + + if carrier not in carrierState.keys(): + await ctx.followup.send(f"The specified carrier {carrier} is not in the allowed list! Quitting!") + return 0 + author = str(ctx.author) carrierState[carrier] = state @@ -244,7 +251,7 @@ class IdaCogs(commands.Cog): #print(rawState) - await ctx.defer() + i = 1 text = "Current Carrier State : \n" -- 2.20.1 From c8bb112fc27f2a10a00433ee274516102b6368ed Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Mon, 13 Jul 2026 21:38:56 +0200 Subject: [PATCH 12/22] added prod channels ID. --- cogs/IdaCogs.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py index 7fa2832..f7783d8 100644 --- a/cogs/IdaCogs.py +++ b/cogs/IdaCogs.py @@ -13,6 +13,9 @@ class IdaCogs(commands.Cog): self.gsheetToken = helpers.readToken("sheet.token") self.stationName = helpers.getStationName() self.stationUrl = helpers.getStationUrl() + self.whatsLeftToHaulChannelId = 668892839798898698 + self.carrierStatsChannel = 00 + self.debugChannel = 583345534178426911 @@ -267,7 +270,7 @@ class IdaCogs(commands.Cog): if response == 200: await ctx.followup.send(f"The carrier {carrier} has been set to {state}") print(f"{author} set {carrier} state to {state}") - channel = self.bot.get_channel(1521963883018063882) + channel = self.bot.get_channel(self.debugChannel) await channel.send(f"{author} set {carrier} state to {state}") else: @@ -345,7 +348,7 @@ class IdaCogs(commands.Cog): url=self.stationUrl) - channel = self.bot.get_channel(1519457137234022460) + channel = self.bot.get_channel(self.whatsLeftToHaulChannelId) found = False async for oldmsg in channel.history(limit=2): @@ -367,7 +370,7 @@ class IdaCogs(commands.Cog): carrierState = await helpers.parseCarrierState(response) - channel = self.bot.get_channel(1521596285981819101) + channel = self.bot.get_channel(self.carrierStateChannelId) embed = discord.Embed(title="Carriers State", colour=discord.Colour(0x29ac08), -- 2.20.1 From 21563f1aeff3ff59e405f4df33f062c75e51bd1b Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Tue, 28 Jul 2026 23:29:35 +0200 Subject: [PATCH 13/22] fixed missing var --- cogs/IdaCogs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py index f7783d8..019b1b9 100644 --- a/cogs/IdaCogs.py +++ b/cogs/IdaCogs.py @@ -14,7 +14,7 @@ class IdaCogs(commands.Cog): self.stationName = helpers.getStationName() self.stationUrl = helpers.getStationUrl() self.whatsLeftToHaulChannelId = 668892839798898698 - self.carrierStatsChannel = 00 + self.carrierStatsChannel = 1531775556801269930 self.debugChannel = 583345534178426911 @@ -370,7 +370,7 @@ class IdaCogs(commands.Cog): carrierState = await helpers.parseCarrierState(response) - channel = self.bot.get_channel(self.carrierStateChannelId) + channel = self.bot.get_channel(self.carrierStatsChannel) embed = discord.Embed(title="Carriers State", colour=discord.Colour(0x29ac08), -- 2.20.1 From cc04cc7a4994484b21261cf83018f13aa309001d Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Tue, 28 Jul 2026 23:35:01 +0200 Subject: [PATCH 14/22] help --- cogs/IdaCogs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py index 019b1b9..a08ac15 100644 --- a/cogs/IdaCogs.py +++ b/cogs/IdaCogs.py @@ -222,6 +222,7 @@ class IdaCogs(commands.Cog): self.writeToWhatsLeftToHaul.restart() except Exception as e: + print(e) await ctx.followup.send(f"something shat the bed") -- 2.20.1 From 9c1f2b8cbc10be1f329c1536e1cdc9ac14199870 Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Tue, 28 Jul 2026 23:37:31 +0200 Subject: [PATCH 15/22] help --- cogs/IdaCogs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py index a08ac15..7ff59e5 100644 --- a/cogs/IdaCogs.py +++ b/cogs/IdaCogs.py @@ -201,6 +201,7 @@ class IdaCogs(commands.Cog): await ctx.defer() try: with open("../sheet.token", 'w') as f: + print(url) f.write(url) await ctx.followup.send(f"URL has been set to {url}") -- 2.20.1 From c3d574b57c0482360bddf6790ea41ce811549ea6 Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Tue, 28 Jul 2026 23:39:19 +0200 Subject: [PATCH 16/22] help --- cogs/IdaCogs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py index 7ff59e5..bf48ed0 100644 --- a/cogs/IdaCogs.py +++ b/cogs/IdaCogs.py @@ -203,6 +203,7 @@ class IdaCogs(commands.Cog): with open("../sheet.token", 'w') as f: print(url) f.write(url) + print("fqzqzdzqqzqzdqdzqzdqdz") await ctx.followup.send(f"URL has been set to {url}") self.gsheetToken = helpers.readToken("../sheet.token") -- 2.20.1 From 049ae8f9dd4c305f9ac872fe1ba1977214107a90 Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Tue, 28 Jul 2026 23:42:30 +0200 Subject: [PATCH 17/22] help --- cogs/IdaCogs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py index bf48ed0..3857894 100644 --- a/cogs/IdaCogs.py +++ b/cogs/IdaCogs.py @@ -202,7 +202,7 @@ class IdaCogs(commands.Cog): try: with open("../sheet.token", 'w') as f: print(url) - f.write(url) + f.write("ssssss") print("fqzqzdzqqzqzdqdzqzdqdz") await ctx.followup.send(f"URL has been set to {url}") -- 2.20.1 From 57d5c38a988e4a3a60059325f25fb2e63ce12a48 Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Tue, 28 Jul 2026 23:44:18 +0200 Subject: [PATCH 18/22] fixed bad files path --- cogs/IdaCogs.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py index 3857894..ed3c28e 100644 --- a/cogs/IdaCogs.py +++ b/cogs/IdaCogs.py @@ -200,24 +200,23 @@ class IdaCogs(commands.Cog): await ctx.defer() try: - with open("../sheet.token", 'w') as f: + with open("sheet.token", 'w') as f: print(url) - f.write("ssssss") - print("fqzqzdzqqzqzdqdzqzdqdz") + f.write(url) await ctx.followup.send(f"URL has been set to {url}") - self.gsheetToken = helpers.readToken("../sheet.token") + self.gsheetToken = helpers.readToken("sheet.token") await helpers.delLastCommandFile() print("deleted command.last file content") # gets the name and URL from the sheet, then store it in a file so we don't ask the sheet again. name, url = (await helpers.getFromSheet(self.gsheetToken, "sheet")).split("|") - with open("../station.name", 'w') as f: + with open("station.name", 'w') as f: f.write(name) self.stationName = name - with open("../station.url", 'w') as f: + with open("station.url", 'w') as f: f.write(url) self.stationUrl = url -- 2.20.1 From 5f013718661e5baa35d23ce231613504c55d4e37 Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Tue, 28 Jul 2026 23:51:59 +0200 Subject: [PATCH 19/22] fuck you --- cogs/IdaCogs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py index ed3c28e..8984c1b 100644 --- a/cogs/IdaCogs.py +++ b/cogs/IdaCogs.py @@ -292,7 +292,7 @@ class IdaCogs(commands.Cog): response = await helpers.getFromSheet(self.session, self.gsheetToken, "commodity") - + print(response) commodity, values, initial = response.split("|") commodity = commodity.split(",") -- 2.20.1 From 5d012510724b65cecc512a6ce5e2ab331df68a08 Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Wed, 29 Jul 2026 09:56:39 +0200 Subject: [PATCH 20/22] changed channel ID to fix wrong perms. --- cogs/IdaCogs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py index 8984c1b..af90c86 100644 --- a/cogs/IdaCogs.py +++ b/cogs/IdaCogs.py @@ -13,7 +13,7 @@ class IdaCogs(commands.Cog): self.gsheetToken = helpers.readToken("sheet.token") self.stationName = helpers.getStationName() self.stationUrl = helpers.getStationUrl() - self.whatsLeftToHaulChannelId = 668892839798898698 + self.whatsLeftToHaulChannelId = 1531933188132175943 self.carrierStatsChannel = 1531775556801269930 self.debugChannel = 583345534178426911 -- 2.20.1 From 30e403a14b8e8b74eb030d005a088c2ba0c3340d Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Wed, 29 Jul 2026 10:05:38 +0200 Subject: [PATCH 21/22] fixed wrong function call in change sheet --- cogs/IdaCogs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py index af90c86..97907ff 100644 --- a/cogs/IdaCogs.py +++ b/cogs/IdaCogs.py @@ -210,7 +210,7 @@ class IdaCogs(commands.Cog): print("deleted command.last file content") # gets the name and URL from the sheet, then store it in a file so we don't ask the sheet again. - name, url = (await helpers.getFromSheet(self.gsheetToken, "sheet")).split("|") + name, url = (await helpers.getFromSheet(self.session, self.gsheetToken, "sheet"),).split("|") with open("station.name", 'w') as f: f.write(name) -- 2.20.1 From 5081b2933349bc483fc349c0b47c2923f403fafc Mon Sep 17 00:00:00 2001 From: TanguyPcFixe Date: Wed, 29 Jul 2026 10:07:28 +0200 Subject: [PATCH 22/22] fixed wrong function call in change sheet, again --- cogs/IdaCogs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/IdaCogs.py b/cogs/IdaCogs.py index 97907ff..28f27a8 100644 --- a/cogs/IdaCogs.py +++ b/cogs/IdaCogs.py @@ -210,7 +210,7 @@ class IdaCogs(commands.Cog): print("deleted command.last file content") # gets the name and URL from the sheet, then store it in a file so we don't ask the sheet again. - name, url = (await helpers.getFromSheet(self.session, self.gsheetToken, "sheet"),).split("|") + name, url = (await helpers.getFromSheet(self.session, self.gsheetToken, "sheet")).split("|") with open("station.name", 'w') as f: f.write(name) -- 2.20.1