如何将被狙击的消息发送到另一个频道? (discord.py)

How to send messages that are sniped to another channel? (discord.py)

每当删除一条消息时,我都希望将该消息发送到另一个渠道,就像日志一样。基本上每当某个频道内的消息被删除时,我希望将 sniped/deleted 消息发送到另一个频道。

例子:如果某条消息在频道X被删除,我希望消息内容转到频道Y。

代码

import discord
from discord.ext import commands
from tokens import token, CHANNEL_ID

client = commands.Bot(command_prefix='!')
client.sniped_message = None

@client.event
async def on_ready():
    print("Your bot is ready.")

@client.event
async def on_message(message):
    
    if message.channel.id == CHANNEL_ID and message.author != client.user:
        print(f'Fetched message: {message}')
        client.sniped_message = message

@client.command()
async def snipe(ctx):
    
    if ctx.channel.id != CHANNEL_ID:
        return

    if client.sniped_message is None:
        await ctx.channel.send("Couldn't find a message to fetch!")
        return

    message = client.sniped_message

    embed = discord.Embed(
        description=message.content,
        color=discord.Color.purple(),
        timestamp=message.created_at
    )
    embed.set_author(
        name=f"{message.author.name}#{message.author.discriminator}",
        icon_url=message.author.avatar_url
    )
    embed.set_footer(text=f"Message sent in: #{message.channel.name}")

    await ctx.channel.send(embed=embed)
    # assume I would be sending the embed to another channel but not sure how to tackle that

client.run(token)

非常感谢您的帮助! PS:我对Python很陌生,它和JS有很大的不同...

首先像这样获取频道 Y:

channely = client.get_channel(channel_id)

那你可以做

await channely.send(client.sniped_message)