让discord.js机器人在用户使用斜杠命令时发送临时消息,我尝试过使用interation.editReply({content: "etc-etc", ephemeral:true});,以及任何看起来合理但似乎不成功的东西,请发送一个示例,我将如何实现临时消息!
编辑:
我的斜杠命令帮助文件:
const { Message, Client } = require("discord.js");
module.exports = {
name: "help",
description: "Sends web page url for all commands",
run: async (client, interaction) => {
await interaction.deferReply({ephemeral: true});
interaction.editReply({
embeds: [
{
title: `${client.user.username}'s Help Page`,
description: `https://help.tcb.jayeshrocks.xyz`,
color: "RANDOM"
}
]
})
}
};
Run Code Online (Sandbox Code Playgroud)
现在我收到交互已回复错误
编辑2:这是我的interactionCreate.js 的一个错误,现在我修复了它,它正在与 .deferReply() 一起使用,谢谢!
根据文档,您需要ephemeral在InteractionReplyOptions. 您还可以查看 Discord.js关于临时响应的指南。
您可能并不总是希望有权访问该频道的每个人都看到斜杠命令的响应。值得庆幸的是,Discord 实现了一种对除了斜杠命令执行者之外的所有人隐藏消息的方法。这种类型的消息称为
ephemeral消息,可以通过ephemeral: true在InteractionReplyOptions
//use the `interaction.reply()` function normally
await interaction.reply({
embeds: [{
title: `${client.user.username}'s Help Page`,
description: `https://help.tcb.jayeshrocks.xyz`,
color: "RANDOM"
}],
//this is the important part
ephemeral: true
});
Run Code Online (Sandbox Code Playgroud)
您也可以在执行时使用该ephemeral选项deferReply()
。
//use the `interaction.deferReply()` function normally
await interaction.deferReply({
//this is the important part
ephemeral: true
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24366 次 |
| 最近记录: |