This commit is contained in:
*x1
2024-06-17 18:20:25 +02:00
3 changed files with 161 additions and 120 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ module.exports = {
message.reply({ embeds: [embed], components: [row], allowedMentions: { repliedUser: false } });
client.on('interactionCreate', async (interaction) => {
if (!interaction.isSelectMenu()) return;
if (!interaction.isStringSelectMenu()) return;
if (!interaction.customId === 'shop') return
const selected = interaction.values[0];
+148 -119
View File
@@ -1,7 +1,8 @@
const { EmbedBuilder, ButtonStyle, ButtonBuilder, ActionRowBuilder } = require('discord.js');
const embedColor = require('../../fonctions/embedColor.js');
const getPrefix = require('../../fonctions/getPrefix.js');
function commandsList (client, category) {
function commandsList (client, category, prefix) {
const casinoCommands = client.commands.filter(command => command.category === category).sort((a, b) => a.name.localeCompare(b.name));
const uniqueCommands = new Map();
@@ -11,7 +12,7 @@ function commandsList (client, category) {
let commandsList = '';
uniqueCommands.forEach((command, name) => {
commandsList += `> ${command.emote} \`${name}${command.utilisation ? ' ' + command.utilisation : ''}\`\n> ┖ ${command.description}\n\n`;
commandsList += `> ${command.emote} \`${prefix}${name}${command.utilisation ? ' ' + command.utilisation : ''}\`\n> ┖ ${command.description}\n\n`;
});
return commandsList;
@@ -25,139 +26,167 @@ module.exports = {
permission: 0,
async execute(message, args, client) {
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 &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);
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() });
const rightButton = new ButtonBuilder()
.setCustomId('right')
.setLabel('▶')
.setStyle(ButtonStyle.Primary);
message.reply({ embeds: [embed], allowedMentions: { repliedUser: false } });
} else {
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))
const row = new ActionRowBuilder()
.addComponents(leftButton, rightButton);
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 messageEmbed = await message.reply({ embeds: [embedPage1], components: [row], allowedMentions: { repliedUser: false } });
const rightButton = new ButtonBuilder()
.setCustomId('right')
.setLabel('▶')
.setStyle(ButtonStyle.Primary);
const filter = i => i.user.id === message.author.id;
const collector = message.channel.createMessageComponentCollector({ filter, time: 90000 });
const row = new ActionRowBuilder()
.addComponents(leftButton, rightButton);
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;
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 (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'))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 2/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() });
const filter = i => i.user.id === message.author.id;
const collector = message.channel.createMessageComponentCollector({ filter, time: 90000 });
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'))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 3/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: [embedPage3], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 4) {
const embedPage4 = new EmbedBuilder()
.setTitle('🛍️・Achats')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'achats'))
.setColor(await embedColor(message.author.id, message.guild.id))
.setTimestamp()
.setFooter({ text: `Page 4/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: [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'))
.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: [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: [embedPage5], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 6) {
const embedPage6 = new EmbedBuilder()
.setTitle('💼・Teams')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'teams'))
.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: [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: [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'))
.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: [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: [embedPage7], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 8) {
const embedPage8 = new EmbedBuilder()
.setTitle('🤝・Alliance')
.setThumbnail(message.guild.iconURL())
.setDescription(`page 8`)
.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: [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: [embedPage8], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 9) {
const embedPage9 = new EmbedBuilder()
.setTitle('👑・Gestion')
.setThumbnail(message.guild.iconURL())
.setDescription(commandsList(client, 'gestion'))
.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: [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: [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'))
.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: [embedPage7], components: [row], allowedMentions: { repliedUser: false } });
} else if (page === 8) {
const embedPage8 = new EmbedBuilder()
.setTitle('🤝・Alliance')
.setThumbnail(message.guild.iconURL())
.setDescription(`page 8`)
.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: [embedPage10], components: [row], allowedMentions: { repliedUser: false } });
}
});
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() });
collector.on('end', () => {
messageEmbed.edit({ components: [], 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() });
i.update({ embeds: [embedPage10], components: [row], allowedMentions: { repliedUser: false } });
}
});
collector.on('end', () => {
messageEmbed.edit({ components: [], allowedMentions: { repliedUser: false } })
});
}
}
};
+12
View File
@@ -0,0 +1,12 @@
const db = require('./database.js');
module.exports = async function getPrefix(serverId) {
const prefix = await new Promise((resolve, reject) => {
db.get(`SELECT * FROM config WHERE guildId = ? AND name = ?`, [serverId, 'prefix'], (err, row) => {
if (err) reject(err);
resolve(row);
});
});
return prefix ? prefix.value : '&';
}