L
L
lolikcheck092021-11-09 19:16:08
Python
lolikcheck09, 2021-11-09 19:16:08

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

1 answer(s)
V
Vindicar, 2021-11-09
@Vindicar

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 question

Ask a Question

731 491 924 answers to any question