Skip to content

Commit

Permalink
Development (#7)
Browse files Browse the repository at this point in the history
* feat(button-ticket): create ticket, set permiss, and test msg (#2)

* update(readme): readme (#1)

* feat(button-ticket): embed and close button is done

* deb: remove console.log
  • Loading branch information
osiic authored Sep 22, 2023
1 parent c0d6492 commit 607ba0d
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions events/interactionCreate.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
const {
Events,
Collection,
ButtonStyle,
ChannelType,
EmbedBuilder,
ButtonBuilder,
ActionRowBuilder,
PermissionFlagsBits,
Events,
} = require("discord.js");

module.exports = {
Expand Down Expand Up @@ -58,13 +62,14 @@ module.exports = {
}
} else if (interaction.isButton()) {
// respond to the button

try {
let channel;
await interaction.deferReply({ ephemeral: true });

switch (interaction.customId) {
case "open-ticket":
try {
channel = await interaction.guild.channels.create({
| let channel = await interaction.guild.channels.create({
name: `t-${interaction.user.username}`,
type: ChannelType.GuildText,
permissionOverwrites: [
Expand All @@ -79,10 +84,27 @@ module.exports = {
],
});

const ticketEmbed = new EmbedBuilder()
.setColor(0x0099ff)
.setTitle("Open Ticket")
.setDescription(
"**Close a Ticket using the button below this message!**",
)
.setFooter({
text: "Do not use for joking or playing around",
iconURL: interaction.guild.iconURL(),
});

const closeTicket = new ButtonBuilder()
.setLabel("Close Ticket")
.setCustomId("close-ticket")
.setStyle(ButtonStyle.Danger)
.setEmoji("✖️");

channel.send({
content: `<@${interaction.user.id}>`,
// embeds: [ticketEmbed],
// components: [new ActionRowBuilder().addComponents(openTicket)],
embeds: [ticketEmbed],
components: [new ActionRowBuilder().addComponents(closeTicket)],
});

await interaction.editReply(
Expand All @@ -93,6 +115,12 @@ module.exports = {
}
break;

case "close-ticket":
await interaction.editReply("Clone The Ticket in 10s");
setTimeout(() => {
interaction.channel.delete();
}, 1000 * 10);
break;
default:
break;
}
Expand Down

0 comments on commit 607ba0d

Please sign in to comment.