【发布时间】:2021-06-26 08:43:52
【问题描述】:
我一直在制作一个支持“say”命令类型的 Discord.js (V12) 机器人(请注意我是新手),但是当我使用这个“say”命令并单击“reply”时在特定消息中,它只发送我写的消息,根本不显示我正在回复的原始消息。 Here is what I wrote with the bot 和 here the result。
我的“说”命令代码很简单,因为我找不到实际的回复功能,所以我无法添加它(我不得不删除内容以便更准确)。
client.on('message', (message) => {
if (message.content.startsWith('p:')) {
//This line reads the content of the message, creates the variable "say" for it.
var say = message.content;
//This removes my message, so it can be replaced by bot's one.
message.delete();
//This line deletes the prefix from "say" and sends the rest of the message.
message.channel.send(say.replace('p:', '')
.catch(() => console.error('Failed to send - Can\'t send empty messages!'));
}
});
我发现还有另一种回复方式。 Here the two: The first one is the normal and the other is by a Tupperhook (Webhook) created by the bot Tupperbox.
有没有办法为机器人制作至少一个版本的 Webhook 回复?
在 Webhook 方法可以工作的情况下,我已经有办法跳转到一个消息(在这个例子中,原始消息正在触发一个特定的命令 - 这将被更改为跳转到回复的消息)嵌入,这是它的代码。
//These should be in the embed command.
//This line recognizes the servers the bot is in.
var guild = message.guild
//This other line recognizes the channels of the servers.
var channel = message.channel
//This one sends the word "Message" and includes a link to the message that triggered this command.
`[Message](https://discordapp.com/channels/${guild.id}/${channel.id}/${message.id})`
是否可以使我的代码适应任何这些回复功能?我发誓我从一个月开始就在尝试这个。任何答案都非常感谢!
【问题讨论】:
-
this 回答你的问题了吗?
-
哇,谢谢你的回答!此外,该线程正在解释没有办法让机器人发送正常回复......所以我可以把那部分放在一边,现在我想知道 Webhook 方法是否最初是由机器人的创建者编码的使用那些 Webhook,如果是这种情况,我想我不能做任何其他事情,我几乎不知道编码......我可以尝试制作自己的方法,但由于我是新人,这将很难 - 以防万一Webhooks 有一种已知的方法,我可以为我的机器人制作一个,我会尝试进行更多调查!
标签: javascript discord discord.js