#๐Ÿ”’ kick command is not working

49 messages ยท Page 1 of 1 (latest)

upbeat mason
#

import os
import discord
import asyncio
from discord.ext import commands
import random


greetings = ["hello" , "hi" , "hey" , "wassup" , "sup" , "yo", "daddy", "mommy", "dad", "hi daddy" ]

hated_words =  ["george sucks", "george is bad", "george is stupid", "george is dumb" , "george is a dumbass", ]

bot = commands.Bot(command_prefix='!', intents=discord.Intents.all())

@bot.command()
@commands.has_permissions(administrator=True)
async def kick(ctx, member: discord.Member, *, reason = None):
    await member.kick(reason=reason)
    await ctx.channel.sends(f"User {member.mention} has been kicked for {reason}")

@bot.command()
@commands.has_permissions(administrator=True)
async def purge(ctx, amount : int):
    if amount > 100: #an if statement to check if amount is greater than 100
        await ctx.channel.purge(limit=100) #deletes 100 messages
        await ctx.channel.send("max number is 100 deleted 100 messages")
        amount = 100 #if it is greater than 50, then just set the amount to 100 by default
    await ctx.channel.purge(limit= amount + 1) 
    await ctx.channel.send(f"purged {amount} messages") #deletes the amount of messages specified
        
        
@bot.event
async def on_message(message):
    await bot.process_commands(message)
    if message.author == bot.user:
        return

    if message.content.startswith('$hello'):
        await message.channel.send('Hello!')
        
    if any(message.content.lower().strip() == word for word in greetings):
        await message.channel.send('hi')

    if any(message.content.lower().strip() == word for word in hated_words):
        await message.channel.send('he is the best l bozo') ```
valid islandBOT
#

@upbeat mason

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

grim garden
#

Is there any error message?

timber bear
#

Does purge work i heard on_message can somehow owervrite commands or something

grim garden
#

Oh right

upbeat mason
grim garden
#

At the end of your on message

upbeat mason
#

purge works

upbeat mason
grim garden
#

await bot.process_commands(message)

#

Otherwise text commands wonโ€™t work

upbeat mason
#

i swear i did it

#

purge command works

#

btw

grim garden
#

Oh ok

#

So no error message when kick?

upbeat mason
#

there is

grim garden
#

Ok can you provide the full trace back error

upbeat mason
#

Traceback (most recent call last):
File "/home/runner/moderation-bot/.pythonlibs/lib/python3.10/site-packages/discord/ext/commands/core.py", line 235, in wrapped
ret = await coro(*args, **kwargs)
File "/home/runner/moderation-bot/main.py", line 20, in kick
await member.kick(reason=reason)
File "/home/runner/moderation-bot/.pythonlibs/lib/python3.10/site-packages/discord/member.py", line 762, in kick
await self.guild.kick(self, reason=reason)
File "/home/runner/moderation-bot/.pythonlibs/lib/python3.10/site-packages/discord/guild.py", line 3648, in kick
await self._state.http.kick(user.id, self.id, reason=reason)
File "/home/runner/moderation-bot/.pythonlibs/lib/python3.10/site-packages/discord/http.py", line 739, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/runner/moderation-bot/.pythonlibs/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1350, in invoke
await ctx.command.invoke(ctx)
File "/home/runner/moderation-bot/.pythonlibs/lib/python3.10/site-packages/discord/ext/commands/core.py", line 1029, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "/home/runner/moderation-bot/.pythonlibs/lib/python3.10/site-packages/discord/ext/commands/core.py", line 244, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

grim garden
#

No kick permission?

#

Does the bot have admin perms or member kick perms?

upbeat mason
#

i aded administrator

upbeat mason
grim garden
#

Is the user also an admin

upbeat mason
#

its me

#

the admin

grim garden
#

Or is the user you are trying to kick above the bot

#

Bc then the bit isnโ€™t able to

#

Bot

upbeat mason
#

im the creator of the server

#

i should have administrator

#

im kicking a low member

#

(my alt)

grim garden
#

The bot can only kick users that are lower than the bot account on the role hierarchy

upbeat mason
#

it worke

#

but

#

it doesnt print the kicked user

#
    await ctx.channel.sends(f"User {member.mention} has been kicked for {reason}")```
grim garden
#

.sends() do you mean .send

upbeat mason
#

oooh

#

ok

#

is there an unban?

green pewter
#

Yes there is a way to unban

user = await bot.fetch_user(id)
await ctx.guild.unban(user)
#

if you mention a user you can use just the

await ctx.guild.unban(user)
valid islandBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.