add base commands

This commit is contained in:
Tutur33
2024-03-02 21:42:57 +01:00
parent 95daf7ef0f
commit c9965e913f
4 changed files with 65 additions and 6 deletions
+58
View File
@@ -0,0 +1,58 @@
import { Message } from "discord.js";
interface Command {
name: string;
aliases?: string[];
description: string;
emote?: string;
utilisation?: string;
category?: string;
}
module.exports = {
aliases: ['h', 'aide'],
description: 'Affiche la liste des commandes',
emote: '📚',
utilisation: '<commande>',
async execute(message: Message, args: string[], client: any) {
const prefix = '!!'
if (args[0]) {
const command = client.commands.get(args[0]);
if (!command) {
return message.edit(`Je n'ai pas trouvé de commande nommée "${args[0]}".`);
}
return message.edit(`# Aide pour la commande ${command.emote ? ` ${command.emote}` : '🔧'} ${command.name}\nUtilisation : \`${prefix}${command.name}${command.utilisation ? ` ${command.utilisation}` : ''}\`\nCatégorie : ${command.category || 'Non spécifiée'}\nAlias : ${command.aliases ? command.aliases.map((alias: string) => `\`${alias}\``).join(', ') : 'Aucun'}`);
} else {
let commands: Command[] = [];
for (const command of client.commands?.values() || []) {
const existingCommand = commands.find(cmd => cmd.name === command.name);
if (!existingCommand) {
commands.push(command);
}
}
let categories: { [key: string]: Command[] } = {};
commands.forEach((command: any) => {
if (!categories[command.category]) {
categories[command.category] = [];
}
categories[command.category]?.push(command);
});
let description = `Pour obtenir de l'aide sur les commandes faite ${prefix}help <commande>.\n Il y a ${commands.length} commandes disponibles\n\n`;
for (const [category, commands] of Object.entries(categories)) {
description += `**Catégorie ${category}**\n`;
description += commands.length > 0 ? '> ' + commands.map(command => `\`${command.name}\``).join(', ') : '> Aucune commande dans cette catégorie';
description += '\n\n';
}
message.edit(`# 📚 Information\n${description}`)
}
},
};
+3 -4
View File
@@ -1,13 +1,12 @@
const { ButtonStyle, ButtonBuilder, ActionRowBuilder } = require('discord.js');
import { Message, Client } from 'discord.js';
module.exports = {
aliases: ['latence'],
description: 'Avoir la latence du bot.',
emote: '⏱️',
utilisation: '',
permission: 0,
async execute(message: any, args: string[], client: any) {
message.reply("pong");
async execute(message: Message, args: string[], client: Client) {
message.edit(`Pong! ${client.ws.ping}ms`);
}
};
+3 -1
View File
@@ -14,9 +14,11 @@ module.exports = {
try {
command.execute(message, args, client);
setTimeout(() => {
if (message.deletable) message.delete();
}, 300000);
} catch (error) {
console.error(error);
message.edit("Erreur lors de l'exécution de la commande");
}
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
const { Collection } = require('discord.js')
import { Collection } from 'discord.js';
const { Client } = require('discord.js-selfbot-v13');
const loadEvents = require("./loadEvents");