Skip to content

Instantly share code, notes, and snippets.

@SubhrajitPrusty
Last active May 31, 2023 03:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SubhrajitPrusty/ac7f5b8981cf32f40f62c418d4e8056b to your computer and use it in GitHub Desktop.
Save SubhrajitPrusty/ac7f5b8981cf32f40f62c418d4e8056b to your computer and use it in GitHub Desktop.
Simple discord bot to kick everyone and delete all channels
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