Пишу бота для своего сервера, у меня работали команды до сегодняшнего дня. Бот попросту не реагирует на них в discord. В документации discord.py было написано, что это может возникать от ивента on_message
и нужно добавить в код await bot.process_commands(message)
, тогда команды должны заработать, но по итогу ничего не изменилось.
Вот сам код.
import random
import asyncio
import discord
from discord.ext import commands
config = {
'token': 'токен',
'prefix': '% ',
}
bot = commands.Bot(command_prefix=config['prefix'], intents=discord.Intents.all())
@bot.event
async def on_ready():
await bot.change_presence(activity=discord.Game(name=f'Foxhole'))
ping_1 = '1'
ping_2 = '2'
ping_3 = '3'
@bot.event
async def on_message(message):
if bot.user in message.mentions:
await message.channel.send(random.choice([ping_1,ping_2,ping_3]))
await bot.process_commands(message)
@bot.command()
async def text(ctx):
await ctx.channel.purge(limit=1)
await ctx.send("Текст")
@bot.command()
async def add(ctx, *, on_message):
if ctx.author != bot.user:
await ctx.channel.purge(limit=1)
await ctx.send('```' + on_message + '```')
bot.run(config['token'])