-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create export-commands & fix giveaway errors
- Loading branch information
Showing
5 changed files
with
70 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const Command = require('../../base/Command.js'); | ||
const { QuickDB } = require('quick.db'); | ||
const { EmbedBuilder } = require('discord.js'); | ||
const fs = require('fs'); | ||
|
||
class ExportCommands extends Command { | ||
constructor(client) { | ||
super(client, { | ||
name: 'export-commands', | ||
description: 'Exports all commands to a JSON file.', | ||
category: 'General', | ||
usage: 'export-commands', | ||
examples: ['exportcommands'], | ||
aliases: ['exportcmds', 'exportjson'], | ||
}); | ||
} | ||
|
||
async run(msg, args, level) { | ||
const allCommands = this.client.commands; | ||
const commandData = {}; | ||
|
||
allCommands.forEach((cmd) => { | ||
const category = cmd.help.category || 'Unknown'; | ||
const cmdName = cmd.help.name; | ||
|
||
if (!commandData[category]) { | ||
commandData[category] = {}; | ||
} | ||
|
||
commandData[category][cmdName] = { | ||
description: cmd.help.description, | ||
usage: cmd.help.usage, | ||
examples: cmd.help.examples, | ||
aliases: cmd.conf.aliases, | ||
permissionLevel: cmd.conf.permLevel, | ||
guildOnly: cmd.conf.guildOnly, | ||
nsfw: cmd.conf.nsfw, | ||
longDescription: cmd.help.longDescription || 'None', | ||
}; | ||
}); | ||
|
||
const jsonFilePath = './commands.json'; | ||
fs.writeFileSync(jsonFilePath, JSON.stringify(commandData, null, 2), 'utf-8'); | ||
|
||
const embed = new EmbedBuilder() | ||
.setTitle('Commands Exported') | ||
.setDescription(`All commands have been exported to \`${jsonFilePath}\``) | ||
.setColor('#00FF00'); | ||
|
||
msg.channel.send({ embeds: [embed] }); | ||
} | ||
} | ||
|
||
module.exports = ExportCommands; |