最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Python Bot That Repeats Deleted Messages on Discord (Issue) - Stack Overflow

programmeradmin0浏览0评论

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"
发布评论

评论列表(0)

  1. 暂无评论