ajouter gif commande and corrige help and loadCommande

This commit is contained in:
VALOU3336
2024-02-27 11:28:49 +01:00
parent 16a446c9c1
commit 2f2a7995d7
6 changed files with 83 additions and 20 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ module.exports = {
return message.reply('Vous devez entrer un nombre entre 1 et 99');
}
await message.reply('🗑️ Clear en cours...');
await message.channel.bulkDelete(amount, true).catch((err) => {
await message.channel.bulkDelete(amount + 1, true).catch((err) => {
message.reply('Une erreur est survenue lors du clear');
});
},
+36
View File
@@ -0,0 +1,36 @@
const Discord = require("discord.js")
const giphy = require("giphy-api")("eW1dIGt8WPveUcxEZgXAFtEmuZ8MTxmy");
module.exports = {
name: 'gif',
usage: 'gif [terme de recherche]',
description: 'Recherche un gif basé sur le terme de recherche fourni.',
emote: '🎮',
category: 'utils',
async execute(message, args, client) {
if (args.length === 0) {
message.channel.send("Indiquez une recherche");
return;
}
if (args.length === 1) {
term = args.toString();
} else {
term = args.join(" ");
}
giphy.search(term).then(function (res) {
let id = res.data[0].id;
let msgurl = `https://media.giphy.com/media/${id}/giphy.gif`;
const embed = new Discord.EmbedBuilder()
.setTitle(`Résultat pour \`${term}\``)
.setImage(msgurl)
.setFooter({text: `${client.user.username}`})
message.channel.send({ embeds: [embed] });
});
message.delete();
},
};
+36 -17
View File
@@ -1,6 +1,6 @@
const { EmbedBuilder, StringSelectMenuBuilder, ActionRowBuilder } = require("discord.js")
const db = require('quick.db');
const GestionDb = new db.table("gestion");
const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('myDatabase.db');
module.exports = {
name: 'help',
@@ -11,22 +11,42 @@ module.exports = {
utilisation: 'help [commande]',
async execute(message, args, client) {
const botId = client.user.id;
const botInfo = GestionDb.get(botId);
const permissions = botInfo.permissions;
const botId = client.user.id;
const guildId = message.guild.id;
const defaultprefix = "+";
let mainPrefix = await GestionDb.get(`${botId}.prefix`);
let serverPrefix = await GestionDb.get(`${botId}.${guildId}.prefix`);
const prefix = serverPrefix !== undefined ? serverPrefix : mainPrefix !== undefined ? mainPrefix : defaultprefix;
let data = await new Promise((resolve, reject) => {
db.get('SELECT value FROM gestion WHERE id = ?', [botId], (err, row) => {
if (err) {
console.error(err.message);
reject(err);
}
resolve(row ? JSON.parse(row.value) : {});
});
});
const permissions = data.permissions || {};
const defaultPrefix = "+";
let mainPrefix = data.prefixes && data.prefixes.main ? data.prefixes.main : defaultPrefix;
let serverPrefix = data.prefixes && data.prefixes[guildId];
const prefix = serverPrefix !== undefined ? serverPrefix : mainPrefix;
if (args[0]) {
const command = client.commands.get(args[0]);
if (!command) {
return message.reply(`Je n'ai pas trouvé de commande nommée "${args[0]}".`);
}
const commandPerm = await permissions[command.name];
let customAliases = [];
if (data.alias && data.alias[command.name]) {
customAliases = Object.keys(data.alias[command.name]);
}
const allAliases = [...(command.aliases || []), ...customAliases];
let aliasesField = { name: 'Alias', value: 'Aucun', inline: true };
if (allAliases.length > 0) {
aliasesField.value = allAliases.map(alias => `\`${alias}\``).join(', ');
}
const embed_command = new EmbedBuilder()
.setColor('#0099ff')
.setTitle(`Aide pour la commande ${command.emote ? ` ${command.emote}` : '🔧'} ${command.name}`)
@@ -34,16 +54,15 @@ module.exports = {
.addFields(
{ name: 'Utilisation', value: `\`${prefix}${command.utilisation ? `${command.utilisation}` : ''}\``, inline: true },
{ name: 'Catégorie', value: command.category || 'Non spécifiée', inline: true },
{ name: 'Alias', value: command.aliases ? command.aliases.map(alias => `\`${alias}\``).join(', ') : 'Aucun', inline: true },
{ name: 'Permissions', value: `Perm level: ${commandPerm}` || 'Indéfini', inline: true },
aliasesField,
{ name: 'Permissions', value: commandPerm === 11 ? 'buyer' : commandPerm === 10 ? 'owner' : `Perm level: ${commandPerm}`, inline: true },
)
.setTimestamp()
.setFooter({text: `${client.user.tag} © 2024`, iconURL: client.user.displayAvatarURL({dynamic: true})})
return message.reply({ embeds: [embed_command] });
.setFooter({text: `${client.user.tag} © 2024`, iconURL: client.user.displayAvatarURL({dynamic: true})})
return message.reply({ embeds: [embed_command] });
}
const categories = {
antiraid: [],
botcontrol: [],
+3 -2
View File
@@ -81,9 +81,10 @@ module.exports = (client) => {
const permissions = data.permissions || {};
const defaultPrefix = "+";
let mainPrefix = data.prefix || defaultPrefix;
let serverPrefix = data.permissions && data.permissions[guildId] && data.permissions[guildId].prefix || mainPrefix;
let mainPrefix = data.prefixes && data.prefixes.main ? data.prefixes.main : defaultPrefix;
let serverPrefix = data.prefixes && data.prefixes[guildId];
const prefix = serverPrefix !== undefined ? serverPrefix : mainPrefix;
if (!message.content.startsWith(prefix) || message.author.bot) return;
+6
View File
@@ -15,6 +15,7 @@
"discord.js": "^14.14.1",
"discordjs-button-pagination": "^3.0.1",
"dotenv": "^16.4.4",
"giphy-api": "^2.0.2",
"ms": "^2.1.3",
"quick.db": "^7.1.3",
"sqlite": "^5.1.1",
@@ -811,6 +812,11 @@
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
}
},
"node_modules/giphy-api": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/giphy-api/-/giphy-api-2.0.2.tgz",
"integrity": "sha512-vZaLQhgMF0mDQSNpqooe4Zqoe2dWGqVYhh7Ar6I41BRtcZtfupr9avT23IIPScKBYfb3qAfiKQRQyKgLi8Lcxw=="
},
"node_modules/github-from-package": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz",
+1
View File
@@ -23,6 +23,7 @@
"discord.js": "^14.14.1",
"discordjs-button-pagination": "^3.0.1",
"dotenv": "^16.4.4",
"giphy-api": "^2.0.2",
"ms": "^2.1.3",
"quick.db": "^7.1.3",
"sqlite": "^5.1.1",