This commit is contained in:
parent
cde8b0e96a
commit
29e4d4cd32
@ -1,5 +1,5 @@
|
|||||||
// comandos/add.js
|
// comandos/add.js
|
||||||
const { InteractionContextType, PermissionFlagsBits, SlashCommandBuilder, MessageFlags } = require('discord.js');
|
const { InteractionContextType, EmbedBuilder, PermissionFlagsBits, SlashCommandBuilder, MessageFlags } = require('discord.js');
|
||||||
const conn = require('../../../database/db'); // Ajusta o caminho
|
const conn = require('../../../database/db'); // Ajusta o caminho
|
||||||
|
|
||||||
|
|
||||||
@ -52,15 +52,12 @@ module.exports = {
|
|||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 1 - Verificar se já existe no banco
|
// 1 - Verificar se já existe no banco
|
||||||
const [existing] = await conn.execute(
|
const [existing] = await conn.execute(`SELECT * FROM users WHERE discord_id = ?`, [nome.id]);
|
||||||
`SELECT * FROM users WHERE discord_id = ?`,
|
|
||||||
[nome.id]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (existing.length > 0) {
|
if (existing.length > 0) {
|
||||||
return await interaction.editReply({ content: `❗ O membro ${nome.username} já está registrado no banco de dados.`, ephemeral: true });
|
return await interaction.editReply({ content: `❗ O membro ${nome.username} já está registrado no banco de dados.`, ephemeral: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2 - Inserir no banco
|
// 2 - Inserir no banco
|
||||||
await conn.execute(
|
await conn.execute(
|
||||||
@ -92,5 +89,23 @@ module.exports = {
|
|||||||
console.error('❌ Erro ao adicionar o cargo:', error);
|
console.error('❌ Erro ao adicionar o cargo:', error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setTitle('📋 Informações do Membro')
|
||||||
|
.setColor('Green')
|
||||||
|
.setDescription(`
|
||||||
|
\`\`\`
|
||||||
|
Nome | Cargo | ID
|
||||||
|
-------------------------------------------
|
||||||
|
${nome.username} | ${cargo} | ${nome.id}
|
||||||
|
\`\`\`
|
||||||
|
`)
|
||||||
|
.setFooter({ text: 'Adicionado à base de dados ✅' });
|
||||||
|
|
||||||
|
await interaction.editReply({ embeds: [embed] });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
Loading…
x
Reference in New Issue
Block a user