Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- exports.run = (bot, message, args, func) => {
- const embed = new Discord.RichEmbed()
- .setColor(0x1D82B6)
- let commandsFound = 0;
- const commands = JSON.parse(fs.readFileSync('Storage/commands.json', 'utf8'));
- for (var cmd in commands) {
- if (commands[cmd].group.toUpperCase() === 'USER') {
- commandsFound++
- embed.addField(`${commands[cmd].name}`, `**Description:** ${commands[cmd].desc}\n**Usage:** ${prefix + commands[cmd].usage}`); // This will output something like <commandname>[title] [newline] desc: <description> [newline] usage: <usage
- }
- }
- embed.setFooter(`Currently showing user commands. To view another group do ${prefix}help [group / command]`)
- embed.setDescription(`**${commandsFound} commands found** - <> means required, [] means optional`)
- message.author.send({embed})
- message.channel.send({embed: {
- color: 0x1D82B6,
- description: `**Check your DMs ${message.author}!**`
- }})
- if (args.join(" ").toUpperCase() === 'GROUPS') {
- let groups = '';
- for (var cmd in commands) {
- if (!groups.includes(commands[cmd].group)) {
- groups += `${commands[cmd].group}\n`
- }
- }
- message.channel.send({embed: {
- description:`**${groups}**`,
- title:"Groups",
- color: 0x1D82B6
- }})
- return;
- } else {
- let groupFound = '';
- for (var cmd in commands) {
- if (args.join(" ").trim().toUpperCase() === commands[cmd].group.toUpperCase()) {
- groupFound = commands[cmd].group.toUpperCase();
- break;
- }
- }
- if (groupFound != '') {
- // Start of the embed
- const embed = new Discord.RichEmbed()
- .setColor(0x1D82B6)
- // Variables
- let commandsFound = 0;
- for (var cmd in commands) {
- if (commands[cmd].group.toUpperCase() === groupFound) {
- commandsFound++
- embed.addField(`${commands[cmd].name}`, `**Description:** ${commands[cmd].desc}\n**Usage:** ${prefix + commands[cmd].usage}`); // This will output something like <commandname>[title] [newline] desc: <description> [newline] usage: <usage
- }
- }
- embed.setFooter(`Currently showing ${groupFound} commands. To view another group do ${prefix}help [group / command]`)
- embed.setDescription(`**${commandsFound} commands found** - <> means required, [] means optional`)
- message.author.send({embed})
- message.channel.send({embed: {
- color: 0x1D82B6,
- description: `**Check your DMs ${message.author}!**`
- }})
- return;
- }
- let commandFound = '';
- let commandDesc = '';
- let commandUsage = '';
- let commandGroup = '';
- for (var cmd in commands) {
- if (args.join(" ").trim().toUpperCase() === commands[cmd].name.toUpperCase()) {
- commandFound = commands[cmd].name;
- commandDesc = commands[cmd].desc;
- commandUsage = commands[cmd].usage;
- commandGroup = commands[cmd].group;
- break;
- }
- }
- if (commandFound === '') {
- message.channel.send({embed: {
- description:`**No group or command found titled \`${args.join(" ")}\`**`,
- color: 0x1D82B6,
- }})
- }
- message.channel.send({embed: {
- title:'<> means required, [] means optional',
- color: 0x1D82B6,
- fields: [{
- name:commandFound,
- value:`**Description:** ${commandDesc}\n**Usage:** ${commandUsage}\n**Group:** ${commandGroup}`
- }]
- }})
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement