Проблема с ботом на python.
Есть код, он создан на языке Python 3. Бот должен проверять сообщение пользователя на оскорбления. Но есть проблема в том что при отправке команды или сообщения, оно дублируется.
Сразу скажу что консоль включена всего одна.
Основной файл:
import discord
from discord.ext import commands
import os
import main
token = main.token
prefix = main.prefix
client = commands.Bot ( command_prefix = prefix )
client.remove_command ("help")
@client.command ()
async def load (ctx, extension): # Функция загрузки кога
if ctx.author.id == 716054757327896588:
client.load_extension (f"cogs.{extension}")
await ctx.send ("Cogs is loaded...")
else:
await ctx.send ("Вы не разработчик")
@client.command ()
async def unload (ctx, extension): # Функция выключения когда
if ctx.author.id == 716054757327896588:
client.unload_extension (f"cogs.{extension}")
await ctx.send ("Cogs is unloaded...")
else:
await ctx.send ("Вы не разработчик")
@client.command ()
async def reload (ctx, extension): # Функция перезагрузки
if ctx.author.id == 716054757327896588:
client.unload_extension (f"cogs.{extension}")
client.load_extension (f"cogs.{extension}")
await ctx.send ("Cogs is reloaded...")
else:
await ctx.send ("Вы не разработчик")
for filename in os.listdir ('./cogs/'):
if filename.endswith (".py"):
client.load_extension (f"cogs.{filename [:-3]}")
client.run (token)
Файл для проверки сообщений:
import discord
from discord.ext import commands
from datetime import *
import os
class User (commands.Cog):
def __init__ (self, client):
self.client = client
@commands.Cog.listener ()
async def on_message(self, message):
await self.client.process_commands(message)
msg = message.content.lower()
for i in bad_word:
if i in msg:
await message.delete()
await message.author.send(embed = discord.Embed(description = f'{message.author}, не матерись!!!',color=0x0c0c0c))
def setup (client):
client.add_cog (User (client))
Заранее спасибо.
Вроде бы внутри, что-то должно быть написано
@client.command ()