Ping NaNms

const { SlashCommandBuilder, Client, GatewayIntentBits, WebsocketOptions } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds]});
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Omni-Bot Replies with Pong!'),
async execute(interaction) {
await interaction.reply({content:` Websocket heartbeat: ${client.ws.ping}ms.`, ephemeral: true});
},
};
const { SlashCommandBuilder, Client, GatewayIntentBits, WebsocketOptions } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds]});
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Omni-Bot Replies with Pong!'),
async execute(interaction) {
await interaction.reply({content:` Websocket heartbeat: ${client.ws.ping}ms.`, ephemeral: true});
},
};
Result:
26 Replies
d.js toolkit
d.js toolkit16mo ago
• 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.
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
Zaenalos
Zaenalos16mo ago
Alright i'll try it.
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
Zaenalos
Zaenalos16mo ago
MB, Thank you!! Do i put the console.log like this?
const { SlashCommandBuilder, Client, GatewayIntentBits, WebsocketOptions } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds]});
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Omni-Bot Replies with Pong!'),
async execute(interaction) {
console.log(client);
await interaction.reply({content:` Websocket heartbeat: ${client.ws.ping}ms.`, ephemeral: true});
},
};
const { SlashCommandBuilder, Client, GatewayIntentBits, WebsocketOptions } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds]});
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Omni-Bot Replies with Pong!'),
async execute(interaction) {
console.log(client);
await interaction.reply({content:` Websocket heartbeat: ${client.ws.ping}ms.`, ephemeral: true});
},
};
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
Zaenalos
Zaenalos16mo ago
Still NaNms
Zaenalos
Zaenalos16mo ago
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
Zaenalos
Zaenalos16mo ago
My main file is index.js
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
Zaenalos
Zaenalos16mo ago
This index.js
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.commands = new Collection();
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}


const eventsPath = path.join(__dirname, 'events');
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));

for (const file of eventFiles) {
const filePath = path.join(eventsPath, file);
const event = require(filePath);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
}


client.login(token);
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.commands = new Collection();
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}


const eventsPath = path.join(__dirname, 'events');
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));

for (const file of eventFiles) {
const filePath = path.join(eventsPath, file);
const event = require(filePath);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
}


client.login(token);
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
Zaenalos
Zaenalos16mo ago
I changed the ping.ms into this
const { SlashCommandBuilder } = require('discord.js');
const client = require('../../index.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Omni-Bot Replies with Pong!'),
async execute(interaction) {
console.log(client);
await interaction.reply({content:` Websocket heartbeat: ${interaction.client.ws.ping}ms.`, ephemeral: true});
},
};
const { SlashCommandBuilder } = require('discord.js');
const client = require('../../index.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Omni-Bot Replies with Pong!'),
async execute(interaction) {
console.log(client);
await interaction.reply({content:` Websocket heartbeat: ${interaction.client.ws.ping}ms.`, ephemeral: true});
},
};
Is this good now?
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server