Я пытаюсь реализовать какую-то функцию, когда, если кто-то отправляет приглашение Discord, его забанят, но я получаю одну и ту же ошибку каждый раз:
'BotLibertarin' object has no attribute 'ban'
Вот код:
import discord
from discord.ext import commands
class BotLibertarin(discord.Client):
client = commands.Bot(command_prefix='.')
@client.event
async def on_ready(self):
print(f"Logged on as {self.user}")
@client.event
async def on_message(self, message):
print(f"message from {message.author} what he said {message.content} and the id is {message.author.id}")
if message.author == client.user:
return
#ban for invinte on discord
if message.content.startswith("https://discord.gg/"):
for member in client.get_all_members():
print("entrou dentro do if")
if member.id == message.author.id:
print("vai tomar ban KKKKKK")
banned = member.id
try:
await client.ban(banned,delete_message_days=2)
await message.channel.send(f"User {banned} sended a discord invite")
except Exception as e:
print(f"you got error {e}")
client = BotLibertarin()
client.run("")