Rapptz / discord.py

An API wrapper for Discord written in Python.
http://discordpy.rtfd.org/en/latest
MIT License
14.93k stars 3.77k forks source link

Unknown Error #1187

Closed Drakonix000 closed 6 years ago

Drakonix000 commented 6 years ago

I'm making a bot using discord.py for kicking players.

from discord.ext.commands import Bot
from discord.ext import commands
import discord

bot_prefix = "`"
token = "NDMxNDc1OTU1NjYwNDg4NzA0.DafS4A.fIXEkLtWfZkmLjtduBPhq51hN5E"

client = Bot(command_prefix = bot_prefix)

@client.command(name='kick',
                brief="Kick a player",
                description="Kick",
                pass_context = True)
async def kick(context):
    kick(context.message.mentions[0].id)

client.run(token)

But when someone uses the kick command it doesn't work and gets this error.

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'Command' object is not callable
paris-ci commented 6 years ago

Change your token

Harmon758 commented 6 years ago

First off, you're going to want to regenerate your token now.

async def kick(context):
    kick(context.message.mentions[0].id)

In this kick command, you're trying to recursively call the kick command. That's why it's raising an error telling you that Command objects aren't callable. What you're probably looking for is https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.kick. However, note that Client.kick accepts a Member object as a parameter rather than an ID.

This isn't an issue with discord.py, and for future questions like this, you should join either the official discord.py server or the Discord API server for help, as the README recommends.

paris-ci commented 6 years ago

Multiple things wrong with your code too :