added a try to avoid exception stopping the process, track_channel.history had a limit of -1, making the loop instantly stop

This commit is contained in:
raphael60650 2021-08-01 22:46:50 +02:00
parent ca01ded4e7
commit 3ba2fa92e7

View file

@ -50,7 +50,7 @@ async def on_ready():
old_sha1 = set() old_sha1 = set()
message: discord.Message message: discord.Message
async for message in track_channel.history(limit=-1): async for message in track_channel.history(limit=5000):
if message.author.id == bot.user.id: if message.author.id == bot.user.id:
for field in message.embeds[0].fields: for field in message.embeds[0].fields:
if "sha1" in field.name: if "sha1" in field.name:
@ -61,6 +61,7 @@ async def on_ready():
ct_config.load_ctconfig_file("./ct_config.json") ct_config.load_ctconfig_file("./ct_config.json")
for track in ct_config.all_tracks: for track in ct_config.all_tracks:
try:
if track.name == "_": continue if track.name == "_": continue
embed = discord.Embed(title=f"**{track.get_track_name()}**", embed = discord.Embed(title=f"**{track.get_track_name()}**",
@ -103,4 +104,7 @@ async def on_ready():
if hasattr(track, "sha1"): if hasattr(track, "sha1"):
await message_from_sha1[track.sha1].edit(embed=embed) await message_from_sha1[track.sha1].edit(embed=embed)
except Exception as e:
print(f'error in track {track.name} : {str(e)}')
bot.run(os.environ['DISCORD_GR_TOKEN']) bot.run(os.environ['DISCORD_GR_TOKEN'])