Skip to content

Commit b9baaca

Browse files
committed
Fix prefix commands
1 parent 7b445fa commit b9baaca

File tree

2 files changed

+91
-89
lines changed

2 files changed

+91
-89
lines changed

commands/Bot/help.js

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

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

55
module.exports = {
6-
name: "help",
7-
aliases: ["h", "commands"],
8-
usage: '!help <command>',
9-
category: "Bot",
10-
description: "Return all commands, or one specific command!",
11-
run: async (client, message, args) => {
6+
name: "help",
7+
aliases: ["h", "commands"],
8+
usage: '!help <command>',
9+
category: "Bot",
10+
description: "Return all commands, or one specific command!",
11+
ownerOnly: false,
12+
run: async (client, message, args) => {
1213

13-
// Buttons that take you to a link
14-
// If you want to delete them, remove this part of
15-
// the code and in line: 55 delete ", components: [row]"
16-
const row = new client.discord.MessageActionRow()
17-
.addComponents(
18-
new client.discord.MessageButton()
19-
.setLabel("GitHub")
20-
.setStyle("LINK")
21-
.setURL("https://github.com/Expectatives/Discord.js-v13-Example"),
22-
new client.discord.MessageButton()
23-
.setLabel("Support")
24-
.setStyle("LINK")
25-
.setURL("https://dsc.gg/faithcommunity")
26-
);
27-
28-
if (!args[0]) {
14+
// Buttons that take you to a link
15+
// If you want to delete them, remove this part of
16+
// the code and in line: 55 delete ", components: [row]"
17+
const row = new client.discord.MessageActionRow()
18+
.addComponents(
19+
new client.discord.MessageButton()
20+
.setLabel("GitHub")
21+
.setStyle("LINK")
22+
.setURL("https://github.com/Expectatives/Discord.js-v13-Example"),
23+
new client.discord.MessageButton()
24+
.setLabel("Support")
25+
.setStyle("LINK")
26+
.setURL("https://dsc.gg/faithcommunity")
27+
);
2928

30-
// Get the commands of a Bot category
31-
const botCommandsList = [];
32-
readdirSync(`./commands/Bot`).forEach((file) => {
33-
const filen = require(`../../commands/Bot/${file}`);
34-
const name = `\`${filen.name}\``
35-
botCommandsList.push(name);
36-
});
29+
if (!args[0]) {
3730

38-
// Get the commands of a Utility category
39-
const utilityCommandsList = [];
40-
readdirSync(`./commands/Utility`).forEach((file) => {
41-
const filen = require(`../../commands/Utility/${file}`);
42-
const name = `\`${filen.name}\``
43-
utilityCommandsList.push(name);
44-
});
31+
// Get the commands of a Bot category
32+
const botCommandsList = [];
33+
readdirSync(`./commands/Bot`).forEach((file) => {
34+
const filen = require(`../../commands/Bot/${file}`);
35+
const name = `\`${filen.name}\``
36+
botCommandsList.push(name);
37+
});
4538

46-
// This is what it commands when using the command without arguments
47-
const helpEmbed = new client.discord.MessageEmbed()
48-
.setTitle(`${client.user.username} Help`)
49-
.setDescription(` Hello **<@${message.author.id}>**, I am <@${client.user.id}>. \nYou can use \`!help <command>\` to see more info about the commands!\n**Total Commands:** ${client.commands.size}\n**Total SlashCommands:** ${client.slashCommands.size}`)
50-
.addField("🤖 - Bot Commands", botCommandsList.map((data) => `${data}`).join(", "), true)
51-
.addField("🛠 - Utility Commands", utilityCommandsList.map((data) => `${data}`).join(", "), true)
52-
.setColor(client.config.embedColor)
53-
.setFooter(client.config.embedfooterText, client.user.avatarURL());
54-
55-
message.reply({embeds: [helpEmbed], allowedMentions: {repliedUser: false}, components: [row]});
56-
} else {
57-
const command = client.commands.get(args[0].toLowerCase()) || client.commands.find((c) => c.aliases && c.aliases.includes(args[0].toLowerCase()));
39+
// Get the commands of a Utility category
40+
const utilityCommandsList = [];
41+
readdirSync(`./commands/Utility`).forEach((file) => {
42+
const filen = require(`../../commands/Utility/${file}`);
43+
const name = `\`${filen.name}\``
44+
utilityCommandsList.push(name);
45+
});
5846

59-
// This is what it sends when using the command with argument and it does not find the command
60-
if (!command) {
61-
message.reply({content: `There isn't any command named "${args[0]}"`, allowedMentions: {repliedUser: false}});
62-
} else {
47+
// This is what it commands when using the command without arguments
48+
const helpEmbed = new client.discord.MessageEmbed()
49+
.setTitle(`${client.user.username} Help`)
50+
.setDescription(` Hello **<@${message.author.id}>**, I am <@${client.user.id}>. \nYou can use \`!help <command>\` to see more info about the commands!\n**Total Commands:** ${client.commands.size}\n**Total SlashCommands:** ${client.slash.size}`)
51+
.addField("🤖 - Bot Commands", botCommandsList.map((data) => `${data}`).join(", "), true)
52+
.addField("🛠 - Utility Commands", utilityCommandsList.map((data) => `${data}`).join(", "), true)
53+
.setColor(client.config.embedColor)
54+
.setFooter({ text: `${client.config.embedfooterText}`, iconURL: `${client.user.displayAvatarURL()}` });
6355

64-
// This is what it sends when using the command with argument and if it finds the command
65-
let command = client.commands.get(args[0].toLowerCase()) || client.commands.find((c) => c.aliases && c.aliases.includes(args[0].toLowerCase()));
66-
let name = command.name;
67-
let description = command.description || "No descrpition provided"
68-
let usage = command.usage || "No usage provided"
69-
let aliases = command.aliases || "No aliases provided"
70-
let category = command.category || "No category provided!"
56+
message.reply({ embeds: [helpEmbed], allowedMentions: { repliedUser: false }, components: [row] });
57+
} else {
58+
const command = client.commands.get(args[0].toLowerCase()) || client.commands.find((c) => c.aliases && c.aliases.includes(args[0].toLowerCase()));
7159

72-
let helpCmdEmbed = new client.discord.MessageEmbed()
73-
.setTitle(`${client.user.username} Help | \`${(name.toLocaleString())}\` Command`)
74-
.addFields(
75-
{ name: "Description", value: `${description}` },
76-
{ name: "Usage", value: `${usage}` },
77-
{ name: "Aliases", value: `${aliases}` },
78-
{ name: 'Category', value: `${category}` })
79-
.setColor(client.config.embedColor)
80-
.setFooter(client.config.embedfooterText, client.user.avatarURL());
81-
82-
message.reply({embeds: [helpCmdEmbed], allowedMentions: {repliedUser: false}});
83-
}
84-
}
85-
},
60+
// This is what it sends when using the command with argument and it does not find the command
61+
if (!command) {
62+
message.reply({ content: `There isn't any command named "${args[0]}"`, allowedMentions: { repliedUser: false } });
63+
} else {
64+
65+
// This is what it sends when using the command with argument and if it finds the command
66+
let command = client.commands.get(args[0].toLowerCase()) || client.commands.find((c) => c.aliases && c.aliases.includes(args[0].toLowerCase()));
67+
let name = command.name;
68+
let description = command.description || "No descrpition provided"
69+
let usage = command.usage || "No usage provided"
70+
let aliases = command.aliases || "No aliases provided"
71+
let category = command.category || "No category provided!"
72+
73+
let helpCmdEmbed = new client.discord.MessageEmbed()
74+
.setTitle(`${client.user.username} Help | \`${(name.toLocaleString())}\` Command`)
75+
.addFields(
76+
{ name: "Description", value: `${description}` },
77+
{ name: "Usage", value: `${usage}` },
78+
{ name: "Aliases", value: `${aliases}` },
79+
{ name: 'Category', value: `${category}` })
80+
.setColor(client.config.embedColor)
81+
.setFooter({ text: `${client.config.embedfooterText}`, iconURL: `${client.user.displayAvatarURL()}` });
82+
83+
message.reply({ embeds: [helpCmdEmbed], allowedMentions: { repliedUser: false } });
84+
}
85+
}
86+
},
8687
};

commands/Utility/ping.js

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

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

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

18-
await message.reply({embeds: [pingEmbed], allowedMentions: {repliedUser: false}});
19+
await message.reply({ embeds: [pingEmbed], allowedMentions: { repliedUser: false } });
1920

20-
msg.delete();
21-
},
21+
msg.delete();
22+
},
2223
};

0 commit comments

Comments
 (0)