#TypeError: MCSTRESS_srvcheck.help_listener() takes 1 positional argument but 2 were given

1 messages · Page 1 of 1 (latest)

fiery crypt
#

I have error TypeError: MCSTRESS_srvcheck.help_listener() takes 1 positional argument but 2 were given while user press the button. I use cogs, my code:

import disnake
from disnake.ext import commands
from config import mcstress_settings

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

    @commands.Cog.listener()
    async def on_ready(self):
        channel = self.bot.get_channel(1213163241790906438) # Канал 🔍・инфа-о-сервере
        await channel.purge()
        
        embed = disnake.Embed(
            title="🔍 Проверка статуса сервера",
            description="""С помощью этой функции можно проверить название, версию, онлайн, MOTD, макс. игроков, версию протокола, используемые плагины сервера. 
            
            > Чтобы начать, нажмите кнопку ниже!
            """,
            colour=0x2b2d31,
        )

        await channel.send(embed=embed, components=[
            disnake.ui.Button(label="🔍 Проверить сервер", style=disnake.ButtonStyle.blurple, custom_id="check_server"),
        ],)

    @commands.Cog.listener("on_button_click")
    async def help_listener(inter: disnake.MessageInteraction):
        if inter.component.custom_id not in ["check_server"]:
            return

        if inter.component.custom_id == "check_server":
            await inter.response.send_message("кнопка работает!")

def setup(bot):
    bot.add_cog(MCSTRESS_srvcheck(bot))
glass salmon
#

basic python class syntax. You're missing self

#

Also, do not use on_ready like that

muted lava
#

You forgot for self, correct:

async def help_listener(self, inter: disnake.MessageInteraction):
quasi sorrel