Ping not working

Code:
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Get the ping to discord'),
async execute(client, interaction) {
interaction.followUp(`Ping to discord :- ${Math.round(client.ws.ping)}ms`);
},
};
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Get the ping to discord'),
async execute(client, interaction) {
interaction.followUp(`Ping to discord :- ${Math.round(client.ws.ping)}ms`);
},
};
The error:
Error executing ping
TypeError: Cannot read properties of undefined (reading 'followUp')
at Object.execute (C:\Users\awash\Downloads\all mod\commands\ping.js:9:15)
at Object.execute (C:\Users\awash\Downloads\all mod\events\interactionCreate.js:16:18)
at Client.<anonymous> (C:\Users\awash\Downloads\all mod\index.js:38:44)
at Client.emit (node:events:513:28)
at InteractionCreateAction.handle (C:\Users\awash\Downloads\all mod\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\awash\Downloads\all mod\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\awash\Downloads\all mod\node_modules\discord.js\src\client\websocket\WebSocketManager.js:352:31)
at WebSocketShard.onPacket (C:\Users\awash\Downloads\all mod\node_modules\discord.js\src\client\websocket\WebSocketShard.js:489:22)
at WebSocketShard.onMessage (C:\Users\awash\Downloads\all mod\node_modules\discord.js\src\client\websocket\WebSocketShard.js:328:10)
at callListener (C:\Users\awash\Downloads\all mod\node_modules\ws\lib\event-target.js:290:14)
Error executing ping
TypeError: Cannot read properties of undefined (reading 'followUp')
at Object.execute (C:\Users\awash\Downloads\all mod\commands\ping.js:9:15)
at Object.execute (C:\Users\awash\Downloads\all mod\events\interactionCreate.js:16:18)
at Client.<anonymous> (C:\Users\awash\Downloads\all mod\index.js:38:44)
at Client.emit (node:events:513:28)
at InteractionCreateAction.handle (C:\Users\awash\Downloads\all mod\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\awash\Downloads\all mod\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\awash\Downloads\all mod\node_modules\discord.js\src\client\websocket\WebSocketManager.js:352:31)
at WebSocketShard.onPacket (C:\Users\awash\Downloads\all mod\node_modules\discord.js\src\client\websocket\WebSocketShard.js:489:22)
at WebSocketShard.onMessage (C:\Users\awash\Downloads\all mod\node_modules\discord.js\src\client\websocket\WebSocketShard.js:328:10)
at callListener (C:\Users\awash\Downloads\all mod\node_modules\ws\lib\event-target.js:290:14)
node = v18.13.0 djs = 14.7.1
11 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
SpecialSauce
SpecialSauce2y ago
I’m guessing param mismatch. Make sure your args match the params in your handler.
d.js docs
d.js docs2y ago
The order of function parameters must match between definition and function call.
function execute(client, message, args) { ... };
execute(message, client, args);
function execute(client, message, args) { ... };
execute(message, client, args);
• mismatch! you pass a Message where the client is expected • mismatch! you pass the Client where a Message is expected
Awashcard0
Awashcard0OP2y ago
still got the same error
SpecialSauce
SpecialSauce2y ago
Show updated code.
Awashcard0
Awashcard0OP2y ago
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Get the ping to discord'),
async execute(message, client, args) {
message.followUp(`Ping to discord :- ${Math.round(client.ws.ping)}ms`);
},
};
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Get the ping to discord'),
async execute(message, client, args) {
message.followUp(`Ping to discord :- ${Math.round(client.ws.ping)}ms`);
},
};
Squid
Squid2y ago
The bot message was an example, not literal code that you should use
Awashcard0
Awashcard0OP2y ago
Im trying to make it work
Squid
Squid2y ago
The point is that wherever you call your execute() function should have the same parameters in the same order as where you define your execute() function The actual order is arbitrary, but it needs to be consistent
Awashcard0
Awashcard0OP2y ago
ok then what should I do
Squid
Squid2y ago
Make the parameters (and their order) consistent
Want results from more Discord servers?
Add your server