-
Notifications
You must be signed in to change notification settings - Fork 6
/
sysbot.py
130 lines (111 loc) · 5.06 KB
/
sysbot.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
print("Launching SysBot.py...")
import discord
from discord.ext import commands
import os
import yaml
from yaml import load
yaml.warnings({'YAMLLoadWarning': False})
from discord_slash import SlashCommand
from colorama import Fore
import ctypes
from rich.console import Console
import pokemon.connection.wireless as sysbot
import subprocess
import json
# Loads token and autolauncher from config file
with open("config.yaml") as file:
data = load(file)
token = data["token"]
botprefix = data["defaultprefix"]
autolauncher = data["autolauncher"]
twitch = data["twitch"]
# Fetch prefix
def get_prefix(client, message):
with open("res/prefix.json", "r") as f:
prefixes = json.load(f)
if str(message.guild.id) in prefixes:
prefix = prefixes[str(message.guild.id)]
return commands.when_mentioned_or(*prefix)(client, message)
else:
prefixes[str(message.guild.id)] = botprefix
with open("res/prefix.json", "w") as f:
json.dump(prefixes, f, indent=4)
return commands.when_mentioned_or(botprefix)(client, message)
##Simple bot settings like mentioning as a prefix, settings all intents to true, deleting built in discord.py help command
client = commands.AutoShardedBot(name="SysBot 2.2.0", command_prefix=get_prefix, intents=discord.Intents.all())
slash = SlashCommand(client, sync_commands=True)
console = Console()
# State if autolauncher is toggled
if autolauncher == 1:
console.print("Autolauncher set to true.", style="green")
if autolauncher == 2:
console.print("Autolauncher set to false.", style="green")
#Bot Start Up
@client.event
async def on_ready():
ctypes.windll.kernel32.SetConsoleTitleW('{0.user}'.format(client) + ' ALPHA')
console.clear()
print(f'''{Fore.LIGHTBLUE_EX}
_____ ____ _
/ ____| | _ \ | |
| (___ _ _ ___| |_) | ___ | |_ _ __ _ _
\___ \| | | / __| _ < / _ \| __| | '_ \| | | |
____) | |_| \__ \ |_) | (_) | |_ _| |_) | |_| |
|_____/ \__, |___/____/ \___/ \__(_) __/ \__, |
__/ | | | __/ |
|___/ |_| |___/ \x1b[0m{Fore.MAGENTA}By 6A\x1b[0m
{Fore.WHITE}────────────────────────────────────────────────────────────────────────────────
{Fore.LIGHTRED_EX}Connected as: {Fore.LIGHTYELLOW_EX}{client.user}
{Fore.LIGHTRED_EX}Guild Count: {Fore.LIGHTYELLOW_EX}{len(client.guilds)}
{Fore.WHITE}────────────────────────────────────────────────────────────────────────────────
''')
if autolauncher == 1:
try:
client.load_extension("pokemon.connection.wireless")
await sysbot.connection(client).initiate()
except:
console.print(f"Unable to launch wireless.py", style="red")
elif autolauncher == 2:
console.print('The bot will launch without sysbot commands.', style="blue")
else:
console.print("Would you like to connect a Nintendo Switch to your bot?\nType Y to load the sysbot module, type N to continue without the sysbot.", style="yellow")
yes = {'yes', 'y'}
choice = input().lower()
if choice in yes:
try:
client.load_extension("pokemon.connection.wireless")
await sysbot.connection(client).initiate()
except:
console.print(f"Unable to launch wireless.py", style="red")
else:
print('The bot will launch without sysbot commands.')
if twitch == 1:
subprocess.Popen('python pokemon/twitch.py')
elif autolauncher == 2 or twitch == 2:
pass
else:
console.print("Would you like to launch Sysbot-Twitch.py?", style="blue")
yes = {'yes', 'y'}
choice = input().lower()
if choice in yes:
subprocess.Popen('python pokemon/twitch/twitch.py')
else:
print('Will not launch SysBot-Twitch.')
# Build Plugins List
plugins = []
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
plugins.append("cogs." + filename[:-3])
# Load plugins
if __name__ == '__main__':
for x in plugins:
try:
client.load_extension(x)
except Exception as e:
console.print(f"Unable to load {x}: {e}.", style="red")
#Debugger || {defaultprefix}jsk debug <command>
client.load_extension('jishaku')
try:
client.run('{}'.format(token))
except Exception as e:
print(f"Error when logging in: {e}")