From cf1d61552736417f71d531e33e8ab68e82377c74 Mon Sep 17 00:00:00 2001 From: marius david Date: Sat, 25 Jan 2025 12:02:08 +0100 Subject: [PATCH] add command: make it work if species or form has been deleted --- SpriteBot.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SpriteBot.py b/SpriteBot.py index ff4d715..8eba181 100644 --- a/SpriteBot.py +++ b/SpriteBot.py @@ -2506,11 +2506,11 @@ async def addSpeciesForm(self, msg, args): await msg.channel.send(msg.author.mention + " {0} already exists!".format(species_name)) return - count = len(self.tracker) - new_idx = "{:04d}".format(count) + new_id_int = max([int(i) for i in self.tracker.keys()]) + 1 + new_idx = "{:04d}".format(new_id_int) self.tracker[new_idx] = TrackerUtils.createSpeciesNode(species_name) - await msg.channel.send(msg.author.mention + " Added #{0:03d}: {1}!".format(count, species_name)) + await msg.channel.send(msg.author.mention + " Added #{0:03d}: {1}!".format(new_id_int, species_name)) else: if species_idx is None: await msg.channel.send(msg.author.mention + " {0} doesn't exist! Create it first!".format(species_name)) @@ -2540,9 +2540,9 @@ async def addSpeciesForm(self, msg, args): if species_name == "Missingno_": canon = False - count = len(species_dict.subgroups) - new_count = "{:04d}".format(count) - species_dict.subgroups[new_count] = TrackerUtils.createFormNode(form_name, canon) + new_id_int = max([int(i) for i in species_dict.subgroups.keys()]) + 1 + new_idx = "{:04d}".format(new_id_int) + species_dict.subgroups[new_idx] = TrackerUtils.createFormNode(form_name, canon) await msg.channel.send(msg.author.mention + " Added #{0:03d}: {1} {2}!".format(int(species_idx), species_name, form_name))