Compare commits

...

2 commits

2 changed files with 57 additions and 5 deletions

View file

@ -1,4 +1,4 @@
import { SlashCommandBuilder, EmbedBuilder, AttachmentBuilder } from 'discord.js'; import { SlashCommandBuilder, EmbedBuilder, AttachmentBuilder, PermissionsBitField } from 'discord.js';
import fs from 'node:fs'; import fs from 'node:fs';
const { ownerId, prefix } = process.env; const { ownerId, prefix } = process.env;
@ -27,8 +27,13 @@ export default {
let type = 'String'; let type = 'String';
const constructorName = cmd.constructor.name.toLowerCase(); const constructorName = cmd.constructor.name.toLowerCase();
if (constructorName.includes('boolean')) { if (constructorName.includes('boolean')) {
if (interaction.isMessage) {
type = `--${cmd.name}`;
}
else {
type = 'True/False'; type = 'True/False';
} }
}
else if (constructorName.includes('mentionable')) { else if (constructorName.includes('mentionable')) {
type = 'User'; type = 'User';
} }
@ -39,9 +44,14 @@ export default {
return `[${cmd.name}: ${type}]`; return `[${cmd.name}: ${type}]`;
}); });
let p = '/';
if (interaction.isMessage) {
p = prefixs[0];
}
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
.setColor(interaction.member ? interaction.member.displayHexColor : 'NAVY') .setColor(interaction.member ? interaction.member.displayHexColor : 'NAVY')
.setTitle(`\`${prefixs[0]}${command.data.name} ${usage.join(' ')}\``) .setTitle(`\`${p}${command.data.name} ${usage.join(' ')}\``)
.addFields( .addFields(
{ name: 'Description', value: description.description }, { name: 'Description', value: description.description },
) )
@ -53,6 +63,33 @@ export default {
const text = `${prefixs[0]}${command.alias[0]}`; const text = `${prefixs[0]}${command.alias[0]}`;
embed.addFields({ name: 'Examples', value: `\`${text} ${description.examples.join(`\`\n\`${text} `)}\``, inline: true }); embed.addFields({ name: 'Examples', value: `\`${text} ${description.examples.join(`\`\n\`${text} `)}\``, inline: true });
} }
else {
const example = command.data.options.map(cmd => {
let string = '"lorem ipsum"';
const constructorName = cmd.constructor.name.toLowerCase();
if (constructorName.includes('boolean')) {
if (interaction.isMessage) {
string = `--${cmd.name}`;
}
else {
string = 'True/False';
}
}
else if (constructorName.includes('mentionable')) {
string = `@${interaction.user.username}`;
}
else if (constructorName.includes('attachment')) {
string = 'Attachment';
}
if (!interaction.isMessage) {
string = `\`\`${cmd.name}:${string}\`\``;
}
return string;
});
embed.addFields({ name: 'Example', value: `${p}${command.data.name} ${example.join(' ')}`, inline: true });
}
if (command.alias) { if (command.alias) {
if (command.alias.length >= 1) { if (command.alias.length >= 1) {
@ -61,11 +98,19 @@ export default {
} }
if (command.userPermissions) { if (command.userPermissions) {
embed.addFields({ name: 'User permission', value: `\`${command.userPermissions.join('` `')}\``, inline: true }); const perm = [];
command.userPermissions.forEach(permission => {
perm.push(new PermissionsBitField(permission).toArray());
});
embed.addFields({ name: 'User permission', value: `\`${perm.join('` `')}\``, inline: true });
} }
if (command.clientPermissions) { if (command.clientPermissions) {
embed.addFields({ name: 'Bot permission', value: `\`${command.clientPermissions.join('` `')}\``, inline: true }); const perm = [];
command.clientPermissions.forEach(permission => {
perm.push(new PermissionsBitField(permission).toArray());
});
embed.addFields({ name: 'Bot permission', value: `\`${perm.join('` `')}\``, inline: true });
} }
if (fs.existsSync(`./asset/img/command/${command.category}/${command.data.name}.png`)) { if (fs.existsSync(`./asset/img/command/${command.category}/${command.data.name}.png`)) {

View file

@ -182,6 +182,13 @@ const commands = [
option.setName('url') option.setName('url')
.setDescription('URL of the video you want to add.') .setDescription('URL of the video you want to add.')
.setRequired(true)), .setRequired(true)),
new SlashCommandBuilder()
.setName('help')
.setDescription('Displays a list of commands or information about a command.')
.addStringOption(option =>
option.setName('command')
.setDescription('The command you want more details about.')),
] ]
.map(command => command.toJSON()); .map(command => command.toJSON());