Не работает on_message
Код:
import config
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='r!', intents=intents)
@bot.event
async def on_ready():
print("Bot ready!")
@bot.event
async def on_message(message):
print("on_message")
if message.author == bot.user:
print("Sender is not user")
if message.channel.id == 1126833110605103194:
print("Channel is 1126833110605103194")
await message.channel.send(message.content)
@bot.command()
async def ping(ctx):
await ctx.send('pong')
bot.run("token")
Логи бота после сообщения в нужном канале:
2023-07-07 19:23:51 INFO discord.client logging in using static token
2023-07-07 19:23:52 INFO discord.gateway Shard ID None has connected to Gateway (Session ID: 8863fa4af4fff98408ffb50ca612686c).
Bot ready!
Что делать?
Источник: Stack Overflow на русском