Skip to content

Commit

Permalink
Guildbomb 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ARealWant authored Jan 1, 2023
1 parent 92657cb commit a8fb7a3
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
176 changes: 176 additions & 0 deletions GuildbombNEW/Features/cmd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
import asyncio

import discord
from discord import app_commands
from discord.app_commands import Group
from discord.ext import commands
from discord.ext.commands import has_permissions
from Features.reset import RESET


class CMD(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot

@commands.Cog.listener()
async def on_ready(self):
print("EXTENSION LOADED: RAID MODULE SUCCESSFULLY LOADED")

reset = Group(name='start', description='Start a reset')

@reset.command(name="channels", description="Start a channel reset")
@app_commands.describe(confirm="Confirm the deletion of all channels in the server")
async def channels(self, interaction: discord.Interaction, confirm: bool = False):
'''
Deletes all channels in the guild
:param interaction: The interaction object
:param confirm: Whether or not to confirm the action
'''
if confirm:
try:
reset = RESET(interaction)
await reset.delete_channels()
return await interaction.response.send_message("> ***✅ All channels have been successfully "
"deleted from the server {}***".format(
interaction.guild.name))
except Exception as e:
await interaction.response.send_message(f"> ***❌ ERROR: {e}***", ephemeral=True)
return print(f"ERROR: {e}")
else:
return await interaction.response.send_message(
"> ***❌ This command requires confirmation. Please run the command "
"again with the confirm argument set to True***", ephemeral=True)

@reset.command(name="roles", description="Start a role reset")
@app_commands.describe(confirm="Confirm the deletion of all roles in the server")
async def roles(self, interaction: discord.Interaction, confirm: bool = False):
'''
Deletes all roles in the guild
:param interaction: The interaction object
:param confirm: Whether or not to confirm the action
'''
if confirm:
try:
reset = RESET(interaction)
await reset.delete_roles()
return await interaction.response.send_message("> ***✅ All roles have been successfully "
"deleted from the server {}***".format(
interaction.guild.name))
except Exception as e:
await interaction.response.send_message(f"> ***❌ ERROR: {e}***", ephemeral=True)
return print(f"ERROR: {e}")
else:
return await interaction.response.send_message(
"> ***❌ This command requires confirmation. Please run the command "
"again with the confirm argument set to True***", ephemeral=True)

@reset.command(name="emojis", description="Start an emoji reset")
@app_commands.describe(confirm="Confirm the deletion of all emojis in the server")
async def emojis(self, interaction: discord.Interaction, confirm: bool = False):
'''
Deletes all emojis in the guild
:param interaction: The interaction object
:param confirm: Whether or not to confirm the action
'''
if confirm:
try:
reset = RESET(interaction)
await reset.delete_emojis()
return await interaction.response.send_message("> ***✅ All emojis have been successfully "
"deleted from the server {}***".format(
interaction.guild.name))
except Exception as e:
await interaction.response.send_message(f"> ***❌ ERROR: {e}***", ephemeral=True)
return print(f"ERROR: {e}")
else:
return await interaction.response.send_message(
"> ***❌ This command requires confirmation. Please run the command "
"again with the confirm argument set to True***", ephemeral=True)

@reset.command(name="webhooks", description="Start a webhook reset")
@app_commands.describe(confirm="Confirm the deletion of all webhooks in the server")
async def webhooks(self, interaction: discord.Interaction, confirm: bool = False):
'''
Deletes all webhooks in the guild
:param interaction: The interaction object
:param confirm: Whether or not to confirm the action
'''
if confirm:
try:
reset = RESET(interaction)
await reset.delete_webhooks()
return await interaction.response.send_message("> ***✅ All webhooks have been successfully "
"deleted from the server {}***".format(
interaction.guild.name))
except Exception as e:
await interaction.response.send_message(f"> ***❌ ERROR: {e}***", ephemeral=True)
return print(f"ERROR: {e}")
else:
return await interaction.response.send_message(
"> ***❌ This command requires confirmation. Please run the command "
"again with the confirm argument set to True***", ephemeral=True)

@reset.command(name="members", description="Start a member reset")
@app_commands.describe(confirm="Confirm the ban of all members in the server")
async def members(self, interaction: discord.Interaction, confirm: bool = False):
'''
Bans all members in the guild
:param interaction: The interaction object
:param confirm: Whether or not to confirm the action
'''
if confirm:
try:
reset = RESET(interaction)
await reset.delete_members()
return await interaction.response.send_message("> ***✅ All members have been successfully "
"banned from the server {}***".format(
interaction.guild.name))
except Exception as e:
await interaction.response.send_message(f"> ***❌ ERROR: {e}***", ephemeral=True)
return print(f"ERROR: {e}")
else:
return await interaction.response.send_message(
"> ***❌ This command requires confirmation. Please run the command "
"again with the confirm argument set to True***", ephemeral=True)

@reset.command(name="all", description="Start a full reset")
@app_commands.describe(
confirm="Confirm the deletion of all channels, roles, emojis, webhooks, and members in the server",
leave="Leave the server after the reset")
async def all(self, interaction: discord.Interaction, confirm: bool = False, leave: bool = False):
'''
Deletes all channels, roles, emojis, webhooks, and bans all members in the guild
:param interaction: The interaction object
:param confirm: Whether or not to confirm the action
'''
if confirm:
try:
reset = RESET(interaction)
await reset.delete_channels()
await reset.delete_roles()
await reset.delete_emojis()
await reset.delete_webhooks()
await reset.delete_members()
if leave:
await interaction.response.send_message("> ***✅ All channels, roles, emojis, webhooks, "
"and members have been successfully "
"deleted from the server {}***".format(
interaction.guild.name))
await asyncio.sleep(5)
return await interaction.guild.leave()
else:
return await interaction.response.send_message("> ***✅ All channels, roles, emojis, webhooks, "
"and members have been successfully "
"deleted from the server {}***".format(
interaction.guild.name))
except Exception as e:
await interaction.response.send_message(f"> ***❌ ERROR: {e}***", ephemeral=True)
return print(f"ERROR: {e}")
else:
return await interaction.response.send_message(
"> ***❌ This command requires confirmation. Please run the command "
"again with the confirm argument set to True***", ephemeral=True)


async def setup(bot: commands.Bot):
await bot.add_cog(CMD(bot))
58 changes: 58 additions & 0 deletions GuildbombNEW/Features/reset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import discord


class RESET():
def __init__(self, interaction: discord.Interaction):
self.guild = interaction.guild
self.guild_id = interaction.guild.id
if len(self.guild.members) > 100:
print("Guild has more than 100 members, please read the README for more information")
raise Exception("Guild has more than 100 members, please read the README for more information")
if not self.guild.me.guild_permissions.administrator:
print("Bot does not have administrator permission")
raise Exception("Bot does not have administrator permission")
if not interaction.user.guild_permissions.administrator:
print("User does not have administrator permission")
raise Exception("User does not have administrator permission")

async def delete_channels(self):
for channel in self.guild.channels:
try:
await channel.delete(reason="Server reset")
except discord.Forbidden:
pass

async def delete_roles(self):
for role in self.guild.roles:
try:
await role.delete(reason="Server reset")
except discord.Forbidden:
pass

async def delete_emojis(self):
for emoji in self.guild.emojis:
try:
await emoji.delete(reason="Server reset")
except discord.Forbidden:
pass

async def delete_webhooks(self):
for webhook in await self.guild.webhooks():
try:
await webhook.delete(reason="Server reset")
except discord.Forbidden:
pass

async def delete_members(self):
for member in self.guild.members:
try:
await member.ban(reason="Server reset")
except discord.Forbidden:
pass

async def delete_all(self):
await self.delete_channels()
await self.delete_roles()
await self.delete_emojis()
await self.delete_webhooks()
await self.delete_members()
3 changes: 3 additions & 0 deletions GuildbombNEW/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"token": ""
}
31 changes: 31 additions & 0 deletions GuildbombNEW/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import asyncio
import json

import discord
from discord.ext import commands

intents = discord.Intents.all()
bot = commands.Bot(command_prefix="!",
case_insensitive=True, intents=intents,
help_command=None, status=discord.Status.offline)

@bot.event
async def on_ready():
print("BOT ONLINE: BOT \"{}\" SUCCESSFULLY STARTED".format(bot.user.name))
await bot.tree.sync()

with open("config.json", "r") as f:
config = json.load(f)
if config["token"] == "":
print("ERROR: TOKEN NOT FOUND")
token = input("Enter the token: ")
config["token"] = token
with open("config.json", "w") as f:
json.dump(config, f, indent=4)

async def main():
async with bot:
await bot.load_extension('Features.cmd')
await bot.start(config["token"])

asyncio.run(main())

0 comments on commit a8fb7a3

Please sign in to comment.