-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelp.js
113 lines (106 loc) · 4.45 KB
/
help.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
const fs = require('fs');
module.exports = {
name : "help",
description : "help",
aliases: ["help"],
execute(message=message, args=args, bot=bot, Discord=Discord, prefix=prefix) {
var emojiForCategory = {
"data": "🗄️",
"fun": "🎮",
"mod": "⚖️"
}
if(args[0] && args[0].toLowerCase() === 'owneronly-random') {
message.channel.send("Lmao, these are only accessible to the owner. R u gud, or r u gud????");
return;
}
const getDirectories = fs.readdirSync('./commands/', { withFileTypes: true }).filter(dirent => dirent.isDirectory()).map(dirent => dirent.name);
var commandFilesCategory = [];
var commandFiles = [];
if(!args[0]) {
commandCategories(message, Discord, prefix)
} else if(args[0] && getDirectories.includes(args[0].toLowerCase())){
args[0] = getDirectories[getDirectories.indexOf(args[0].toLowerCase())];
commandFilesCategory = fs.readdirSync(`./commands/${args[0]}/`).filter((file) => file.endsWith('.js'));
let emoji = emojiForCategory[args[0]];
commandsInCategory(message, Discord, args, commandFilesCategory, emoji, prefix);
} else if(args[0]) {
for(let dir of getDirectories) {
commandFiles = fs.readdirSync(`./commands/${dir}/`).filter((file) => file.endsWith('.js'));
for (let file of commandFiles) {
const command = require(`./commands/${dir}/${file}`);
if(command.aliases.includes(args[0].toLowerCase())) {
individualCommand(message, Discord, command, prefix);
return;
}
}
}
}
}
};
function commandCategories(message, Discord, prefix) {
const cmdCategory = new Discord.MessageEmbed()
.setTitle('CBot Command Catagories')
.setDescription("all the command categories for [CBot](https://github.com/jjoel1630/CBot)")
.addFields(
{
name: `🗄️ Data`, value: `\`${prefix}help data\``, inline: true
},
{
name: `🎮 Fun & Games`, value: `\`${prefix}help fun\``, inline: true
},
{
name: `⚖️ Moderation`, value: `\`${prefix}help mod\``, inline: true
},
{
name: `Having issues with the bot or want to suggest/contribute features?`, value: `Check out my [git-repo](https://github.com/jjoel1630/CBot)!`
}
)
.setFooter(`The prefix for this bot is ${prefix}`)
message.channel.send(cmdCategory);
}
function commandsInCategory(message, Discord, args, commandFilesCategory, emoji, prefix) {
var alias =[];
for(var i = 0; i < commandFilesCategory.length; i++) {
// let a = commandFilesCategory[i].split('.');
// a.splice(1, 1);
// commandFilesCategory[i] = "`" + a.join() + "`";
const commandAlias = require(`./commands/${args[0]}/${commandFilesCategory[i]}`)
alias.push(`\`${commandAlias.aliases[0]}\``);
}
// commandFilesCategory.join(', ');
args[0] = args[0].charAt(0).toUpperCase() + args[0].slice(1);
const cmdCategory = new Discord.MessageEmbed()
.setTitle(`${emoji} ${args[0]} Commands`)
.setDescription("all the [CBot](https://github.com/jjoel1630/CBot) commands for this category")
.addFields(
{
name: `${alias}`, value: `** **`
},
{
name: `Having issues with the bot or want to suggest/contribute features?`, value: `Check out my [git-repo](https://github.com/jjoel1630/CBot)!`
},
)
.setFooter(`The prefix for this bot is ${prefix}`);
message.channel.send(cmdCategory);
}
function individualCommand(message, Discord, command, prefix) {
const individualCommand = new Discord.MessageEmbed()
.setTitle(`The ${command?.name} command`)
.setDescription("all the [CBot](https://github.com/jjoel1630/CBot) commands for this category")
.addFields(
{
name: `Description`, value: `${command?.description}`
},
{
name: `Command Usage`, value: `${command?.usage}`
},
{
name: `Aliases`, value: `${command?.aliases.join(', ')}`
},
{
name: `Perms`, value: `${command.perms ? command.perms : 'Anyone can run this command'}`
},
)
.setFooter(`The prefix for this bot is ${prefix}`);
message.channel.send(individualCommand);
}