generated from FnrDev/fnr-template
-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ticket category & delete command
- Loading branch information
Showing
7 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
const { MessageActionRow, MessageButton, MessageEmbed } = require('discord.js'); | ||
const settings = require('../../settings.json'); | ||
|
||
module.exports = { | ||
name: "delete", | ||
description: "Delete a ticket channel.", | ||
modOnly: true, | ||
ticketOnly: true, | ||
category: "ticket", | ||
run: async(interaction, client) => { | ||
const row = new MessageActionRow() | ||
.addComponents( | ||
new MessageButton() | ||
.setCustomId('delete_ticket') | ||
.setStyle('DANGER') | ||
.setLabel('Delete') | ||
) | ||
.addComponents( | ||
new MessageButton() | ||
.setCustomId('cancel') | ||
.setStyle('SECONDARY') | ||
.setLabel('Cancel') | ||
) | ||
await interaction.reply({ | ||
content: `Are you sure to delete **#${interaction.channel.name}** ticket.`, | ||
fetchReply: true, | ||
components: [row] | ||
}); | ||
const filter = i => i.customId === 'delete_ticket' || 'cancel' && i.user.id === interaction.user.id; | ||
const collector = interaction.channel.createMessageComponentCollector({ filter: filter, time: 20000 }); | ||
collector.on('collect', async i => { | ||
if (i.customId === 'delete_ticket') { | ||
const logChannel = client.channels.cache.get(settings.logChannel); | ||
if (!logChannel) return; | ||
const embed = new MessageEmbed() | ||
.setAuthor(interaction.user.tag, interaction.user.displayAvatarURL({ dynamic: true })) | ||
.setDescription(`${interaction.user} deleted a **#${interaction.channel.name}** ticket.`) | ||
.addField("Ticket ID:", interaction.channel.id, true) | ||
.addField("Ticket Created At:", `<t:${Math.floor(interaction.channel.createdTimestamp / 1000)}:R>`, true) | ||
.addField("Ticket Deleted At:", `<t:${Math.floor(Date.now() / 1000)}:R>`, true) | ||
.setColor(settings.embedColor) | ||
.setTimestamp() | ||
.setThumbnail(interaction.user.displayAvatarURL({ dynamic: true })) | ||
await logChannel.send({ | ||
embeds: [embed] | ||
}) | ||
return interaction.channel.delete(`By: ${interaction.user.tag}`); | ||
} | ||
if (i.customId === 'cancel') { | ||
await interaction.deleteReply(); | ||
} | ||
}); | ||
collector.on('end', async i => { | ||
try { | ||
await interaction.deleteReply(); | ||
} catch (e) { | ||
return false; | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters