#๐Ÿ”’ Help me with my moderation command

4 messages ยท Page 1 of 1 (latest)

supple scrollBOT
#

@storm quest

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.

storm quest
#

import discord
from discord.ext import commands
from discord import app_commands

class Moderation(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_ready(self):
        print("Moderation command is ready")
        
    @commands.command(name="clear", description="Clears a specified number of messages from the channel.")
    @commands.checks.has_permissions(manage_messages=True)
    async def delete_messages(self, interaction: discord.Interaction, amount: int):
        await interaction.response.defer()
        if amount <= 1:
            await interaction.channel.send(f"{intraction.user.mention}, you must delete at least 2 messages.")
            return
        try:
            if amount > 100:
               amount = 100
            deleted_messages = await interaction.channel.purge(limit=amount)
            await interaction.channel.send(f"{interaction.user.mention}, {len(deleted_messages)} messages")
        except Exeption as e:
            print(f"An error occurred: {e}")
            await interaction.channel.send(f"{interaction.user.mention}, an error has occurred")

it keep throwing error discord.ext.commands has no attribute checks do u mean check the code worked yesterday i modified abit after that its throwing this error

supple scrollBOT
#

@storm quest

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.