Error with Ping command

I made a ping command and wanted to go a little further. I wanted to display the bot's ping by executing /ping, but it's not working. Despite many modifications, I still can't find a solution to this problem. The issue is with ${client.ws.ping}. The code is in the discussion. Thanks for helping me.
18 Replies
d.js toolkit
d.js toolkit17mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
DakinDrago
DakinDragoOP17mo ago
[email protected] nœud v16.14.2 Code:
const {Client, EmbedBuilder, SlashCommandBuilder } = require('discord.js');

module.exports = {
données : nouveau SlashCommandBuilder()
.setName('ping')
.setDescription('Ping'),
exécution asynchrone (interaction) {
const pingEmbed = nouveau MessageEmbed()
.setTitle('Pong !')
.setDescription(`Le ping est **${client.ws.ping}** ms.`)
.setColor('#ff0000');
interaction.reply({ embeds : [pingEmbed] });
},
} ;
const {Client, EmbedBuilder, SlashCommandBuilder } = require('discord.js');

module.exports = {
données : nouveau SlashCommandBuilder()
.setName('ping')
.setDescription('Ping'),
exécution asynchrone (interaction) {
const pingEmbed = nouveau MessageEmbed()
.setTitle('Pong !')
.setDescription(`Le ping est **${client.ws.ping}** ms.`)
.setColor('#ff0000');
interaction.reply({ embeds : [pingEmbed] });
},
} ;
Problème : ${client.ws.ping}
treble/luna
treble/luna17mo ago
thats not valid javascript not do you define client anywhere thats also v13 code #rules 1 and 3
DakinDrago
DakinDragoOP17mo ago
Ok. How can I fix this issue ?
treble/luna
treble/luna17mo ago
by writing valid javascript not your self made french javascript
DakinDrago
DakinDragoOP17mo ago
No, no, no. This is the error of my traductor. This is the code.
treble/luna
treble/luna17mo ago
why did you put your code in a translator
DakinDrago
DakinDragoOP17mo ago
No, a pc traslator.
treble/luna
treble/luna17mo ago
regardless
DakinDrago
DakinDragoOP17mo ago
const { Client, EmbedBuilder, SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Ping'),
async execute(interaction) {
const pingEmbed = new MessageEmbed()
.setTitle('Pong !')
.setDescription(`Ping = **${client.ws.ping}** ms.`)
.setColor('#ff0000');
interaction.reply({ embeds: [pingEmbed] });
},
};
const { Client, EmbedBuilder, SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Ping'),
async execute(interaction) {
const pingEmbed = new MessageEmbed()
.setTitle('Pong !')
.setDescription(`Ping = **${client.ws.ping}** ms.`)
.setColor('#ff0000');
interaction.reply({ embeds: [pingEmbed] });
},
};
treble/luna
treble/luna17mo ago
i have 0 clue whether you actually wrote valid js yeah that looks better still, you dont define client, and thats v13 code while you import the v14 equivalent
DakinDrago
DakinDragoOP17mo ago
What then are equivalent in v14 ?
DakinDrago
DakinDragoOP17mo ago
This is in v13 ?
treble/luna
treble/luna17mo ago
the one you use yes the one you import, no
DakinDrago
DakinDragoOP17mo ago
const { Client, EmbedBuilder, SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Donne le ping du bot.'),
async execute(interaction) {
const pingEmbed = new EmbedBuilder()
.setTitle('Pong !')
.setDescription(`Le ping du bot est de **${client.ws.ping}** ms.`)
.setColor('#ff0000');
interaction.reply({ embeds: [pingEmbed] });
},
};
const { Client, EmbedBuilder, SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Donne le ping du bot.'),
async execute(interaction) {
const pingEmbed = new EmbedBuilder()
.setTitle('Pong !')
.setDescription(`Le ping du bot est de **${client.ws.ping}** ms.`)
.setColor('#ff0000');
interaction.reply({ embeds: [pingEmbed] });
},
};
treble/luna
treble/luna17mo ago
thats better but you still do not define client and no, you should not use the import almost all djs structures have a client property
DakinDrago
DakinDragoOP17mo ago
I will test it. It's work !!!
const { EmbedBuilder, SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Ping'),
async execute(interaction) {
const ping = `${interaction.client.ws.ping}`;
const pingEmbed = new EmbedBuilder()
.setTitle('Pong !')
.setDescription(`The ping is **${ping}** ms.`)
.setColor('#ff0000');
interaction.reply({ embeds: [pingEmbed] });
},
};
const { EmbedBuilder, SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Ping'),
async execute(interaction) {
const ping = `${interaction.client.ws.ping}`;
const pingEmbed = new EmbedBuilder()
.setTitle('Pong !')
.setDescription(`The ping is **${ping}** ms.`)
.setColor('#ff0000');
interaction.reply({ embeds: [pingEmbed] });
},
};
Want results from more Discord servers?
Add your server