Answer the question
In order to leave comments, you need to log in
An error in the discord bot code. How to do it right?
Mistake:
discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias.
import discord
from discord.ext.commands import has_permissions
from discord.ext import commands
PREFIX = '&'
client = commands.Bot( command_prefix = PREFIX )
@client.event
async def on_ready():
print( 'Bot connected' )
@client.command( pass_context = True )
@has_permissions( administrator = True )
async def clear( ctx, amount = 100 ):
await ctx.channel.purge( limit = amount )
@client.command( pass_context = True )
@has_permissions( administrator = True )
async def kick( ctx, member: discord.Member, *, reason = None ):
await ctx.channel.purge( limit = 1 )
await member.kick( reason = reason )
await ctx.send( f'kick user { member.mention }' )
@client.command( pass_context = True )
@has_permissions( administrator = True )
async def ban( ctx, member: discord.Member, *, reason = None ):
await ctx.channel.purge( limit = 1 )
await member.ban( reason = reason )
await ctx.send( f'ban user { member.mention }' )
@client.command( pass_context = True )
async def help( ctx ):
ebm = discord.Embed( title = 'Все наши команды' )
emb.add_field( name = '{}help'.format( PREFIX ), value = 'Помощь по командам' )
emb.add_field( name = '{}helpme'.format( PREFIX ), value = 'Помощь по командам в личку' )
emb.add_field( name = '{}clear'.format( PREFIX ), value = 'очистка чата (только для админов)' )
emb.add_field( name = '{}kick'.format( PREFIX ), value = 'кикнуть юзера (только для админов)' )
emb.add_field( name = '{}ban'.format( PREFIX ), value = 'забанить юзера (только для админов)' )
await ctx.send( embed = emb )
client.run( 'мой токен' )
NameError: name 'has_permissions' is not defined
from discord.ext.commands import has_permissions
@client.command( pass_context = True )
async def help( ctx ):
ebm = discord.Embed( title = 'Все наши команды' )
emb.add_field( name = '{}help'.format( PREFIX ), value = 'Помощь по командам' )
emb.add_field( name = '{}helpme'.format( PREFIX ), value = 'Помощь по командам в личку' )
emb.add_field( name = '{}clear'.format( PREFIX ), value = 'очистка чата (только для админов)' )
emb.add_field( name = '{}kick'.format( PREFIX ), value = 'кикнуть юзера (только для админов)' )
emb.add_field( name = '{}ban'.format( PREFIX ), value = 'забанить юзера (только для админов)' )
await ctx.send( embed = emb )
Answer the question
In order to leave comments, you need to log in
Translate the text of the error with Google and try to answer your own question.
You could just translate the text of the error and understand what the problem is, but I will help. Add client.remove_command('help')
Full Code:
import discord
from discord.ext.commands import has_permissions
from discord.ext import commands
PREFIX = '&'
client = commands.Bot( command_prefix = PREFIX )
@client.event
async def on_ready():
print( 'Bot connected' )
@client.command( pass_context = True )
@has_permissions( administrator = True )
async def clear( ctx, amount = 100 ):
await ctx.channel.purge( limit = amount )
@client.command( pass_context = True )
@has_permissions( administrator = True )
async def kick( ctx, member: discord.Member, *, reason = None ):
await ctx.channel.purge( limit = 1 )
await member.kick( reason = reason )
await ctx.send( f'kick user { member.mention }' )
@client.command( pass_context = True )
@has_permissions( administrator = True )
async def ban( ctx, member: discord.Member, *, reason = None ):
await ctx.channel.purge( limit = 1 )
await member.ban( reason = reason )
await ctx.send( f'ban user { member.mention }' )
@client.command( pass_context = True )
async def help( ctx ):
ebm = discord.Embed( title = 'Все наши команды' )
emb.add_field( name = '{}help'.format( PREFIX ), value = 'Помощь по командам' )
emb.add_field( name = '{}helpme'.format( PREFIX ), value = 'Помощь по командам в личку' )
emb.add_field( name = '{}clear'.format( PREFIX ), value = 'очистка чата (только для админов)' )
emb.add_field( name = '{}kick'.format( PREFIX ), value = 'кикнуть юзера (только для админов)' )
emb.add_field( name = '{}ban'.format( PREFIX ), value = 'забанить юзера (только для админов)' )
await ctx.send( embed = emb )
client.run( 'мой токен' )
from discord.ext.commands import has_permissions
instead@has_permissions(administrator=True)
The help command is already there, here is the code, replace it with yours:
client = commands.Bot( command_prefix = PREFIX )
client.remove_command('help')
here is the better help command:
@client.command( pass_context = True )
async def help( ctx ):
ebm = discord.Embed( title = 'Все наши команды' )
emb.add_field( name = f'{ PREFIX }help', value = 'Помощь по командам' )
emb.add_field( name = f'{ PREFIX }helpme', value = 'Помощь по командам в личку' )
emb.add_field( name = f'{ PREFIX }clear', value = 'очистка чата (только для админов)' )
emb.add_field( name = f'{ PREFIX }kick', value = 'кикнуть юзера (только для админов)' )
emb.add_field( name = f'{ PREFIX }ban', value = 'забанить юзера (только для админов)' )
await ctx.send( embed = emb )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question