From 46c962c188a5e067c16aa15c3b8bd819bb6f69f0 Mon Sep 17 00:00:00 2001 From: ame Date: Thu, 21 Dec 2023 00:26:50 -0600 Subject: example ping command --- commands/util/defaults/ping.js.json | 2 ++ commands/util/ping.js | 39 +++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 commands/util/defaults/ping.js.json create mode 100644 commands/util/ping.js diff --git a/commands/util/defaults/ping.js.json b/commands/util/defaults/ping.js.json new file mode 100644 index 0000000..f390c76 --- /dev/null +++ b/commands/util/defaults/ping.js.json @@ -0,0 +1,2 @@ +{"cooldown":3,"desc":"get ping!","restrict":[],"restricted":[], +"usage":"{command}"} \ No newline at end of file diff --git a/commands/util/ping.js b/commands/util/ping.js new file mode 100644 index 0000000..7908c54 --- /dev/null +++ b/commands/util/ping.js @@ -0,0 +1,39 @@ +const fs = require('fs') +const path = require("path"); +let config_loc = __filename+".json" +const { EmbedBuilder } = require("discord.js"); +let settings = require("../../src/settings") + +//get config located at ./ping.js.json (edit in ./defaults/ping.js.json, then run sh buildconfig.sh) +let config = JSON.parse(fs.readFileSync(config_loc)) +module.exports = { + //name used in /help command, or command when used in slash commands + name : "ping", + //aliases a command can be called by (only used in non-slash commands) + command: ["ping"], + mod_only: false, + //link config + config:config, + config_loc:config_loc, + + //main function called when using old commands + async main (client,Discord,message,args){ + return await this.exec(client,{message:message}) + }, + + //slash command w/ options, a slash command wont appear unless a s_main exists + s_options:[{type:"string",name:"test",desc:"example",required:false,autocomplete:false}], + async s_main (client,Discord,interaction){ + return await this.exec(client,{message:interaction}) + }, + + //common function to be called by both main and s_main (just my preference) + async exec(client,info){ + let time = Date.now() - info.message.createdTimestamp + let embed = new EmbedBuilder() + .setTitle("Pong!") + .setDescription(time + "ms") + .setColor(settings.defaultColor) + return info.message.reply({embeds : [embed], ephemeral: true }) + } +} \ No newline at end of file -- cgit v1.2.3