From 51c3ce5880af529b6efaced699963b04f7d40597 Mon Sep 17 00:00:00 2001 From: VALOU3336 Date: Tue, 27 Feb 2024 17:16:42 +0100 Subject: [PATCH] correction confession --- commands/gestion/confession.js | 4 +++- events/gestion/buttongestion.js | 16 ++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/commands/gestion/confession.js b/commands/gestion/confession.js index 6ed5769..be6f61f 100644 --- a/commands/gestion/confession.js +++ b/commands/gestion/confession.js @@ -4,6 +4,9 @@ const { ActionRowBuilder, ButtonStyle, EmbedBuilder, ButtonBuilder} = require('d module.exports = { name: 'confession', description: 'Configure les paramètres pour le salon de confession.', + category: 'gestion', + emote: '🙏', + usage: 'confession [channel|send] [channelID|#channel]', async execute(message, args) { const guildId = message.guild.id; if (!args.length) return message.reply('Veuillez spécifier une sous-commande: channel ou send.'); @@ -37,7 +40,6 @@ async function setConfessionChannel(guildId, message, channelInput) { channelId = channelInput; } - // Vérifier si le salon existe const channel = message.guild.channels.cache.get(channelId); if (!channel) { return message.reply('Le salon spécifié n\'existe pas ou l\'ID est incorrect.'); diff --git a/events/gestion/buttongestion.js b/events/gestion/buttongestion.js index 79e88de..e64f640 100644 --- a/events/gestion/buttongestion.js +++ b/events/gestion/buttongestion.js @@ -7,15 +7,6 @@ module.exports = { name: Events.InteractionCreate, async execute(interaction, client) { const botId = client.user.id; - let data = await new Promise((resolve, reject) => { - db2.get('SELECT value FROM gestion WHERE id = ?', [botId], (err, row) => { - if (err) { - console.error(err.message); - reject(err); - } - resolve(row ? JSON.parse(row.value).owners || {} : {}); - }); - }); let owners = await new Promise((resolve, reject) => { db2.get('SELECT value FROM gestion WHERE id = ?', [botId], (err, row) => { if (err) { @@ -47,13 +38,14 @@ module.exports = { await PrevnameDb.delete(userId) await interaction.reply({ content: "Vos prevname on etait correctement supprimer.", ephemeral: true }); } else if (interaction.customId.startsWith('addconfession_')) { + let data = await new Promise((resolve, reject) => { db2.get('SELECT value FROM gestion WHERE id = ?', [botId], (err, row) => { if (err) { console.error(err.message); reject(err); } - resolve(row ? JSON.parse(row.value).owners || {} : {}); + resolve(row ? JSON.parse(row.value) : {}); }); }); const guildId= interaction.customId.split('_')[1]; @@ -86,8 +78,8 @@ module.exports = { let ConfessionMessageToSend = reponse.fields.getTextInputValue('messageconfession') let ConfidentielAuthor = reponse.fields.getTextInputValue('status') let isConfidential = !ConfidentielAuthor.toLowerCase().startsWith('n'); - data.guildId = data.guildId || {}; - data.guildId.confession = data.guildId.confession || {}; + data.confession = data.confession || {}; + data.confession.channel = data.confession.channel || {}; console.log(guildId); console.log(data.guildId.confession.channel);