[英]embed for a ping command on discord.js
I'm trying to make a nice looking ping command, with the message with the ping being an embed like this:我正在尝试制作一个漂亮的 ping 命令,带有 ping 的消息是这样的嵌入:
However, I don't want the embed to be edited.但是,我不想编辑嵌入。 I want it to be sent as a separate message after the ping finished.
我希望它在 ping 完成后作为单独的消息发送。
Here's my code:这是我的代码:
module.exports = {
name: 'ping',
description: "shows the bot/'s ping",
execute(message, args, embed) {
message.channel.send('**The Ping-inator!**\nPinging...').then((msg) => {
var ping = msg.createdTimestamp - message.createdTimestamp;
msg.edit("**The Ping-inator!**\nPong! bot's ping is `" + ping + 'ms`.');
});
},
};
You cannot edit the message and hide the edited tag.您无法编辑消息并隐藏编辑的标签。 It will appear on every edited message, whether it is sent from a bot or a user.
它将出现在每条编辑过的消息上,无论是从机器人还是用户发送的。
What you can do is, instead of editing the message, you can delete the old message and send a new one.您可以做的是,您可以删除旧消息并发送新消息,而不是编辑消息。 This way, no edited tag will appear.
这样,不会出现任何编辑过的标签。
Here's a simple example I made:这是我制作的一个简单示例:
client.on('message', (message) => {
if (message.author.bot) return false;
const Embed = new Discord.MessageEmbed()
.setDescription('Checking the ping...')
.setColor('#4287f5');
message.channel.send(Embed).then((embedMessage) => {
setTimeout(async () => {
Embed.setDescription('Pong! The ping is `2000ms`!');
await embedMessage.delete().catch((error) => console.log(error));
message.channel.send(Embed);
}, 2000);
});
});
If you don't want to edit it, just send another message.如果您不想编辑它,只需发送另一条消息。
message.channel.send('**The Ping-inator!**\nPinging...').then((msg) => {
ping = msg.createdTimestamp - message.createdTimestamp;
const embed = new Discord.MessageEmbed()
.setColor(`RANDOM`)
.setTitle(`Ping`)
.setDescription(
"**The Ping-inator!**\nPong! bot's ping is `" + ping + 'ms`.'
);
message.channel.send(embed);
msg.delete();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.