Skip to content

Commit 0698256

Browse files
committed
Fix slashcommands
1 parent b9baaca commit 0698256

File tree

2 files changed

+90
-87
lines changed

2 files changed

+90
-87
lines changed

slashcommands/Bot/help.js

Lines changed: 75 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,93 @@
1-
const {readdirSync} = require("fs");
1+
const { readdirSync } = require("fs");
22

33
// Example of how to make a Help SlashCommand
44

55
module.exports = {
6-
name: "help",
7-
usage: '/help <command>',
8-
options: [
6+
name: "help",
7+
usage: '/help <command>',
8+
options: [
99
{
1010
name: 'command',
1111
description: 'What command do you need help',
1212
type: 'STRING',
1313
required: false
14-
}],
15-
category: "Bot",
16-
description: "Return all commands, or one specific command!",
17-
run: async (client, interaction) => {
14+
}
15+
],
16+
category: "Bot",
17+
description: "Return all commands, or one specific command!",
18+
ownerOnly: false,
19+
run: async (client, interaction) => {
1820

19-
// Buttons that take you to a link
20-
// If you want to delete them, remove this part of
21-
// the code and in line: 62 delete ", components: [row]"
22-
const row = new client.discord.MessageActionRow()
23-
.addComponents(
24-
new client.discord.MessageButton()
25-
.setLabel("GitHub")
26-
.setStyle("LINK")
27-
.setURL("https://github.com/Expectatives/Discord.js-v13-Example"),
28-
new client.discord.MessageButton()
29-
.setLabel("Support")
30-
.setStyle("LINK")
31-
.setURL("https://dsc.gg/faithcommunity")
32-
);
21+
// Buttons that take you to a link
22+
// If you want to delete them, remove this part of
23+
// the code and in line: 62 delete ", components: [row]"
24+
const row = new client.discord.MessageActionRow()
25+
.addComponents(
26+
new client.discord.MessageButton()
27+
.setLabel("GitHub")
28+
.setStyle("LINK")
29+
.setURL("https://github.com/Expectatives/Discord.js-v13-Example"),
30+
new client.discord.MessageButton()
31+
.setLabel("Support")
32+
.setStyle("LINK")
33+
.setURL("https://dsc.gg/faithcommunity")
34+
);
3335

34-
const commandInt = interaction.options.getString("command");
35-
if (!commandInt) {
36+
const commandInt = interaction.options.getString("command");
37+
if (!commandInt) {
3638

37-
// Get the slash commands of a Bot category
38-
const botCommandsList = [];
39-
readdirSync(`./slashcommands/Bot`).forEach((file) => {
40-
const filen = require(`../../slashcommands/Bot/${file}`);
41-
const name = `\`${filen.name}\``
42-
botCommandsList.push(name);
43-
});
39+
// Get the slash commands of a Bot category
40+
const botCommandsList = [];
41+
readdirSync(`./slashCommands/Bot`).forEach((file) => {
42+
const filen = require(`../../slashCommands/Bot/${file}`);
43+
const name = `\`${filen.name}\``
44+
botCommandsList.push(name);
45+
});
4446

45-
// Get the slash commands of a Utility category
46-
const utilityCommandsList = [];
47-
readdirSync(`./slashcommands/Utility`).forEach((file) => {
48-
const filen = require(`../../slashcommands/Utility/${file}`);
49-
const name = `\`${filen.name}\``
50-
utilityCommandsList.push(name);
51-
});
47+
// Get the slash commands of a Utility category
48+
const utilityCommandsList = [];
49+
readdirSync(`./slashCommands/Utility`).forEach((file) => {
50+
const filen = require(`../../slashCommands/Utility/${file}`);
51+
const name = `\`${filen.name}\``
52+
utilityCommandsList.push(name);
53+
});
5254

53-
// This is what it commands when using the command without arguments
54-
const helpEmbed = new client.discord.MessageEmbed()
55-
.setTitle(`${client.user.username} SlashHelp`)
56-
.setDescription(` Hello **<@${interaction.member.id}>**, I am <@${client.user.id}>. \nYou can use \`/help <slash_command>\` to see more info about the SlashCommands!\n**Total Commands:** ${client.commands.size}\n**Total SlashCommands:** ${client.slashCommands.size}`)
57-
.addField("🤖 - Bot SlashCommands", botCommandsList.map((data) => `${data}`).join(", "), true)
58-
.addField("🛠 - Utility SlashCommands", utilityCommandsList.map((data) => `${data}`).join(", "), true)
59-
.setColor(client.config.embedColor)
60-
.setFooter(client.config.embedfooterText, client.user.avatarURL());
61-
62-
interaction.followUp({embeds: [helpEmbed], components: [row]});
63-
} else {
64-
const command = client.slashCommands.get(commandInt.toLowerCase());
55+
// This is what it commands when using the command without arguments
56+
const helpEmbed = new client.discord.MessageEmbed()
57+
.setTitle(`${client.user.username} SlashHelp`)
58+
.setDescription(` Hello **<@${interaction.member.id}>**, I am <@${client.user.id}>. \nYou can use \`/help <slash_command>\` to see more info about the SlashCommands!\n**Total Commands:** ${client.commands.size}\n**Total SlashCommands:** ${client.slash.size}`)
59+
.addField("🤖 - Bot SlashCommands", botCommandsList.map((data) => `${data}`).join(", "), true)
60+
.addField("🛠 - Utility SlashCommands", utilityCommandsList.map((data) => `${data}`).join(", "), true)
61+
.setColor(client.config.embedColor)
62+
.setFooter({ text: `${client.config.embedfooterText}`, iconURL: `${client.user.displayAvatarURL()}` });
6563

66-
// This is what it sends when using the command with argument and it does not find the command
67-
if (!command) {
68-
interaction.followUp({content: `There isn't any SlashCommand named "${commandInt}"`});
69-
} else {
64+
interaction.reply({ embeds: [helpEmbed], components: [row] });
65+
} else {
66+
const command = client.slash.get(commandInt.toLowerCase());
7067

71-
// This is what it sends when using the command with argument and if it finds the command
72-
let command = client.slashCommands.get(commandInt.toLowerCase());
73-
let name = command.name;
74-
let description = command.description || "No descrpition provided"
75-
let usage = command.usage || "No usage provided"
76-
let category = command.category || "No category provided!"
68+
// This is what it sends when using the command with argument and it does not find the command
69+
if (!command) {
70+
interaction.reply({ content: `There isn't any SlashCommand named "${commandInt}"` });
71+
} else {
7772

78-
let helpCmdEmbed = new client.discord.MessageEmbed()
79-
.setTitle(`${client.user.username} Help | \`${(name.toLocaleString())}\` SlashCommand`)
80-
.addFields(
81-
{ name: "Description", value: `${description}` },
82-
{ name: "Usage", value: `${usage}` },
83-
{ name: 'Category', value: `${category}` })
84-
.setColor(client.config.embedColor)
85-
.setFooter(client.config.embedfooterText, client.user.avatarURL());
86-
87-
interaction.followUp({embeds: [helpCmdEmbed]});
88-
}
89-
}
90-
},
73+
// This is what it sends when using the command with argument and if it finds the command
74+
let command = client.slash.get(commandInt.toLowerCase());
75+
let name = command.name;
76+
let description = command.description || "No descrpition provided"
77+
let usage = command.usage || "No usage provided"
78+
let category = command.category || "No category provided!"
79+
80+
let helpCmdEmbed = new client.discord.MessageEmbed()
81+
.setTitle(`${client.user.username} Help | \`${(name.toLocaleString())}\` SlashCommand`)
82+
.addFields(
83+
{ name: "Description", value: `${description}` },
84+
{ name: "Usage", value: `${usage}` },
85+
{ name: 'Category', value: `${category}` })
86+
.setColor(client.config.embedColor)
87+
.setFooter({ text: `${client.config.embedfooterText}`, iconURL: `${client.user.displayAvatarURL()}` });
88+
89+
interaction.reply({ embeds: [helpCmdEmbed] });
90+
}
91+
}
92+
},
9193
};

