JaNuK
DIAdiscord.js - Imagine an app
•Created by JaNuK on 12/3/2023 in #djs-questions
Expected the value to be an object, but received string instead & Message is not a Constructor Error
I Coded a /ping Command & It's This How To Fix the Errors v14 (^14.14.1)
const { SlashCommandBuilder } = require('@discordjs/builders');
const { EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('🏓 Check my ping!'),
async execute(interaction, client) {
try {
let embed = new EmbedBuilder()
.setTitle("Pong!")
.setColor('#2F3136')
.setThumbnail('https://media.discordapp.net/attachments/1116930073468080289/1180888416985038889/Zypher.png?ex=657f0f0a&is=656c9a0a&hm=2cc57e0d01717a37b09d6acb6993f58cc916d1c165572d0adbd975805abd344a&=&format=webp&quality=lossless')
.addFields(
{ name: '**Latency**', value: `\`\`\`ini\n[ ${Date.now() - interaction.createdTimestamp}ms ]\n\`\`\``, inline: true },
{ name: '**API Latency**', value: `\`\`\`ini\n[ ${Math.round(client.ws.ping)}ms ]\n\`\`\``, inline: true }
)
.setTimestamp()
.setFooter(`©️ Zyper`, 'https://media.discordapp.net/attachments/1116930073468080289/1180888416985038889/Zypher.png?ex=657f0f0a&is=656c9a0a&hm=2cc57e0d01717a37b09d6acb6993f58cc916d1c165572d0adbd975805abd344a&=&format=webp&quality=lossless');
await interaction.reply({
embeds: [embed]
});
} catch (error) {
console.error(`Error executing ping command: ${error.message}`);
}
},
};
const { SlashCommandBuilder } = require('@discordjs/builders');
const { EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('🏓 Check my ping!'),
async execute(interaction, client) {
try {
let embed = new EmbedBuilder()
.setTitle("Pong!")
.setColor('#2F3136')
.setThumbnail('https://media.discordapp.net/attachments/1116930073468080289/1180888416985038889/Zypher.png?ex=657f0f0a&is=656c9a0a&hm=2cc57e0d01717a37b09d6acb6993f58cc916d1c165572d0adbd975805abd344a&=&format=webp&quality=lossless')
.addFields(
{ name: '**Latency**', value: `\`\`\`ini\n[ ${Date.now() - interaction.createdTimestamp}ms ]\n\`\`\``, inline: true },
{ name: '**API Latency**', value: `\`\`\`ini\n[ ${Math.round(client.ws.ping)}ms ]\n\`\`\``, inline: true }
)
.setTimestamp()
.setFooter(`©️ Zyper`, 'https://media.discordapp.net/attachments/1116930073468080289/1180888416985038889/Zypher.png?ex=657f0f0a&is=656c9a0a&hm=2cc57e0d01717a37b09d6acb6993f58cc916d1c165572d0adbd975805abd344a&=&format=webp&quality=lossless');
await interaction.reply({
embeds: [embed]
});
} catch (error) {
console.error(`Error executing ping command: ${error.message}`);
}
},
};
3 replies