how can i hide that? user used /slash command in discord (discord.py)

huangapple go评论108阅读模式
英文:

how can i hide that? user used /slash command in discord (discord.py)

问题

我可以在创建嵌入消息的功能中隐藏用户使用的斜杠命令吗?

@bot.hybrid_command()
@app_commands.guilds(discord.Object(id = SERVID))
async def criar_embed(ctx, titulo: str, descricao: str, cor: discord.Color, footer_text: str = None, field_name: str = None, field_value: str = None, timestamp: bool = False):
    embed = discord.Embed(
        title=titulo,
        description=descricao,
        color=cor
    )
    embed.set_thumbnail(url='https://m.media-amazon.com/images/I/41YSLRQ0QYL.jpg')
    
    if footer_text:
        embed.set_footer(text=footer_text)
    
    if field_name and field_value:
        embed.add_field(name=field_name, value=field_value)
    
    if timestamp:
        now = datetime.datetime.now()
        formatted_time = now.strftime("%d/%m/%Y")  # Formato da data e hora
        embed.timestamp = now
        embed.set_footer(text=f"{formatted_time}")
    
    await ctx.send(embed=embed)

图片中的紫色线条表示审查。

这里是我所说的内容的图片

英文:

can i hide that -user used /slash_command - in the embed message create feature?

@bot.hybrid_command()
@app_commands.guilds(discord.Object(id = SERVID))
async def criar_embed(ctx, titulo: str, descricao: str, cor: discord.Color, footer_text: str = None, field_name: str = None, field_value: str = None, timestamp: bool = False):
    embed = discord.Embed(
        title=titulo,
        description=descricao,
        color=cor
    )
    embed.set_thumbnail(url='https://m.media-amazon.com/images/I/41YSLRQ0QYL.jpg')
    
    if footer_text:
        embed.set_footer(text=footer_text)
    
    if field_name and field_value:
        embed.add_field(name=field_name, value=field_value)
    
    if timestamp:
        now = datetime.datetime.now()
        formatted_time = now.strftime("%d/%m/%Y")  # Formato da data e hora
        embed.timestamp = now
        embed.set_footer(text=f"{formatted_time}")
    
    await ctx.send(embed=embed)

the purple lines in the image = censorship

image of the thing that i'm saying here

答案1

得分: 1

机器人将始终回复运行斜杠命令的用户,但可以通过以下方式使交互回复对除使用者之外的所有人隐藏,然后使用类似以下代码将嵌入发送到频道:

if timestamp:
    now = datetime.datetime.now()
    formatted_time = now.strftime("%d/%m/%Y")  # 日期和时间格式
    embed.timestamp = now
    embed.set_footer(text=f"{formatted_time}")

await ctx.send('完成', hidden=True)
await ctx.channel.send(embed=embed)
英文:

Bots will always reply to the user that ran a slash command however it should be possible to make the interaction reply hidden to everyone but the one who used it and then send the embed to the channel by using something like this:

if timestamp:
    now = datetime.datetime.now()
    formatted_time = now.strftime("%d/%m/%Y")  # Formato da data e hora
    embed.timestamp = now
    embed.set_footer(text=f"{formatted_time}")

await ctx.send('Done', hidden=True)
await ctx.channel.send(embed=embed)

huangapple
  • 本文由 发表于 2023年8月9日 05:14:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76863235.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定