Update from Git Manager GUI
This commit is contained in:
42
commands/ping.js
Normal file
42
commands/ping.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import { SlashCommandBuilder } from "discord.js";
|
||||
import { requireOwner } from "../util/ownerOnly.js";
|
||||
import { t, getLang } from "../util/i18n.js";
|
||||
import fsSync from "fs";
|
||||
|
||||
export default {
|
||||
name: "ping",
|
||||
description: "Der Ping des Bots!",
|
||||
aliases: ["pingpong"],
|
||||
guild: ["all"],
|
||||
nsfw: false,
|
||||
user_permissions: [],
|
||||
bot_permissions: [],
|
||||
args_required: 0,
|
||||
args_usage: "",
|
||||
cooldown: 5,
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("ping")
|
||||
.setDescription("Zeigt die aktuelle Latenz des Bots"),
|
||||
|
||||
async execute(client, ctx) {
|
||||
const lang = loadLang(ctx.guild.id);
|
||||
if (!await requireOwner(client, ctx, lang)) return;
|
||||
if (ctx.isSlash) {
|
||||
await ctx.interaction.reply("Ping?");
|
||||
const reply = await ctx.interaction.fetchReply();
|
||||
const latency = reply.createdTimestamp - ctx.interaction.createdTimestamp;
|
||||
return ctx.interaction.editReply(`:ping_pong: Pong! Die Latenz beträgt **${latency}ms**.`);
|
||||
}
|
||||
|
||||
const m = await ctx.channel.send("Ping?");
|
||||
m.edit(`:ping_pong: Pong! Die Latenz beträgt **${m.createdTimestamp - ctx.createdTimestamp}ms**.`);
|
||||
},
|
||||
};
|
||||
|
||||
function loadLang(guildID) {
|
||||
try {
|
||||
const data = JSON.parse(fsSync.readFileSync(`./serverdata/${guildID}.json`, "utf8"));
|
||||
return getLang(data);
|
||||
} catch { return "de"; }
|
||||
}
|
||||
Reference in New Issue
Block a user