admin管理员组

文章数量:1318580

I wrote a Discord bot that is supposed to repeat messages that were deleted by users. It responds to a ping without issue, and it composes a message if someone deletes a message, but it does not retrieve the content of the message that was deleted. The only time it is able to retrieve the content of a deleted message is if it was pinged in the message. Ex: if a message "@bot, this is a deleted message" was deleted then the bot will be able to retrieve it, but if a message "this is a deleted message" was deleted, when trying to retrieve the message it will spit out a no content error.

I am a novice at Python and would love any pointers. I have included my code below, with comments. Thank you.

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"

本文标签: Python Bot That Repeats Deleted Messages on Discord (Issue)Stack Overflow