Answer the question
In order to leave comments, you need to log in
How to fix this issue on Aiogram?
import config
import logging
import filters
from aiogram import Bot, Dispatcher, executor, types
from filters import IsAdminFilter
# log level
logging.basicConfig(level=logging.INFO)
# bot init
bot = Bot(token=config.TOKEN)
dp = Dispatcher(bot)
# activate filters
@dp.filters_factory.bind(IsAdminFilter)
# ban
@dp.message_handler(is_admin=True, commands=["ban"], commands_prefix="!/")
async def cmd_ban(message: types.Message):
if not message.reply_to_message:
await message.reply("NONE")
return
await message.bot.delete_message(config_GROUP_ID, message.message_id)
await message.bot.kick_chat_member(chat_id=config_GROUP_ID, user_id=message.reply_to_message.from_user.id)
await message.reply_to_message.reply("User banned!")
# remove new user joined messages
@dp.message_handler(content_types=["new_chat_members"])
async def on_user_joined(message: types.Message):
await message.delete()
# echo
@dp.message_handler()
async def echo(message: types.Message):
if "bad word" in message.text:
# profanity detected, remove
await message.delete()
#run long-polling
if __name__ == "__main__":
executor.start_polling(dp, skip_updates=True)
Traceback (most recent call last):
File "C:\Emilem\selvertone\bot.py", line 21, in <module>
async def cmd_ban(message:types.Message):
TypeError: 'NoneType' object is not callable
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question