Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Callback is already a command. #2405

Closed
3 tasks done
Agoo1234 opened this issue Oct 31, 2019 · 5 comments
Closed
3 tasks done

TypeError: Callback is already a command. #2405

Agoo1234 opened this issue Oct 31, 2019 · 5 comments
Labels
invalid This is not right.

Comments

@Agoo1234
Copy link

Summary

So, my bot was working just fine, but then the next time I run it, it keeps giving me the error saying: TypeError: Callback is already a command. I checked to see if it meant that I already had a command, but that was the only one. I tried to comment out that command, but then it just went to the next command with the same error. I don't exactly get what it means, so please help.

Reproduction Steps

Expected Results

I just want it to stop giving me that error so it can start again.

Actual Results

    async def ban(ctx, member : discord.Member, *, reason=None):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/discord/ext/commands/core.py", line 1086, in decorator
    result = command(*args, **kwargs)(func)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/discord/ext/commands/core.py", line 1240, in decorator
    raise TypeError('Callback is already a command.')
TypeError: Callback is already a command.

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from the display, if visible.

System Information

I am using the latest version of discord.py rewrite(I forgot what it exactly is) and am using Mac OS. The coding softwares I use are IDLE 3.7.3 and repl.it also python3

Here is the link to my code: it is specifically for children, so please don't criticize.

@Zomatree
Copy link
Contributor

@bot.command(pass_context=True)

#@bot.command(pass_context=True)
#@commands.has_permissions(manage_roles = True)
#async def verify(ctx):
#    await add_roles(Verified, reason=None, atomic=True)
#    await ctx.send("Added role...?")

#@verify.error
#async def verify_error(ctx,error):
#    if isinstance(error, commands.MissingPermissions):
#        ctx.send("You can't add other roles without the permissions in real life")

#@bot.command(pass_context=True)
#@commands.has_permissions(kick_members = True)
#async def kick(ctx, member : discord.Member, *, reason=None):
#    await member.kick(reason=reason)
#    await member.channel.send("<@"+discord.Member.id+"> was kicked. \n Reason: "+str(reason))
#    channel = bot.get_channel(627286906995998740)
#    await channel.send("\n \n "+str(ctx.message.author)+" banned "+str(member)+". \n **Reason:** "+str(reason)+("\n\n **In the Server:** ")+str(ctx.message.guild))

#@kick.error
#async def kick_error(ctx, error):
#    if isinstance(error,commands.MissingPermissions):
#        await ctx.send(str(member)+" was kicked. \n Reason: "+str(reason))
#        print(str(member)+" was kicked. \n Reason: "+str(reason))
@bot.command(pass_context = True)
@commands.has_permissions(ban_members = True)

you have the decorator twice here

@Agoo1234
Copy link
Author

@Zomatree Thank you! I was so stupid not to notice that!

@Harmon758
Copy link
Contributor

For future help like this, you should join either the official discord.py server or the Discord API server, as the README also links.

@dpy-manager-bot dpy-manager-bot added the invalid This is not right. label Oct 31, 2019
@ghost
Copy link

ghost commented May 3, 2020

Who can solve this?

import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
import pyowm

owm = pyowm.OWM('')

TOKEN = ''

prefix = '/'
bot = commands.Bot(command_prefix=prefix) #инициализируем бота с префиксом 'prefix'
@bot.command()
@bot.command(pass_context=True) #разрешаем передавать аргументы

@bot.command()
async def weather(ctx, town) :
	await ctx.send("Your town is " + town)
	observation = owm.weather_at_place(town)
	weather = observation.get_weather()
	await ctx.send('In town: ' + town + ' now' + weather)

@bot.command()
async def add(ctx, a: int, b: int):
    await ctx.send(a+b)

@bot.command()
async def multiply(ctx, a: int, b: int):
    await ctx.send(a*b)



@bot.event
async def on_ready():
	activity = discord.Activity(type=discord.ActivityType.listening, name="their masters clebold & KØT")
	await bot.change_presence(status=discord.Status.idle, activity=activity)
print('Bot is ready!')

bot.run(TOKEN)

image

@avayert
Copy link

avayert commented May 3, 2020

You have two @bot.command decorators on top of your async function.

This is not an issue with discord.py, and GitHub issues for this repository should be used to report issues with this library.

For further help specific to using this library, you should join the official discord.py server, as the README recommends.

Repository owner locked as resolved and limited conversation to collaborators May 3, 2020
Repository owner deleted a comment from helish88 May 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
invalid This is not right.
Projects
None yet
Development

No branches or pull requests

5 participants