-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
75 changed files
with
3,630 additions
and
1,185 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const { ButtonInteraction, EmbedBuilder } = require("discord.js"); | ||
const setupData = require("../structures/schemas/guild.js"); | ||
const ticketData = require("../structures/schemas/ticket.js"); | ||
|
||
module.exports = { | ||
id: "claimTicket", | ||
/** | ||
* @param {ButtonInteraction} interaction | ||
*/ | ||
async execute(interaction) { | ||
const { guild, member, channel } = interaction; | ||
|
||
const Embed = new EmbedBuilder(); | ||
|
||
const ticketsData = await ticketData.findOne({ | ||
id: guild.id, | ||
ticketId: channel.id, | ||
}); | ||
|
||
const gTicketData = await setupData.findOne({ id: guild.id }); | ||
|
||
if ( | ||
!member.roles.cache.find( | ||
(r) => r.id === gTicketData.tickets.ticketHandlers | ||
) | ||
) { | ||
return interaction.reply({ | ||
embeds: [ | ||
Embed.setColor("Blurple") | ||
.setDescription("🔹 | Only the support team can use these buttons.") | ||
.setTimestamp(), | ||
], | ||
ephemeral: true, | ||
}); | ||
} | ||
|
||
if (ticketsData.claimed === true) { | ||
return interaction.reply({ | ||
embeds: [ | ||
Embed.setColor("Blurple") | ||
.setDescription("🔹 | This ticket has already been claimed.") | ||
.setTimestamp(), | ||
], | ||
ephemeral: true, | ||
}); | ||
} | ||
|
||
await ticketData.updateMany( | ||
{ | ||
ticketId: channel.id, | ||
}, | ||
{ | ||
claimed: true, | ||
claimer: member.id, | ||
} | ||
); | ||
|
||
return interaction.reply({ | ||
embeds: [Embed.setDescription(`🔹 | Ticket claimed.`).setTimestamp()], | ||
ephemeral: true, | ||
}); | ||
}, | ||
}; |
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,104 @@ | ||
const { ButtonInteraction, EmbedBuilder } = require("discord.js"); | ||
const { createTranscript } = require("discord-html-transcripts"); | ||
const setupData = require("../structures/schemas/guild.js"); | ||
const ticketData = require("../structures/schemas/ticket.js"); | ||
|
||
module.exports = { | ||
id: "closeTicket", | ||
/** | ||
* @param {ButtonInteraction} interaction | ||
*/ | ||
async execute(interaction) { | ||
const { guild, member, channel } = interaction; | ||
|
||
const Embed = new EmbedBuilder(); | ||
|
||
const ticketsData = await ticketData.findOne({ | ||
id: guild.id, | ||
ticketId: channel.id, | ||
}); | ||
|
||
const gTicketData = await setupData.findOne({ id: guild.id }); | ||
|
||
if ( | ||
!member.roles.cache.find( | ||
(r) => r.id === gTicketData.tickets.ticketHandlers | ||
) | ||
) { | ||
return interaction.reply({ | ||
embeds: [ | ||
Embed.setColor("Blurple") | ||
.setDescription("🔹 | Only the support team can use these buttons.") | ||
.setTimestamp(), | ||
], | ||
ephemeral: true, | ||
}); | ||
} | ||
|
||
if (ticketsData.closed === true) | ||
return interaction.reply({ | ||
embeds: [ | ||
Embed.setColor("Blurple") | ||
.setDescription("🔹 | This ticket is already closed.") | ||
.setTimestamp(), | ||
], | ||
}); | ||
|
||
if (!ticketsData.closer == member.id) | ||
return await interaction.reply({ | ||
embeds: [ | ||
Embed.setColor("Blurple") | ||
.setDescription( | ||
"🔹 | You are not the user that closed this ticket!" | ||
) | ||
.setTimestamp(), | ||
], | ||
ephemeral: true, | ||
}); | ||
|
||
await ticketData.findOneAndUpdate( | ||
{ | ||
ticketId: channel.id, | ||
}, | ||
{ | ||
closed: true, | ||
closer: member.id, | ||
} | ||
); | ||
|
||
const attachment = await createTranscript(channel, { | ||
limit: -1, | ||
returnType: "buffer", | ||
fileName: `Ticket - ${ticketsData.creatorId}.html`, | ||
}); | ||
|
||
const message = await guild.channels.cache | ||
.get(gTicketData.tickets.transcriptChannel) | ||
.send({ | ||
embeds: [ | ||
Embed.setColor("Blurple") | ||
.setTitle("Ticket Closed") | ||
.addFields( | ||
{ name: "Opened by", value: `<@!${ticketsData.creatorId}>` }, | ||
{ | ||
name: "Claimed by", | ||
value: `<@!${ticketsData.claimer}>` || "No one.", | ||
}, | ||
{ name: "Closed at", value: `${new Date().toLocaleString()}` } | ||
), | ||
], | ||
files: [attachment], | ||
}); | ||
|
||
interaction.reply({ | ||
embeds: [ | ||
Embed.setDescription( | ||
`🔹 | Transcript saved: [transcripthere](${message.url}).` | ||
).setTimestamp(), | ||
], | ||
}); | ||
setTimeout(() => { | ||
channel.delete(); | ||
}, 10 * 1000); | ||
}, | ||
}; |
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,115 @@ | ||
const { | ||
ButtonInteraction, | ||
ChannelType, | ||
PermissionsBitField, | ||
EmbedBuilder, | ||
ActionRowBuilder, | ||
ButtonBuilder, | ||
ButtonStyle, | ||
} = require("discord.js"); | ||
const { GuildText } = ChannelType; | ||
const { SendMessages, ViewChannel, ReadMessageHistory } = | ||
PermissionsBitField.Flags; | ||
const setupData = require("../structures/schemas/guild.js"); | ||
const ticketData = require("../structures/schemas/ticket.js"); | ||
|
||
module.exports = { | ||
id: "createTicket", | ||
/** | ||
* @param {ButtonInteraction} interaction | ||
*/ | ||
async execute(interaction) { | ||
const { guild, member } = interaction; | ||
|
||
const data = await setupData.findOne({ id: guild.id }); | ||
if (!data) return; | ||
|
||
const ticketsData = await ticketData.findOne({ | ||
creatorId: interaction.user.id, | ||
}); | ||
|
||
if (ticketsData.creatorId && !ticketsData.closed) { | ||
return interaction.reply({ | ||
embeds: [ | ||
new EmbedBuilder() | ||
.setColor("Blurple") | ||
.setDescription("🔹 | You already have a ticket open.") | ||
.setTimestamp(), | ||
], | ||
ephemeral: true, | ||
}); | ||
} | ||
|
||
await guild.channels | ||
.create({ | ||
name: `${interaction.user.username}-ticket`, | ||
type: GuildText, | ||
parent: data.tickets.category, | ||
permissionOverwrites: [ | ||
{ | ||
id: member.id, | ||
allow: [SendMessages, ViewChannel, ReadMessageHistory], | ||
}, | ||
{ | ||
id: interaction.guild.roles.everyone.id, | ||
deny: [SendMessages, ViewChannel, ReadMessageHistory], | ||
}, | ||
], | ||
}) | ||
.then(async (channel) => { | ||
await ticketData.create({ | ||
id: guild.id, | ||
ticketId: channel.id, | ||
claimed: false, | ||
closed: false, | ||
deleted: false, | ||
creatorId: interaction.user.id, | ||
claimer: null, | ||
}); | ||
|
||
channel.setRateLimitPerUser(2); | ||
|
||
const Embed = new EmbedBuilder() | ||
.setAuthor({ | ||
name: `${guild.name} | Your Ticket`, | ||
iconURL: guild.iconURL({ dynamic: true }), | ||
}) | ||
.setDescription( | ||
`Hiya, <@${interaction.user.id}>! Please wait patiently while a staff member is coming to assist you with your issue. In the meantime, describe your issue as detailed as possible.` | ||
) | ||
.setTimestamp(); | ||
|
||
const Buttons = new ActionRowBuilder(); | ||
Buttons.addComponents( | ||
new ButtonBuilder() | ||
.setCustomId("closeTicket") | ||
.setLabel("Close") | ||
.setStyle(ButtonStyle.Success) | ||
.setEmoji("⛔"), | ||
new ButtonBuilder() | ||
.setCustomId("claimTicket") | ||
.setLabel("Claim") | ||
.setStyle(ButtonStyle.Success) | ||
.setEmoji("🛄") | ||
); | ||
channel.send({ | ||
content: `<@&${data.tickets?.ticketHandlers}>`, | ||
embeds: [Embed], | ||
components: [Buttons], | ||
}); | ||
await channel | ||
.send({ | ||
content: `${member}, your ticket has been created: ${channel}`, | ||
}) | ||
.then((m) => { | ||
setTimeout(() => { | ||
m.delete().catch(() => {}); | ||
}, 5 * 1000); | ||
}); | ||
await interaction.reply({ | ||
content: `${member}, your ticket has been created: ${channel}`, | ||
ephemeral: true, | ||
}); | ||
}); | ||
}, | ||
}; |
Oops, something went wrong.