Facebook
From Erenay, 4 Months ago, written in JavaScript.
Embed
Download Paste or View Raw
Hits: 268
  1.  
  2.     const {
  3.       Discord,
  4.       EmbedBuilder,
  5.       SlashCommandBuilder,
  6.       AttachmentBuilder
  7.     } = require('discord.js')
  8.     const {
  9.       updatePingChart,
  10.       canvas
  11.     } = require("../helpers/chart");
  12.  
  13.     function wait(time) {
  14.       return new Promise(resolve => setTimeout(resolve, time));
  15.     }
  16.     const fs = require("fs")
  17.     module.exports = {
  18.       slash: true,
  19.       cooldown: 1200,
  20.  
  21.       data: new SlashCommandBuilder()
  22.         .setName('ping')
  23.         .setDescription('Shows bot ping.'),
  24.  
  25.       async execute(client, interaction) {
  26.  
  27.         let pinge = ':Bot:'
  28.         let bote = ':Ping:'
  29.         let messageping = new Date().getTime() - interaction.createdTimestamp
  30.         let ping = await client.ws.ping
  31.        
  32.         await updatePingChart(ping)
  33.        
  34.         const stream = canvas.createPNGStream();
  35.         const attachment = new AttachmentBuilder(stream, {
  36.           name: 'ping.png'
  37.         });
  38.        
  39.         const embed = new EmbedBuilder()
  40.           .addFields({
  41.             name: `${bote} **Bot ping:**`,
  42.             value: `\`${ping}ms\``
  43.           }, {
  44.             name: `${pinge} **Message ping:**`,
  45.             value: `\`${messageping}ms\``
  46.           })
  47.           .setColor(`Gold`)
  48.          
  49.         await interaction.reply({
  50.           embeds: [embed],
  51.           attachments: [attachment]
  52.         })
  53.        
  54.         wait(5000)
  55.        
  56.         const fileName = 'pingChart.png';
  57.         fs.unlinkSync(fileName);
  58.       }
  59.     }

Replies to Untitled rss

Title Name Language When
Re: Untitled Erenay javascript 4 Months ago.