|
| 1 | +import nextcord |
| 2 | +import asyncio |
| 3 | +from nextcord.ext import commands |
| 4 | +import os |
| 5 | +import sys |
| 6 | + |
| 7 | +ascii_art = r""" |
| 8 | +
|
| 9 | + __ __ ______ __ __ ______ ______ __ __ ______ __ |
| 10 | + /\ \_\ \ /\ __ \ /\_\_\_\ /\ == \ /\ __ \ /\ "-.\ \ /\ ___\ /\ \ |
| 11 | + \ \ __ \ \ \ __ \ \/_/\_\/_ \ \ _-/ \ \ __ \ \ \ \-. \ \ \ __\ \ \ \____ |
| 12 | + \ \_\ \_\ \ \_\ \_\ /\_\/\_\ \ \_\ \ \_\ \_\ \ \_\\"\_\ \ \_____\ \ \_____\ |
| 13 | + \/_/\/_/ \/_/\/_/ \/_/\/_/ \/_/ \/_/\/_/ \/_/ \/_/ \/_____/ \/_____/ |
| 14 | + |
| 15 | + |
| 16 | +""" |
| 17 | + |
| 18 | +def clear_screen(): |
| 19 | + os.system('cls' if os.name == 'nt' else 'clear') |
| 20 | + |
| 21 | +def center_text(text): |
| 22 | + terminal_width = os.get_terminal_size().columns |
| 23 | + return text.center(terminal_width) |
| 24 | + |
| 25 | +def center_ascii_art(ascii_art): |
| 26 | + lines = ascii_art.split("\n") |
| 27 | + return "\n".join([center_text(line) for line in lines]) |
| 28 | + |
| 29 | +def display_menu(): |
| 30 | + clear_screen() |
| 31 | + # Apply lime color to ASCII art |
| 32 | + print(f"\033[1;32m{center_ascii_art(ascii_art)}\033[0m") |
| 33 | + print(center_text("\n\n")) |
| 34 | + print(f"\033[1;32m{center_text('1. List servers the bot is in.')}\033[0m") |
| 35 | + print(f"\033[1;32m{center_text('2. Exit.')}\033[0m\n") |
| 36 | + print(f"\033[31m{center_text('---------------------------------------------------------------------------')}\033[0m") |
| 37 | + print(center_text("")) |
| 38 | + |
| 39 | +async def main_menu(): |
| 40 | + while True: |
| 41 | + display_menu() |
| 42 | + print(f"\033[1;36m{center_text(f'Logged in as: {bot.user}')}\033[0m") |
| 43 | + print(f"\033[1;36m{center_text(f'Bot is in {len(bot.guilds)} servers.')}\033[0m") |
| 44 | + |
| 45 | + sys.stdout.write(f"\033[1;36m> \033[0m") |
| 46 | + sys.stdout.flush() |
| 47 | + |
| 48 | + choice = input() |
| 49 | + |
| 50 | + if choice == "": |
| 51 | + continue |
| 52 | + |
| 53 | + if choice == "1": |
| 54 | + await list_servers() |
| 55 | + elif choice == "2": |
| 56 | + print(f"\033[1;36m{center_text('Exiting...')}\033[0m") |
| 57 | + await bot.close() |
| 58 | + break |
| 59 | + else: |
| 60 | + print(f"\033[1;36m{center_text('Invalid choice. Please try again.')}\033[0m") |
| 61 | + |
| 62 | +async def list_servers(): |
| 63 | + clear_screen() |
| 64 | + print(f"\n\033[1;36m{center_text('Servers the bot is in:')}\033[0m") |
| 65 | + for i, guild in enumerate(bot.guilds): |
| 66 | + print(center_text(f"{i + 1}. {guild.name}")) |
| 67 | + |
| 68 | + try: |
| 69 | + server_number = int(input(f"\033[1;36m{center_text('Enter the number of the server to leave (or 0 to cancel): ')}\033[0m")) |
| 70 | + if server_number == 0: |
| 71 | + print(f"\033[1;36m{center_text('Action cancelled.')}\033[0m") |
| 72 | + return |
| 73 | + |
| 74 | + selected_guild = bot.guilds[server_number - 1] |
| 75 | + confirm = input(f"\033[1;36m{center_text(f'Are you sure you want the bot to leave {selected_guild.name}? (yes/no): ')}\033[0m").lower() |
| 76 | + |
| 77 | + if confirm == "yes": |
| 78 | + await selected_guild.leave() |
| 79 | + print(f"\033[1;36m{center_text(f'The bot has left {selected_guild.name}.')}\033[0m") |
| 80 | + else: |
| 81 | + print(f"\033[1;36m{center_text('Action cancelled.')}\033[0m") |
| 82 | + |
| 83 | + except (ValueError, IndexError): |
| 84 | + print(f"\033[1;36m{center_text('Invalid input. Please try again.')}\033[0m") |
| 85 | + |
| 86 | +intents = nextcord.Intents.default() |
| 87 | +intents.message_content = True |
| 88 | + |
| 89 | +bot = commands.Bot(command_prefix="!", intents=intents) |
| 90 | + |
| 91 | +@bot.event |
| 92 | +async def on_ready(): |
| 93 | + clear_screen() |
| 94 | + await main_menu() |
| 95 | + |
| 96 | +with open("token.txt", "r") as token_file: |
| 97 | + bot_token = token_file.read().strip() |
| 98 | + |
| 99 | +bot.run(bot_token) |
0 commit comments