0

I tried to use the following ping command, but when I trigger it, it gives me the following error:

The code:

const Discord = require('discord.js');

module.exports.run = async (bot, message, args) => {

let waiting = await message.channel.send("Pinging :hourglass:...").catch(console.error);

let embed = new Discord.MessageEmbed()
 .setTitle("Dragonite's & API's Latency", bot.user.avatarURL)
 .setColor("#f900ff")
 .addField("Dragonite :", `${waiting.createdTimestamp - message.createdTimestamp}` + "ms`", true)
 .addField("API :", Math.round(bot.ping) + "ms", true)
 .addFooter("Dragonite | Requested by " + message.author.tag)

waiting.edit(embed).catch(console.error);
}

module.exports.help = {
    name: "ping",
    description: "Calculate Dragonite's & API's Latency.",
    usage: "ping",
    example: "ping"
}

The error:

(node:23760) UnhandledPromiseRejectionWarning: TypeError: (intermediate value).setTitle(...).setColor(...).addField(...).addField(...).addFooter is not a function
LeRegedit
  • 9
  • 7

1 Answers1

0

addFooter is not a method on the message embed object. Here is the API reference: https://discord.js.org/#/docs/main/master/class/MessageEmbed

The method you want might be setFooter: https://discord.js.org/#/docs/main/master/class/MessageEmbed?scrollTo=setFooter

User81646
  • 628
  • 4
  • 13
  • It got fixed but there is one thing, when the commands gets activated the bots sends "Pinging...", after that it shows and embed with the ping. But the "Pinging..." not supposed to be there after the embed appearing, how I can fix it? – LeRegedit Sep 02 '20 at 01:45
  • Try adding `await waiting.delete()` whenever you want it deleted – User81646 Sep 02 '20 at 01:49