gpt-4o-2024-08-06· OpenAI
WildChat-4.8M (AI2)
Instructions: Give the result in MD format, if there's a code, wrap it around code…
- User
Instructions: Give the result in MD format, if there's a code, wrap it around code block. \PROMPT: write me a discord.js ping command with an advanced embed
- Assistant
Certainly! Below is a Discord.js ping command that utilizes an advanced embed. This command responds with the bot's latency and includes additional styling for the embed message.
const { Client, Intents, MessageEmbed } = require('discord.js'); const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] }); client.once('ready', () => { console.log('Bot is online!'); }); client.on('messageCreate', async message => { if (message.content.toLowerCase() === '!ping') { const pingEmbed = new MessageEmbed() .setColor('#0099ff') .setTitle('🏓 Pong!') .setDescription('Here is the latency information:') .addFields( { name: 'Bot Latency', value: `${Date.now() - message.createdTimestamp}ms`, inline: true }, { name: 'API Latency', value: `${Math.round(client.ws.ping)}ms`, inline: true } ) .setThumbnail('https://example.com/your-image.png') // Add a relevant image URL .setFooter('Ping command executed', 'https://example.com/footer-image.png') .setTimestamp(); message.channel.send({ embeds: [pingEmbed] }); } }); client.login('YOUR_BOT_TOKEN');