mirror of
https://github.com/Art-Portal/April.git
synced 2024-11-16 19:47:34 +01:00
54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
import { SlashCommandBuilder } from "discord.js";
|
|
|
|
export default {
|
|
data: new SlashCommandBuilder()
|
|
.setName("setemoji")
|
|
.setDescription("Définir l'émoji de l'artiste ciblé.e")
|
|
.setDefaultMemberPermissions(0x4)
|
|
.addStringOption((option) =>
|
|
option.setName("emoji").setDescription("Émoji").setRequired(true),
|
|
)
|
|
.addUserOption((option) =>
|
|
option
|
|
.setName("artist")
|
|
.setDescription("Artiste à qui ajouter l'émoji !")
|
|
.setRequired(true),
|
|
),
|
|
async execute(interaction, client) {
|
|
const emoji = interaction.options.getString("emoji");
|
|
const member = interaction.options.getMember("artist");
|
|
|
|
const userAlreadyPresent = await client.database.artists.findOne({
|
|
where: { name: member.id },
|
|
});
|
|
const emojiAlreadyPresent = await client.database.artists.findOne({
|
|
where: { emoji: emoji },
|
|
});
|
|
if (emojiAlreadyPresent)
|
|
return interaction.reply({
|
|
content: `Émoji ${emoji} déjà utilisé ! (Par <@${emojiAlreadyPresent.name}>)`,
|
|
ephemeral: true,
|
|
});
|
|
|
|
if (userAlreadyPresent) {
|
|
await client.database.artists.update(
|
|
{ emoji: emoji },
|
|
{ where: { name: member.id } },
|
|
);
|
|
await interaction.reply({
|
|
content: `Émoji de <@${member.id}> modifié en ${emoji} !`,
|
|
ephemeral: true,
|
|
});
|
|
} else {
|
|
await client.database.artists.create({
|
|
name: member.id,
|
|
emoji: emoji,
|
|
});
|
|
await interaction.reply({
|
|
content: `Émoji de <@${member.id}> défini sur ${emoji} !`,
|
|
ephemeral: true,
|
|
});
|
|
}
|
|
},
|
|
};
|