async def end(self, ctx): self.avoid_file_crashes.cancel() settings.save() setlangs.save() blocked_users.save() await self.bot.close()
async def avoid_file_crashes(self): try: cache.save() settings.save() setlangs.save() blocked_users.save() cache_size = basic.get_size("cache") if cache_size >= 1073741824: print("Deleting 100 messages from cache!") cache_folder = listdir("cache") cache_folder.sort( reverse=False, key=lambda x: int(''.join(filter(str.isdigit, x)))) for count, cached_message in enumerate(cache_folder): remove(f"cache/{cached_message}") cache.remove(cached_message) if count == 100: break except Exception as e: error = getattr(e, 'original', e) temp = f"```{''.join(format_exception(type(error), error, error.__traceback__))}```" if len(temp) >= 1900: with open("temp.txt", "w") as f: f.write(temp) await self.bot.channels["errors"].send( file=discord.File("temp.txt")) else: await self.bot.channels["errors"].send(temp)
async def avoid_file_crashes(self): try: settings.save() setlangs.save() blocked_users.save() except Exception as e: error = getattr(e, 'original', e) temp = f"```{''.join(format_exception(type(error), error, error.__traceback__))}```" if len(temp) >= 1900: with open("temp.txt", "w") as f: f.write(temp) await self.bot.channels["errors"].send( file=discord.File("temp.txt")) else: await self.bot.channels["errors"].send(temp)
async def save_files(self, ctx): settings.save() setlangs.save() blocked_users.save() await ctx.send("Saved all files!")