【问题标题】:Why can't I remove embed without deleting the message?为什么我不能在不删除消息的情况下删除嵌入?
【发布时间】:2021-10-17 09:55:21
【问题描述】:

我想在不删除邮件的情况下删除 嵌入。在文档中写道,如果 embed = None,嵌入将被删除。我有: discord=1.7.3 和 discord.py=1.7.3

但这对我不起作用。

@commands.command()
async def lol(self, ctx):
    embed = discord.Embed(title='Title', description='description', color=discord.Colour.gold())
    embed.add_field(name='name', value=f'value', inline=False)
    msg = await ctx.channel.send(embed=embed)
    await asyncio.sleep(1)
    await msg.edit(content='content', embed=None)

【问题讨论】:

  • 您是否尝试过改用suppress 关键字参数?
  • 我试过了,但是没用。
  • 对我来说,它完全按照你说的那样工作,没有问题
  • 如果它不起作用我可以推荐的是尝试更新 discord.py
  • 我有最新版本的 discord.py。我不知道为什么它对我不起作用。

标签: python python-3.x discord discord.py


【解决方案1】:

我发现了问题所在。我使用“discord_components”库来使用不和谐按钮。只有在初始化“discord_components”时才会出现问题。

import discord
import discord.ext
import asyncio
from discord.ext import commands, tasks
from discord_components import DiscordComponents, Button, ButtonStyle, InteractionType

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

@client.event
async def on_ready():
    DiscordComponents(client)
    print('----------Ready---------')

@client.command()
async def lol(ctx):
    embed = discord.Embed(title='Title', description='description', color=discord.Colour.gold())
    embed.add_field(name='name', value=f'value', inline=False)
    msg = await ctx.channel.send(embed=embed)
    await asyncio.sleep(5)
    await msg.edit(content='content', embed=None, suppress=True)

client.run('***********************************************************')

【讨论】:

  • 确保当您提出问题时,您有一个完全重现问题的代码示例。 minimal reproducible example
  • 我以后会小心的。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-02-22
  • 2021-06-12
  • 1970-01-01
  • 1970-01-01
  • 2022-06-17
  • 1970-01-01
  • 2018-11-25
相关资源
最近更新 更多