Last active
March 15, 2025 18:58
-
-
Save SubhrajitPrusty/ac7f5b8981cf32f40f62c418d4e8056b to your computer and use it in GitHub Desktop.
Simple discord bot to kick everyone and delete all channels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import discord | |
from discord.ext.commands import has_permissions, MissingPermissions | |
from discord.ext import commands | |
intents = discord.Intents.default() | |
intents.members = True | |
bot = commands.Bot(command_prefix='!', intents=intents) | |
@bot.command() | |
@has_permissions(kick_members=True) | |
async def kick(ctx, reason: str=None): | |
print("in here") | |
print(ctx.guild.members) | |
for member in ctx.guild.members: | |
print(member) | |
try: | |
if member != bot.user and member.id != ctx.guild.owner: | |
await member.kick(reason=reason) | |
except Exception as e: | |
print(e) | |
@bot.command() | |
async def del_chan(ctx): | |
print("deleting channels") | |
print(ctx.guild.channels) | |
for channel in ctx.guild.channels: | |
print(channel) | |
try: | |
await channel.delete() | |
except: | |
print(f"{channel} cannot be deleted") | |
@bot.event | |
async def on_ready(): | |
print(bot.guilds) | |
print('We have logged in as {0.user}'.format(bot)) | |
@bot.event | |
async def on_message(message): | |
print("inside func") | |
# print(message) | |
if message.author == bot.user or message.author.bot: | |
return | |
await bot.process_commands(message) | |
bot.run('TOKEN HERE') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment