R
R
Ramazan Ramazanov2021-07-15 13:11:13
Python
Ramazan Ramazanov, 2021-07-15 13:11:13

I create my own filter for Tbot ​​in aiogram, the error MyFilter() takes no arguments comes out. wat tu doo?

from aiogram.dispatcher.filters import BoundFilter
from aiogram import types
class MyFilter(BoundFilter):
    key = 'is_admin'

def __init__(self, is_admin):
    self.isin = is_admin

async def check(self, message: types.Message):
    member = await bot.get_chat_member(message.chat.id, message.from_user.id)
    return member.is_chat_admin()


The error itself is:
TypeError: MyFilter() takes no arguments

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Shevkunov, 2021-07-15
@RomaIzdaga

Well, you have init and check not class methods, but separate functions, you forgot the indent

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question