-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain-en.py
325 lines (296 loc) · 12.6 KB
/
main-en.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
from os import system
import psutil
import os
from pypresence import Presence
import time
import sys
import discord
import json
import traceback
from rich.table import Table
from rich.console import Console
from rich.style import Style
from rich.panel import Panel as RichPanel
from rich.progress import Progress
import asyncio
from colorama import Fore, init, Style
import platform
import inquirer
from cloner import Clone
version = '1.4'
#clones = {'Clones_test_done': 0}
console = Console()
def loading(seconds):
with Progress() as progress:
task = progress.add_task("", total=seconds)
while not progress.finished:
progress.update(task, advance=1)
time.sleep(1)
def clearall():
system('clear')
print(f"""{Style.BRIGHT}{Fore.RED}
@@@@@@@@ @@@@@@ @@@@@@@ @@@@@@@@ @@@@@@ @@@ @@@@@@ @@@ @@@ @@@@@@@@@@ @@@@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@
@@@@@@@@ @@@@@@@@ @@@@@@@@ @@@@@@@@ @@@@@@@@ @@@ @@@@@@@@ @@@ @@@ @@@@@@@@@@@ @@@@@@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@
@@! @@! @@@ @@! @@@ @@! @@! @@@ @@! @@! @@@ @@! !@@ @@! @@! @@! @@! @@@ @@! !@@ @@! @@@ @@! !@@ @@! @@@
!@! !@! @!@ !@! @!@ !@! !@! @!@ !@! !@! @!@ !@! @!! !@! !@! !@! !@! @!@ !@! @!! !@! @!@ !@! @!! !@! @!@
@!! @!@!@!@! @!@!!@! @!!!:! @!@!@!@! @!! @!@!@!@! !@@!@! @!! !!@ @!@ @!@!@!@! @!@@!@! @!@ !@! @!@@!@! @!@ !@!
!!! !!!@!!!! !!@!@! !!!!!: !!!@!!!! !!! !!!@!!!! @!!! !@! ! !@! !!!@!!!! !!@!!! !@! !!! !!@!!! !@! !!!
!!: !!: !!! !!: :!! !!: !!: !!! !!: !!: !!! !: :!! !!: !!: !!: !!! !!: :!! !!: !!! !!: :!! !!: !!!
:!: :!: !:! :!: !:! :!: :!: !:! :!: :!: !:! :!: !:! :!: :!: :!: !:! :!: !:! :!: !:! :!: !:! :!: !:!
:: :::: :: ::: :: ::: :: :: ::: :: :::: :: ::: :: ::: ::: :: :: ::: :: ::: ::::: :: :: ::: ::::: ::
: :: : : : : : : : : : : : : : :: : : : : : : :: : : : : : : ::: : : : : ::: : : :
{Style.RESET_ALL}{Fore.RESET}""")
print(
f"{Style.BRIGHT}{Fore.GREEN}New cloner in creation progress, for more information visit: {Fore.BLUE}https://discord.gg/???{Style.RESET_ALL}{Fore.RESET}"
)
def get_user_preferences():
preferences = {}
preferences['guild_edit'] = True
preferences['channels_delete'] = True
preferences['roles_create'] = True
preferences['categories_create'] = True
preferences['channels_create'] = True
preferences['emojis_create'] = False
def map_boolean_to_string(value):
return "Yes" if value else "No"
panel_title = "Config BETA"
panel_content = "\n"
panel_content += f"- Change server name and icon: {map_boolean_to_string(preferences.get('guild_edit', False))}\n"
panel_content += f"- Delete destination server channels: {map_boolean_to_string(preferences.get('channels_delete', False))}\n"
panel_content += f"- Clone roles: {map_boolean_to_string(preferences.get('roles_create', False))}\n"
panel_content += f"- Clone categories: {map_boolean_to_string(preferences.get('categories_create', False))}\n"
panel_content += f"- Clone channels: {map_boolean_to_string(preferences.get('channels_create', False))}\n"
panel_content += f"- Clone emojis: {map_boolean_to_string(preferences.get('emojis_create', False))}\n"
console.print(
RichPanel(panel_content,
title=panel_title,
style="bold blue",
width=70))
questions = [
inquirer.List(
'reconfigure',
message='Do you want to reconfigure the default settings?',
choices=['Yes', 'No'],
default='No')
]
answers = inquirer.prompt(questions)
reconfigure = answers['reconfigure']
if reconfigure == 'Yes':
questions = [
inquirer.Confirm(
'guild_edit',
message='Do you want to edit the server icon and name?',
default=False),
inquirer.Confirm('channels_delete',
message='Do you want to delete the channels?',
default=False),
inquirer.Confirm(
'roles_create',
message=
'Do you want to clone roles? (NOT RECOMMENDED TO DISABLE)',
default=False),
inquirer.Confirm('categories_create',
message='Do you want to clone categories?',
default=False),
inquirer.Confirm('channels_create',
message='Do you want to clone channels?',
default=False),
inquirer.Confirm(
'emojis_create',
message=
'Do you want to clone emojis? (IT IS RECOMMENDED TO ENABLE THIS SOLO CLONING TO AVOID ERRORS)',
default=False)
]
answers = inquirer.prompt(questions)
preferences['guild_edit'] = answers['guild_edit']
preferences['channels_delete'] = answers['channels_delete']
preferences['roles_create'] = answers['roles_create']
preferences['categories_create'] = answers['categories_create']
preferences['channels_create'] = answers['channels_create']
preferences['emojis_create'] = answers['emojis_create']
clearall()
return preferences
versao_python = sys.version.split()[0]
def restart():
python = sys.executable
os.execv(python, [python] + sys.argv)
client = discord.Client()
if platform.system() == "Windows":
system("cls")
else:
print(chr(27) + "[2J")
clearall()
while True:
token = input(
f'{Style.BRIGHT}{Fore.MAGENTA}Insert your token to proceed:{Style.RESET_ALL}{Fore.RESET}\n >'
)
guild_s = input(
f'{Style.BRIGHT}{Fore.MAGENTA}Insert the ID of the server you want to replicate:{Style.RESET_ALL}{Fore.RESET}\n >'
)
guild = input(
f'{Style.BRIGHT}{Fore.MAGENTA}Insert the ID of the destination server to paste the copied server:{Style.RESET_ALL}{Fore.RESET}\n>'
)
clearall()
print(f'{Style.BRIGHT}{Fore.GREEN}The values you inserted are:')
token_length = len(token)
hidden_token = "*" * token_length
print(
f'{Style.BRIGHT}{Fore.GREEN}Your token: {Fore.YELLOW}{hidden_token}{Style.RESET_ALL}{Fore.RESET}'
)
print(
f'{Style.BRIGHT}{Fore.GREEN}Server ID to replicate: {Fore.YELLOW}{guild_s}{Style.RESET_ALL}{Fore.RESET}'
)
print(
f'{Style.BRIGHT}{Fore.GREEN}Destination server ID to paste the copied server: {Fore.YELLOW}{guild}{Style.RESET_ALL}{Fore.RESET}'
)
confirm = input(
f'{Style.BRIGHT}{Fore.MAGENTA}Are the values correct? {Fore.YELLOW}(Y/N){Style.RESET_ALL}{Fore.RESET}\n >'
)
if confirm.upper() == 'Y':
if not guild_s.isnumeric():
clearall()
print(
f'{Style.BRIGHT}{Fore.RED}The server ID to replicate should contain only numbers.{Style.RESET_ALL}{Fore.RESET}'
)
continue
if not guild.isnumeric():
clearall()
print(
f'{Style.BRIGHT}{Fore.RED}The destination server ID should contain only numbers.{Style.RESET_ALL}{Fore.RESET}'
)
continue
if not token.strip() or not guild_s.strip() or not guild.strip():
clearall()
print(
f'{Style.BRIGHT}{Fore.RED}One or more fields are blank.{Style.RESET_ALL}{Fore.RESET}'
)
continue
if len(token.strip()) < 3 or len(guild_s.strip()) < 3 or len(
guild.strip()) < 3:
clearall()
print(
f'{Style.BRIGHT}{Fore.RED}One or more fields have less than 3 characters.{Style.RESET_ALL}{Fore.RESET}'
)
continue
break
elif confirm.upper() == 'N':
clearall()
else:
clearall()
print(
f'{Style.BRIGHT}{Fore.RED}Invalid option. Please insert Y or N.{Style.RESET_ALL}{Fore.RESET}'
)
input_guild_id = guild_s
output_guild_id = guild
token = token
clearall()
@client.event
async def on_ready():
try:
start_time = time.time()
global clones
table = Table(title="Versions", style="bold magenta", width=85)
table.add_column("Component", width=35)
table.add_column("Version", style="cyan", width=35)
table.add_row("Cloner", version)
table.add_row("Discord.py", discord.__version__)
table.add_row("Python", versao_python)
console.print(RichPanel(table))
console.print(
RichPanel(f" Successful authentication as {client.user.name}",
style="bold green",
width=69))
print(f"\n")
loading(5)
clearall()
guild_from = client.get_guild(int(input_guild_id))
guild_to = client.get_guild(int(output_guild_id))
preferences = get_user_preferences()
if not any(preferences.values()):
preferences = {k: True for k in preferences}
if preferences['guild_edit']:
await Clone.guild_edit(guild_to, guild_from)
if preferences['channels_delete']:
await Clone.channels_delete(guild_to)
if preferences['roles_create']:
await Clone.roles_create(guild_to, guild_from)
if preferences['categories_create']:
await Clone.categories_create(guild_to, guild_from)
if preferences['channels_create']:
await Clone.channels_create(guild_to, guild_from)
if preferences['emojis_create']:
await Clone.emojis_create(guild_to, guild_from)
end_time = time.time()
duration = end_time - start_time
duration_str = time.strftime("%M:%S", time.gmtime(duration))
print("\n\n")
print(
f"{Style.BRIGHT}{Fore.BLUE}The server was successfully cloned in {Fore.YELLOW}{duration_str}{Style.RESET_ALL}"
)
print(
f"{Style.BRIGHT}{Fore.BLUE}Visit our Discord server: {Fore.YELLOW}https://discord.gg/Qvf5NUtqMg{Style.RESET_ALL}"
)
#with open('saves.json', 'r') as f:
# clones = json.load(f)
#clones['Clones_test_done'] += 1
# with open('saves.json', 'w') as f:
# json.dump(clones, f)
print(
f"{Style.BRIGHT}{Fore.BLUE}Ending process and logging out from {Fore.YELLOW}{client.user}"
)
await asyncio.sleep(30)
await client.close()
except discord.LoginFailure:
print(
"Unable to authenticate with the account. Check if the token is correct."
)
except discord.Forbidden:
print("Cloning failed due to insufficient permissions.")
except discord.NotFound:
print(
"Unable to find one of the elements to be copied (channels, categories, etc.)."
)
except discord.HTTPException:
print(
"There was a communication error with the Discord API. The code will continue from where it left off in 20 seconds."
)
loading(20)
await Clone.emojis_create(guild_to, guild_from)
except asyncio.TimeoutError:
print("An error occurred: TimeOut")
except Exception as e:
print(Fore.RED + "An error occurred:", e)
print("\n")
traceback.print_exc()
panel_text = (
f"1. Incorrect server ID\n"
f"2. You are not in the inserted server\n"
f"3. Inserted server does not exist\n"
f"Still not resolved? Contact the developer at [link=https://discord.gg/Qvf5NUtqMg]https://discord.gg/Qvf5NUtqMg[/link]"
)
console.print(
RichPanel(panel_text,
title="Possible Causes and Solutions",
style="bold red",
width=70))
print(
Fore.YELLOW +
"\nThe code will restart in 20 seconds. If you don't want to wait, refresh the page and start again."
)
print(Style.RESET_ALL)
loading(20)
restart()
print(Fore.RED + "Restarting...")
try:
client.run(token, bot=False)
except discord.LoginFailure:
print(Fore.RED + "The inserted token is invalid")
print(
Fore.YELLOW +
"\n\nThe code will restart in 10 seconds. If you don't want to wait, refresh the page and start again."
)
print(Style.RESET_ALL)
loading(10)
restart()
clearall()
print(Fore.RED + "Restarting...")