Updated help commands to use command builder

This commit is contained in:
2023-12-15 17:47:24 +01:00
parent 88d0200823
commit a6c207a66d
9 changed files with 30 additions and 28 deletions

View File

@@ -10,20 +10,7 @@ module.exports = {
type: "slash", type: "slash",
dev: false, dev: false,
public: true, public: true,
subcommands: [ subcommands: true,
{
name: "member",
description: "Get info about a guild memeber",
},
{
name: "info",
description: "Get info about a guild.",
},
{
name: "top",
description: "Get the top guild members based on gexp",
}
],
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("guild") .setName("guild")
@@ -89,8 +76,6 @@ module.exports = {
async execute(interaction) { async execute(interaction) {
await interaction.deferReply()
const subcommand = interaction.options.getSubcommand() const subcommand = interaction.options.getSubcommand()
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
@@ -112,7 +97,7 @@ module.exports = {
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true }) const footerIcon = interaction.guild ? interaction.guild.iconURL({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true })
await interaction.editReply({ await interaction.reply({
embeds: [{ embeds: [{
description: "This command is currently under development", description: "This command is currently under development",
color: embedColor, color: embedColor,

View File

@@ -4,6 +4,7 @@ const { color, devMessage } = require("../../../config/options.json")
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */ /** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async function guildInfo(interaction) { async function guildInfo(interaction) {
await interaction.deferReply()
const query = interaction.options.getString("query") const query = interaction.options.getString("query")
const type = interaction.options.getString("type") || "ign" const type = interaction.options.getString("type") || "ign"

View File

@@ -4,6 +4,8 @@ const { color, devMessage } = require("../../../config/options.json")
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */ /** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async function guildMember(interaction) { async function guildMember(interaction) {
await interaction.deferReply()
const ign = interaction.options.getString("ign") const ign = interaction.options.getString("ign")
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))

View File

@@ -6,6 +6,8 @@ const { redis } = require("../../utils/redis.js")
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */ /** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async function guildTop(interaction) { async function guildTop(interaction) {
await interaction.deferReply()
const query = interaction.options.getString("query") const query = interaction.options.getString("query")
const type = interaction.options.getString("type") || "ign" const type = interaction.options.getString("type") || "ign"
let amount = interaction.options.getNumber("amount") || 10 let amount = interaction.options.getNumber("amount") || 10

View File

@@ -27,17 +27,15 @@ module.exports = {
if (command.public && !command.subcommands) { if (command.public && !command.subcommands) {
commands.push(command) commands.push(command)
} else if (command.public && command.subcommands) { } else if (command.public && command.subcommands) {
const commandName = command.name const commandName = command.data.name
const subcommands = command.subcommands.map((subcommand) => { const subcommands = command.data.options.map((subcommand) => {
return { return {
name: commandName + " " + subcommand.name, name: commandName + " " + subcommand.name,
description: subcommand.description description: subcommand.description
} }
}) })
console.log(subcommands)
for (const subcommand of subcommands) { for (const subcommand of subcommands) {
commands.push(subcommand) commands.push(subcommand)
} }

View File

@@ -7,6 +7,7 @@ module.exports = {
type: "slash", type: "slash",
dev: true, dev: true,
public: false, public: false,
subcommands: true,
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("setup") .setName("setup")

View File

@@ -9,6 +9,7 @@ module.exports = {
type: "slash", type: "slash",
dev: false, dev: false,
public: false, public: false,
subcommands: true,
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("staff") .setName("staff")
@@ -35,8 +36,6 @@ module.exports = {
async execute(interaction) { async execute(interaction) {
await interaction.deferReply()
const subcommand = interaction.options.getSubcommand() const subcommand = interaction.options.getSubcommand()
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
@@ -53,7 +52,7 @@ module.exports = {
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true }) const footerIcon = interaction.guild ? interaction.guild.iconURL({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true })
await interaction.editReply({ await interaction.reply({
embeds: [{ embeds: [{
description: "This command is currently under development", description: "This command is currently under development",
color: embedColor, color: embedColor,

View File

@@ -5,6 +5,7 @@ const { hypixelLevel, bedwarsLevel, skywarsLevel, getUUID, getPlayer, getGuild,
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */ /** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async function beast(interaction) { async function beast(interaction) {
await interaction.deferReply()
const ign = interaction.options.getString("ign") const ign = interaction.options.getString("ign")
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))

View File

@@ -5,13 +5,25 @@ const path = require("path")
/** @param { import("discord.js").ChatInputCommandInteraction } interaction */ /** @param { import("discord.js").ChatInputCommandInteraction } interaction */
async function help(interaction) { async function help(interaction) {
const commands = [] const commands = []
const commandFiles = fs.readdirSync(path.join(__dirname, "..")).filter(file => file.endsWith(".js")) const commandFiles = fs.readdirSync(path.join(__dirname, "..")).filter(file => file.endsWith(".js"))
for (const file of commandFiles) { for (const file of commandFiles) {
const command = require(`../../commands/${file}`) const command = require(`../../commands/${file}`)
if (!command.public) { if (!command.public && !command.subcommands) {
commands.push(command) commands.push(command)
} else if (!command.public && command.subcommands) {
const commandName = command.data.name
const subcommands = command.data.options.map((subcommand) => {
return {
name: commandName + " " + subcommand.name,
description: subcommand.description
}
})
for (const subcommand of subcommands) {
commands.push(subcommand)
}
} }
} }
const commandList = commands.map((command) => { const commandList = commands.map((command) => {
@@ -25,7 +37,7 @@ async function help(interaction) {
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true }) const footerIcon = interaction.guild ? interaction.guild.iconURL({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true })
await interaction.editReply({ await interaction.reply({
embeds: [{ embeds: [{
title: "Commands", title: "Commands",
description: "List of commands", description: "List of commands",
@@ -38,7 +50,8 @@ async function help(interaction) {
icon_url: footerIcon, icon_url: footerIcon,
text: footerText + " | " + devMessage text: footerText + " | " + devMessage
} }
}] }],
ephemeral: true
}) })
} }