Add envoie le panel help lors du ping du bot

This commit is contained in:
*x1
2024-06-19 16:15:04 +02:00
parent b1c8fcee66
commit 00309fac1c
2 changed files with 153 additions and 144 deletions
+143 -144
View File
@@ -26,167 +26,166 @@ module.exports = {
permission: 0,
async execute(message, args, client) {
if (args[0] && client.commands.has(args[0])) {
const command = client.commands.get(args[0]);
const prefix = await getPrefix(message.guild.id);
const embed = new EmbedBuilder()
.setTitle(`📚・${command.name}`)
.setThumbnail(message.guild.iconURL())
.setDescription(`> **Description :** ${command.description}\n> **Utilisation :** \`${prefix}${command.name}${command.utilisation ? ' ' + command.utilisation : ''}\`\n> **Alias :** ${command.aliases.join(', ') || 'Aucun'}\n> **Permission :** ${command.permission}\n> **Catégorie :** ${command.category}\n> **Emote :** ${command.emote}`)
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
message.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
} else {
if (args[0]) {
if (args) {
if (args[0] && client.commands.has(args[0])) {
const command = client.commands.get(args[0]);
const prefix = await getPrefix(message.guild.id);
const embed = new EmbedBuilder()
.setTitle('❌・Commande inconnue')
.setDescription('La commande que vous avez demandée n\'existe pas. Nous vous invitons à vérifier l\'orthographe dans le help si dessous et à réessayer.')
.setTitle(`📚・${command.name}`)
.setThumbnail(message.guild.iconURL())
.setDescription(`> **Description :** ${command.description}\n> **Utilisation :** \`${prefix}${command.name}${command.utilisation ? ' ' + command.utilisation : ''}\`\n> **Alias :** ${command.aliases.join(', ') || 'Aucun'}\n> **Permission :** ${command.permission}\n> **Catégorie :** ${command.category}\n> **Emote :** ${command.emote}`)
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
message.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
}
const prefix = await getPrefix(message.guild.id);
const embedPage1 = new EmbedBuilder()
.setTitle('📚 ・Information')
.setThumbnail(message.guild.iconURL())
.setDescription(`Voici le panel d'aide du bot. Pour plus d'informations sur une commande, utilisez ${prefix}help <commande>\n\n> **🎙️ Récompenses vocales :**\n> Vous gagnez \`100\` coins toutes les \`15\`minutes lorsque vous êtes en vocal (**NON MUTE** sinon c'est \`50\`coins).\n \n> **📺 Récompenses de streaming :**\n> Activer un stream vous fera gagner \`200\`.\n \n> **📷 Récompenses de caméra :**\n> Activer votre caméra vous fera gagner \`200\`.\n\n> Le coins est une monnaie fictive.`)
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 1/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
const leftButton = new ButtonBuilder()
.setCustomId('left')
.setLabel('◀')
.setStyle(ButtonStyle.Primary);
const rightButton = new ButtonBuilder()
.setCustomId('right')
.setLabel('▶')
.setStyle(ButtonStyle.Primary);
const row = new ActionRowBuilder()
.addComponents(leftButton, rightButton);
let messageEmbed;
if (args[0]) {
messageEmbed = await message.channel.send({ embeds: [embedPage1], components: [row], allowedMentions: { repliedUser: false } });
} else {
messageEmbed = await message.reply({ embeds: [embedPage1], components: [row], allowedMentions: { repliedUser: false } });
if (args[0]) {
const embed = new EmbedBuilder()
.setTitle('❌・Commande inconnue')
.setDescription('La commande que vous avez demandée n\'existe pas. Nous vous invitons à vérifier l\'orthographe dans le help si dessous et à réessayer.')
.setColor(await embedColor(message.author.id, message.guild.id))
message.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
}
}
}
const prefix = await getPrefix(message.guild.id);
const embedPage1 = new EmbedBuilder()
.setTitle('📚 ・Information')
.setThumbnail(message.guild.iconURL())
.setDescription(`Voici le panel d'aide du bot. Pour plus d'informations sur une commande, utilisez ${prefix}help <commande>\n\n> **🎙️ Récompenses vocales :**\n> Vous gagnez \`100\` coins toutes les \`15\`minutes lorsque vous êtes en vocal (**NON MUTE** sinon c'est \`50\`coins).\n \n> **📺 Récompenses de streaming :**\n> Activer un stream vous fera gagner \`200\`.\n \n> **📷 Récompenses de caméra :**\n> Activer votre caméra vous fera gagner \`200\`.\n\n> Le coins est une monnaie fictive.`)
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 1/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
const leftButton = new ButtonBuilder()
.setCustomId('left')
.setLabel('◀')
.setStyle(ButtonStyle.Primary);
const rightButton = new ButtonBuilder()
.setCustomId('right')
.setLabel('▶')
.setStyle(ButtonStyle.Primary);
const row = new ActionRowBuilder()
.addComponents(leftButton, rightButton);
let messageEmbed;
messageEmbed = await message.reply({ embeds: [embedPage1], components: [row], allowedMentions: { repliedUser: false } });
const filter = i => i.user.id === message.author.id;
const collector = message.channel.createMessageComponentCollector({ filter, time: 120000 });
let page = 1;
collector.on('collect', async i => {
if (i.customId === 'left') {
page--;
if (page < 1) page = 10;
} else if (i.customId === 'right') {
page++;
if (page > 10) page = 1;
}
const filter = i => i.user.id === message.author.id;
const collector = message.channel.createMessageComponentCollector({ filter, time: 120000 });
if (page === 1) {
i.update({ embeds: [embedPage1], components: [row] });
} else if (page === 2) {
const embedPage2 = new EmbedBuilder()
.setTitle('💰・Casino')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'casino', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 2/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
let page = 1;
collector.on('collect', async i => {
if (i.customId === 'left') {
page--;
if (page < 1) page = 10;
} else if (i.customId === 'right') {
page++;
if (page > 10) page = 1;
}
i.update({ embeds: [embedPage2], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 3) {
const embedPage3 = new EmbedBuilder()
.setTitle('🎲・Jeux')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'jeux', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 3/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
if (page === 1) {
i.update({ embeds: [embedPage1], components: [row] });
} else if (page === 2) {
const embedPage2 = new EmbedBuilder()
.setTitle('💰・Casino')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'casino', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 2/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
i.update({ embeds: [embedPage3], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 4) {
const embedPage4 = new EmbedBuilder()
.setTitle('🛍️・Achats')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'achats', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 4/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
i.update({ embeds: [embedPage2], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 3) {
const embedPage3 = new EmbedBuilder()
.setTitle('🎲・Jeux')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'jeux', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 3/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
i.update({ embeds: [embedPage4], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 5) {
const embedPage5 = new EmbedBuilder()
.setTitle('🏭・Metier et capacité')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'jobs', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 5/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
i.update({ embeds: [embedPage3], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 4) {
const embedPage4 = new EmbedBuilder()
.setTitle('🛍️・Achats')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'achats', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 4/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
i.update({ embeds: [embedPage5], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 6) {
const embedPage6 = new EmbedBuilder()
.setTitle('💼・Teams')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'teams', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 6/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
i.update({ embeds: [embedPage4], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 5) {
const embedPage5 = new EmbedBuilder()
.setTitle('🏭・Metier et capacité')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'jobs', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 5/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
i.update({ embeds: [embedPage6], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 7) {
const embedPage7 = new EmbedBuilder()
.setTitle('🛡️・Teams administration')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'teams admin', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 7/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
i.update({ embeds: [embedPage5], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 6) {
const embedPage6 = new EmbedBuilder()
.setTitle('💼・Teams')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'teams', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 6/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
i.update({ embeds: [embedPage7], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 8) {
const embedPage8 = new EmbedBuilder()
.setTitle('🤝・Alliance')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'Alliance', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 8/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
i.update({ embeds: [embedPage6], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 7) {
const embedPage7 = new EmbedBuilder()
.setTitle('🛡️・Teams administration')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'teams admin', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 7/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
i.update({ embeds: [embedPage8], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 9) {
const embedPage9 = new EmbedBuilder()
.setTitle('👑・Gestion')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'gestion', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 9/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
i.update({ embeds: [embedPage7], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 8) {
const embedPage8 = new EmbedBuilder()
.setTitle('🤝・Alliance')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'Alliance', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 8/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
i.update({ embeds: [embedPage9], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 10) {
const embedPage10 = new EmbedBuilder()
.setTitle('👑・Bot control')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'bot control', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 10/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
i.update({ embeds: [embedPage8], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 9) {
const embedPage9 = new EmbedBuilder()
.setTitle('👑・Gestion')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'gestion', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 9/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
i.update({ embeds: [embedPage10], components: [row], allowedMentions: { repliedUser: false } });
}
});
i.update({ embeds: [embedPage9], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 10) {
const embedPage10 = new EmbedBuilder()
.setTitle('👑・Bot control')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'bot control', prefix))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 10/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
collector.on('end', () => {
messageEmbed.edit({ components: [], allowedMentions: { repliedUser: false } })
});
i.update({ embeds: [embedPage10], components: [row], allowedMentions: { repliedUser: false } });
}
});
collector.on('end', () => {
messageEmbed.edit({ components: [], allowedMentions: { repliedUser: false } })
});
}
}
};
+10
View File
@@ -6,6 +6,16 @@ module.exports = {
name: Events.MessageCreate,
async execute(message, client) {
if (message.author.bot) return;
if (message.content == "<@" + client.user.id + ">") {
const command = client.commands.get('help');
try {
command.execute(message, null, client);
console.log(`[&] ${message.guild.name} | ${message.author.tag} | ${command.name}`.blue)
} catch (error) {
console.error(error);
message.reply("Erreur lors de l'exécution de la commande");
}
}
const user = await new Promise((resolve, reject) => {
db.get(`SELECT * FROM users WHERE guildId = ? AND userId = ?`, [message.guild.id, message.author.id], (err, row) => {
if (err) reject(err);