#Slash commands

23 messages · Page 1 of 1 (latest)

sour root
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

shrewd ferry
#

v19.3.0

#
const { EmbedBuilder, SlashCommandBuilder } = require("discord.js");
const moment = require("moment");
const { clientId } = require("../../config");
require("moment-duration-format");

module.exports = {
  name: "ping",
  category: "Information",
  description: "Displays the bot's ping.",
  args: false,
  usage: "",
  userPerms: [],
  owner: false,

  execute: async (message, args, client, prefix) => {

    await message.reply({ content: "Pinging..." }).then(async (msg) => {

      const pping = msg.createdAt - message.createdAt;

      const api_ping = client.ws.ping;
      const uptime = moment.duration(message.client.uptime).format(" D[d], H[h], m[m], s[s]");

      const PingEmbed = new EmbedBuilder()
        .setAuthor({ name: "Pong", iconURL: client.user.displayAvatarURL() })
        .setColor(client.embedColor)
        .addFields([
          { name: "Bot Latency", value: `\`\`\`ini\n[ ${pping}ms ]\n\`\`\``, inline: true },
          { name: "API Latency", value: `\`\`\`ini\n[ ${api_ping}ms ]\n\`\`\``, inline: true },
          { name: "Uptime", value: `\`\`\`ini\n[ ${uptime} ]\n\`\`\``, inline: true }
        ])
        .setFooter({ text: `Requested by ${message.author.username}`, iconURL: message.author.avatarURL({ dynamic: true }) })
        .setTimestamp();

      await msg.edit({
        content: "\`:ping_pong:\`",
        embeds: [PingEmbed]
      })
    })
  }}```
wet flax
#

that isnt even a slashcommand

shrewd ferry
#

i know it

#

I don't know how to embed it

mild wraithBOT
#

Suggestion for @shrewd ferry:
guide Creating Your Bot: Creating slash commands
read more

wet flax
#

You can check this to see how slashcommands work

shrewd ferry
#

oh oke

wet flax
#

you will need to rewrite the whole command

shrewd ferry
#

ok

#

thx

#
const moment = require("moment");
const { clientId } = require("../../config");
require("moment-duration-format");

module.exports = {
    data: new SlashCommandBuilder()
        .setName('ping')
        .setDescription('Show ur ping as in ms'),
    async execute(interaction) {
        await message.reply({ content: "Pinging..." }).then(async (msg) => {

            const pping = msg.createdAt - message.createdAt;
      
            const api_ping = client.ws.ping;
            const uptime = moment.duration(message.client.uptime).format(" D[d], H[h], m[m], s[s]");
      
            const PingEmbed = new EmbedBuilder()
              .setAuthor({ name: "Pong", iconURL: client.user.displayAvatarURL() })
              .setColor(client.embedColor)
              .addFields([
                { name: "Bot Latency", value: `\`\`\`ini\n[ ${pping}ms ]\n\`\`\``, inline: true },
                { name: "API Latency", value: `\`\`\`ini\n[ ${api_ping}ms ]\n\`\`\``, inline: true },
                { name: "Uptime", value: `\`\`\`ini\n[ ${uptime} ]\n\`\`\``, inline: true }
              ])
              .setFooter({ text: `Requested by ${message.author.username}`, iconURL: message.author.avatarURL({ dynamic: true }) })
              .setTimestamp();
      
            await msg.edit({
              content: "\`:ping_pong:\`",
              embeds: [PingEmbed]
            })
          })
    },
};```
#

it doesnt works

wet flax
#

you will need to rewrite the whole command

#

And you need to read the whole guide to see how to deploy commands

shrewd ferry
#

bru

#

ok

#

slash commands don't appear either, how I use them :/

#
const { REST } = require('@discordjs/rest');
const { clientId, guildId, token } = require('./config');

const commands = [
    new SlashCommandBuilder().setName('ping').setDescription('Show ur ping as in ms'),
]
    .map(command => command.toJSON());

const rest = new REST({ version: '10' }).setToken(token);

rest.put(Routes.applicationCommands(clientId), { body: commands })
    .then(() => console.log('I comandi sono stati registrati con successo.'))
    .catch(console.error);

``` do i have to register them with this?
#

@wet flax

next grotto