Answer the question
In order to leave comments, you need to log in
Hello, I'm writing a discord bot in Python, kick doesn't work, what's my mistake?
Here is the code:
import discord
from discord.ext import commands
bot = commands.Bot( command_prefix = "/" ) #Connect
visibility
class MyClient( discord.Client ):
async def on_ready( self ):
print( "Logged in as {0} ! ".format( self.user ) ) #Prints
message and user to console
async def on_message( self, message ):
print( "Message from {0.author}: {0.content}".format(message) )
# Kick
bot.command( pass_context = True )
@commands.has_permissions( administrator = True )
async def kick( ctx, member:discord.Member, *, reason = None ):
await member.kick( reason = reason )
client = MyClient( )
client.run( 'token' )
Answer the question
In order to leave comments, you need to log in
lolikcheck09 , button </>
Next, I don't understand what client you work with?
Or are you working with MyClient() or are you working with discord.ext.commands.Bot()?
Because Bot() is a descendant of Client(). You use its decorator, i.e. you subscribe your functions to its events, but at the same time you do not start the bot, but you start the instance of MyClient ().
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question