slashcommands/Utility/ping.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
// Example of how to make a SlashCommand
22

33
module.exports = {
4-
name: "ping",
5-
category: "Utility",
6-
description: "Check the bot's ping!",
7-
run: async (client, interaction) => {
8-
const msg = await interaction.channel.send(`🏓 Pinging...`);
4+
name: "ping",
5+
category: "Utility",
6+
description: "Check the bot's ping!",
7+
ownerOnly: false,
8+
run: async (client, interaction) => {
9+
const msg = await interaction.channel.send(`🏓 Pinging...`);
910

10-
const pingEmbed = new client.discord.MessageEmbed()
11-
.setTitle(':signal_strength: Bot Ping')
12-
.addField("Time", `${Math.floor(msg.createdAt - interaction.createdAt)}ms`, true)
13-
.addField("API Ping", `${client.ws.ping}ms`, true)
14-
.setColor(client.config.embedColor)
15-
.setFooter(client.config.embedfooterText, client.user.avatarURL());
11+
const pingEmbed = new client.discord.MessageEmbed()
12+
.setTitle(':signal_strength: Bot Ping')
13+
.addField("Time", `${Math.floor(msg.createdAt - interaction.createdAt)}ms`, true)
14+
.addField("API Ping", `${client.ws.ping}ms`, true)
15+
.setColor(client.config.embedColor)
16+
.setFooter({ text: `${client.config.embedfooterText}`, iconURL: `${client.user.displayAvatarURL()}` });
1617

17-
await interaction.followUp({embeds: [pingEmbed]});
18+
await interaction.reply({ embeds: [pingEmbed] });
1819

19-
msg.delete();
20-
},
20+
msg.delete();
21+
},
2122
};

0 commit comments

Comments
 (0)