-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainRunner.py
87 lines (72 loc) · 3.19 KB
/
mainRunner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import threading
import os
import sys
import time
import discord
from discord.ext import commands
from discord.commands import slash_command, Option
import logging
import textwrap
from utils.common import clear_screen, Color
from validation.token import check_token_validity
from bot.commands import *
# Flag or event to indicate if CLI functionality has finished
cli_finished = threading.Event()
# Flag or event to indicate if CLI functionality has finished
cli_finished = threading.Event()
bot = main()
token = None # Define token as a global variable
bot_thread = None # Define bot_thread as a global variable
def runCLI():
time.sleep(1)
ascii_art = '''
\033[93m .88b d88. d8888b. .88b d88. \033[0m
\033[93m 88'YbdP`88 88 `8D 88'YbdP`88 \033[0m
\033[93m 88 88 88 88 88 88 88 88 \033[0m
\033[93m 88 88 88 88 88 88 88 88 \033[0m
\033[93m 88 88 88 88 .8D 88 .8D 88 \033[0m
\033[93m YP YP YP Y8888D' YP YP YP \033[0m
\033[93m Mass Discord Moderation \033[0m
'''
for line in ascii_art.splitlines():
print(line)
time.sleep(0.1)
def getToken():
global token
token = input("\nAuthenticate with your token (leave empty if you don't have one): ")
if token == '':
print("To get a Discord Bot Token, follow these instructions:")
print("1. Go to the Discord Developer Portal website: https://discord.com/developers/applications.")
print("2. Log in to your Discord account or create a new one if you don't have an account.")
print("3. Click on the 'New Application' button at the top right corner.")
print("4. Give your application a name. This will be the name of your bot. For example, 'My Discord Bot.'")
print("5. Click on the 'Create' button to create the application.")
print("")
print("Once you have created the application, follow the remaining steps in the portal to create a bot and obtain its token.")
print("Make sure to treat your bot token like a password and keep it secure. Do not share it with anyone or include it in public code repositories.")
print("")
print("See more detailed instructions here: https://discord.com/developers/docs")
getToken()
return
time.sleep(0.3)
print("\nChecking token validity...")
if check_token_validity(token):
print(Color.GREEN + "Token Valid. Signing in..." + Color.ENDC)
# Run the bot in a thread with the token
bot_thread = threading.Thread(target=bot.run, args=(token, ))
bot_thread.start()
return
else:
print(Color.FAIL + "Token Invalid. Please try again." + Color.ENDC)
getToken()
return
getToken()
def switch_to_cli():
clear_screen()
# Start the CLI thread
cli_thread = threading.Thread(target=runCLI, daemon=True)
cli_thread.start()
cli_finished.wait()
switch_to_cli()
# Flag or event to indicate if CLI functionality has finished
cli_finished = threading.Event()