#Slash commands
23 messages · Page 1 of 1 (latest)
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]
})
})
}}```
that isnt even a slashcommand
You can check this to see how slashcommands work
oh oke
you will need to rewrite the whole command
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
you will need to rewrite the whole command
And you need to read the whole guide to see how to deploy commands
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
Creating Your Bot: Creating slash commands