mirror of
https://github.com/Art-Portal/April.git
synced 2024-12-26 03:14:17 +01:00
Added emoji registering for artists
Using /setemoji, staff can define an emoji for artists, that will automatically be added to the start of a ticket when taken.
This commit is contained in:
parent
eb115d2274
commit
7d25298377
35
commands/misc/setemoji.js
Normal file
35
commands/misc/setemoji.js
Normal file
@ -0,0 +1,35 @@
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
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 });
|
||||
}
|
||||
},
|
||||
};
|
7
index.js
7
index.js
@ -39,13 +39,20 @@ const modlog = sequelize.define('sanctions', {
|
||||
moderatorid: Sequelize.STRING
|
||||
});
|
||||
|
||||
const artists = sequelize.define('artists', {
|
||||
name: Sequelize.STRING,//id
|
||||
emoji: Sequelize.STRING,
|
||||
});
|
||||
|
||||
client.database = {
|
||||
sequelize: sequelize,
|
||||
modlog: modlog,
|
||||
blacklistdb: blacklistdb,
|
||||
artists: artists,
|
||||
};
|
||||
blacklistdb.sync();
|
||||
modlog.sync();
|
||||
artists.sync();
|
||||
|
||||
const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
|
||||
for (const file of eventFiles) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
const { PermissionFlagsBits, ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder } = require('discord.js')
|
||||
|
||||
module.exports = {
|
||||
async execute(interaction) {
|
||||
async execute(interaction, client) {
|
||||
await interaction.deferUpdate({ ephemeral: true });
|
||||
switch (interaction.customId.replace("ticket_","").split("-")[0]) {
|
||||
case 'close':
|
||||
@ -141,7 +141,8 @@ module.exports = {
|
||||
.setEmoji("🔒")
|
||||
.setCustomId(`ticket_close-${interaction.customId.replace("ticket_","").split("-")[1]}`),
|
||||
]);
|
||||
await interaction.channel.setName("🟢"+interaction.channel.name);
|
||||
const artist = await client.database.artists.findOne({ where: { name: interaction.user.id } });
|
||||
await interaction.channel.setName((artist ? artist.emoji :"🟢")+interaction.channel.name);
|
||||
await interaction.followUp({ embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor({ name: interaction.user.tag, iconURL: interaction.user.avatarURL() })
|
||||
|
Loading…
Reference in New Issue
Block a user