英文:
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
答案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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论