/
ping.js
96 lines (84 loc) · 3.95 KB
/
ping.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//=====================================| Import the Module |=====================================\\
const { SlashCommandBuilder, PermissionFlagsBits, Client, ChatInputCommandInteraction, EmbedBuilder } = require("discord.js");
//==========< SETTINGS >==========\\
const Config = require("../../../Structures/Settings/config.json");
const Emoji = require("../../../Structures/Settings/emojis.json");
const Embed = require("../../../Structures/Settings/embed.json");
//==========< FUNCTIONS >==========\\
const { errorCmdLogsInt } = require("../../../Structures/Functions/errorCmdLogs.js");
//=====================================| Code |=====================================\\
module.exports = {
category: "Info",
cooldown: 15,
devOnly: false,
guildOnly: false,
voiceOnly: false,
nsfwOnly: false,
toggleOffCmd: false,
maintenanceCmd: false,
data: new SlashCommandBuilder()
.setName("ping")
.setDescription("Show discord bot latency.")
.setDefaultMemberPermissions(PermissionFlagsBits.UseApplicationCommands),
/**
* @param {ChatInputCommandInteraction} interaction
* @param {Client} client
*/
async execute(client, interaction) {
try {
// Function Uptime
let days = Math.floor(client.uptime / 86400000)
let hours = Math.floor(client.uptime / 3600000) % 24
let minutes = Math.floor(client.uptime / 60000) % 60
let seconds = Math.floor(client.uptime / 1000) % 60
// Latency Check
let webLatency = new Date() - interaction.createdAt
let apiLatency = client.ws.ping
let totalLatency = webLatency + apiLatency
// Emoji
let emLatency = {
Green: '🟢',
Yellow: '🟡',
Red: '🔴'
}
interaction.reply({
ephemeral: true,
embeds: [
new EmbedBuilder()
.setColor(totalLatency < 200 ? Embed.Colors.successcolor : totalLatency < 500 ? Embed.Colors.stanbycolor : Embed.Colors.wrongcolor)
.setTitle(`Returns Latency And API Ping`)
.addFields(
{
name: `📡 Websocket Latency`,
value: `\`${webLatency <= 200 ? emLatency.Green : webLatency <= 400 ? emLatency.Yellow : emLatency.Red}\` \`${webLatency}\`ms`,
inline: true
},
{
name: `🛰 API Latency`,
value: `\`${apiLatency <= 200 ? emLatency.Green : apiLatency <= 400 ? emLatency.Yellow : emLatency.Red}\` \`${apiLatency}\`ms`,
inline: true
},
{
name: `⏲ Uptime`,
value: `\`${days}Days\` : \`${hours}Hrs\` : \`${minutes}Mins\` : \`${seconds}Secs\``,
inline: true
}
)
],
});
} catch (error) {
errorCmdLogsInt(client, interaction, error);
}
}
};
/**
/////////////////////////////////////////////////////////////////////
//// ////
\\\\ Handlers Coded by GalaXd#9165 \\\\
//// ////
\\\\ Work for MGalaCyber Development | https://galacyber.xyz \\\\
//// ////
\\\\ All Right Reserved! \\\\
//// ////
/////////////////////////////////////////////////////////////////////
*/