Ask coding questions

← Back to all posts
How to fix my moderator bot?
Nithen (0)

I have made a moderator bot in Discord to kick/ban members. Its not working; please help me!

Comments
hotnewtop
VulcanWM (2305)

try:

@commands.has_permissions(kick_members=True)
@bot.command()
async def kick(ctx, user: discord.Member, *, reason="No reason provided"):
        await user.kick(reason=reason)
        kick = discord.Embed(title=f":boot: Kicked {user.name}!", description=f"Reason: {reason}\nBy: {ctx.author.mention}")
        await ctx.message.delete()
        await ctx.channel.send(embed=kick)
        await user.send(embed=kick)

@commands.has_permissions(ban_members=True)
@bot.command()
async def ban(ctx, user: discord.Member, *, reason="No reason provided"):
        await user.ban(reason=reason)
        ban = discord.Embed(title=f":boom: Banned {user.name}!", description=f"Reason: {reason}\nBy: {ctx.author.mention}")
        await ctx.message.delete()
        await ctx.channel.send(embed=ban)
        await user.send(embed=ban)
Nithen (0)

@VulcanWM its still not working. to activate it, I have to put %kick @person, ryt?

VulcanWM (2305)

%kick @user reason
try using this code when defining the client and the bot:

import discord
prefix = "%"
bot = discord.Client()
bot = commands.Bot(command_prefix=prefix)
bot.remove_command('help')

@Nithen

VulcanWM (2305)

and add this code to the bot to show the error:

@bot.event
async def on_command_error(ctx, error):
  embed = make_embed(title="Error", desc="")
  embed.add_field(name=":face_with_raised_eyebrow: ", value=error)
  await ctx.send(embed=embed)

@Nithen

Nithen (0)

@VulcanWM its showing that mke_embed is not defined

VulcanWM (2305)

replace the code above with this:

@bot.event
async def on_command_error(ctx, error):
  embed = discord.Embed(title="Error", desc="")
  embed.add_field(name=":face_with_raised_eyebrow: ", value=error)
  await ctx.send(embed=embed)

@Nithen

Nithen (0)

@VulcanWM Ok so.. I tried it and the bot responded with the error "Error Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions"

however, I have the kick members permission. what should I do?

VulcanWM (2305)

give the bot admin perms @Nithen

Nithen (0)

Oh ok I will do that

@VulcanWM

Nithen (0)

@VulcanWM nope... it already had the permission, yet couldn't do it

VulcanWM (2305)

Which error is coming up?

Nithen (0)

@VulcanWM there is no error. it just doesn't respond at all