Код: Выделить всё
import discord
import os
from flask.app import cli
from keep_alive import keep_alive
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
intents.messages = True
client = discord.Client(intents=discord.Intents.default())
token = os.getenv('token.env')
# Event to detect and log deleted messages
@client.event
async def on_message_delete(message):
# Response message
response = (
f"🔔 **Deleted Message Alert** 🔔\n"
f"User: {message.author}\n"
f"{message.content or 'No text content'}"
)
# Ignore messages sent by bots
if message.author.bot:
return
# Send the response to the same channel
await message.channel.send(response)
# Event to detect when the bot is pinged
@client.event
async def on_message(message):
# Check if the bot is mentioned
if client.user in message.mentions:
await message.channel.send("Hello!")
# Ensure other commands and events still work
await client.process_commands(message)
# Log when the bot is ready
@client.event
async def on_ready():
print(f"Logged in as {client.user.name} - {client.user.id}")
#server activation
keep_alive()
# Runs the bot
client.run(os.getenv("TOKEN"))
Переписал и отформатировал код по-другому. без влияния/изменений.
Использованы разделы, чтобы проверить, не вызывает ли проблема «событие обнаружения проверки связи бота», никаких изменений, кроме того, что бот не ответил на проверку связи.
Также удален текст без текста. раздел контента, в результате которого появилось пустое сообщение.
Подробнее здесь: https://stackoverflow.com/questions/793 ... cord-issue
Мобильная версия