Skip to content
Sign upLog in
← Back to Community

How to fix my moderator bot?

Profile icon
Nithen

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

Voters
Profile icon
Nithen
Comments
hotnewtop
Profile icon
VulcanWM

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)
Profile icon
Nithen

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

Profile icon
VulcanWM

%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

Profile icon
VulcanWM

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

Profile icon
Nithen

@VulcanWM
its showing that mke_embed is not defined

Profile icon
VulcanWM

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

Profile icon
Nithen

@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?

Profile icon
VulcanWM

give the bot admin perms

@Nithen

Profile icon
Nithen

Oh ok I will do that

@VulcanWM

Profile icon
VulcanWM

works?

@Nithen

Profile icon
Nithen

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

Profile icon
VulcanWM

Which error is coming up?

Profile icon
Nithen

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