async def mass_leave(self, ctx, *, code=None): try: check_for_servers() if int(code) != int(CODE): command_error("mass_leave") return with open("cogs/servers.txt", "r") as f: IDs = f.read().split("\n") for ID in IDs: try: ID = int(ID) await self.bot.get_guild(ID).leave() except BaseException: pass f.close() os.remove("cogs/servers.txt") with open("cogs/servers.txt", "w") as f: f.close() print( f"{Fore.LIGHTGREEN_EX}Anubis bot has successfully left all servers.{Fore.RESET}" ) return except BaseException as e: print(f"{Fore.LIGHT_RED}{e}\n\n") return
import discord import os import asyncpg from discord.ext import commands, tasks from itertools import cycle from cogs.anubis_methods import DATA, check_for_run_settings, write_temp, check_for_servers, display_start_error, display_title_screen, search_for_updates from colorama import Fore, init init() # Check for basic files needed and write the temp file. DATA = check_for_run_settings() write_temp() check_for_servers() # Sets the bot prefix to the prefix specified in the JSON file. if DATA.get("prefix").strip().replace(" ", "") == "": display_start_error("No prefix!") else: intents = discord.Intents.default() intents.members = True bot = commands.Bot(command_prefix=DATA.get("prefix"), intents=intents) # Status' to be cycled continously as the bot runs. # You add or change these status' here - make sure to have at least one.