-
Notifications
You must be signed in to change notification settings - Fork 64
/
main.py
137 lines (114 loc) · 4.04 KB
/
main.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
131
132
133
134
135
136
137
try:
import subprocess
import os
import sys
import json
import time
import discord
from utils.cloner import Cloner
from utils.panel import Panel, Panel_Run
from discord import Client, Intents
from rich.prompt import Prompt, Confirm
from time import sleep
if discord.__version__ != "1.7.3":
print("Updating Discord.py...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
print("Discord.py Updated Successfully!")
print("Restarting...")
os.execl(sys.executable, sys.executable, *sys.argv)
except Exception:
print("Installing Requirements...")
subprocess.check_call(
[sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
print("Requirements Installed Successfully!")
print("Restarting...")
os.execl(sys.executable, sys.executable, *sys.argv)
try:
client = Client(intents=Intents.all())
except Exception as e:
print("> Failed to create Discord client: ", e)
with open("./utils/config.json", "r") as json_file:
data = json.load(json_file)
os.system('cls' if os.name == 'nt' else 'clear')
def clear(option=False):
sleep(1)
os.system('cls' if os.name == 'nt' else 'clear')
if option:
user = client.user
guild = client.get_guild(int(INPUT_GUILD_ID))
Panel_Run(guild, user)
else:
Panel()
async def clone_server():
start_time = time.time()
guild_from = client.get_guild(int(INPUT_GUILD_ID))
print(" ")
guild_to = client.get_guild(int(GUILD))
# Edit the server name and icon
await Cloner.guild_create(guild_to, guild_from)
await Cloner.channels_delete(guild_to)
if data["copy_settings"]["roles"]:
await Cloner.roles_create(guild_to, guild_from)
if data["copy_settings"]["categories"]:
await Cloner.categories_create(guild_to, guild_from)
if data["copy_settings"]["channels"]:
await Cloner.channels_create(guild_to, guild_from)
if data["copy_settings"]["emojis"]:
await Cloner.emojis_create(guild_to, guild_from)
print("\n> Done Cloning Server in " +
str(round(time.time() - start_time, 2)) + " seconds")
@client.event
async def on_ready():
clear(True)
await clone_server()
class ClonerBot:
def __init__(self):
self.INPUT_GUILD_ID = None
with open("./utils/config.json", "r") as json_file:
self.data = json.load(json_file)
def clear(self):
sleep(1)
os.system('cls' if os.name == 'nt' else 'clear')
Panel()
def edit_config(self, option, value, copy_settings=False):
if copy_settings:
self.data["copy_settings"][option] = value
else:
self.data[option] = value
with open("./utils/config.json", "w") as json_file:
json.dump(self.data, json_file, indent=4)
def edit_settings_function(self):
print("\nDo you want to copy:")
categories = Confirm.ask("> Categories?")
channels = Confirm.ask("> Channels?")
roles = Confirm.ask("> Roles?")
emojis = Confirm.ask("> Emojis?")
for option in ["categories", "channels", "roles", "emojis"]:
self.edit_config(option, locals()[option], copy_settings=True)
def main(self):
self.clear()
if self.data["token"] == False:
self.TOKEN = Prompt.ask("\n> Enter your Token")
sleep(0.5)
else:
print("> Token Found")
self.clear()
edit_settings = Confirm.ask("\n> Do you want to edit the settings?")
self.clear()
if edit_settings:
self.edit_settings_function()
self.clear()
self.GUILD = Prompt.ask('\n> Enter the Server ID you want to edit (Create a Server Manully)')
sleep(0.5)
self.INPUT_GUILD_ID = Prompt.ask("\n> Enter the Server ID you want to copy from")
sleep(0.5)
return self.INPUT_GUILD_ID, self.TOKEN, self.GUILD
if __name__ == "__main__":
INPUT_GUILD_ID, TOKEN, GUILD = ClonerBot().main()
try:
client.run(TOKEN, bot=False)
clear()
except Exception as e:
print(e)
print("> Invalid Token")
data["token"] = False