Skip to content

Commit

Permalink
v3.0 | EDGE
Browse files Browse the repository at this point in the history
  • Loading branch information
notscrappie authored Oct 11, 2022
2 parents 770b692 + 0c86ced commit 778a301
Show file tree
Hide file tree
Showing 75 changed files with 3,630 additions and 1,185 deletions.
37 changes: 22 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
{
"name": "evelyn",
"version": "2.1.0",
"version": "3.0.0",
"description": "A Discord Bot that puts you as its first priority with no paywalls to interrupt your supercharged experience.",
"main": "src/structures/index.js",
"main": "src/shard.js",
"scripts": {
"start": "node ./src/structures/index.js"
"start": "node ./src/shard.js",
"dev": "node ./src/structures/index.js"
},
"dependencies": {
"better-erela.js-apple": "^1.0.4",
"better-erela.js-spotify": "^1.3.9",
"canvacord": "^5.4.6",
"canvacord": "^5.4.8",
"chalk": "^4.1.2",
"dbd-dark-dashboard": "^1.6.591",
"discord-dashboard": "^2.3.41",
"discord.js": "^14.3.0",
"erela.js": "^2.3.3",
"erela.js-deezer": "^1.0.7",
"connect-mongodb-session": "^3.1.1",
"dbd-soft-ui": "^1.5.2-beta.1",
"discord-dashboard": "^2.3.45",
"discord-html-transcripts": "^3.1.0",
"discord-hybrid-sharding": "^1.7.4",
"discord-together": "^1.3.31",
"discord-xp": "^1.1.16",
"discord.js": "^14.6.0",
"express-session": "^1.17.3",
"genius-lyrics": "^4.4.0",
"glob": "^8.0.3",
"humanize-duration": "^3.27.2",
"humanize-duration": "^3.27.3",
"imdb-api": "^4.4.1",
"mongoose": "^6.5.2",
"kazagumo": "^2.2.3",
"kazagumo-spotify": "^1.1.5",
"mongoose": "^6.6.5",
"ms": "^2.1.3",
"nekobot-api": "^2.1.0",
"node-kitsu": "^1.1.1",
"pretty-ms": "^7.0.1",
"string-progressbar": "^1.0.4",
"superagent": "^8.0.0"
"session-file-store": "^1.5.0",
"shoukaku": "^3.2.0",
"superagent": "^8.0.2"
},
"repository": {
"type": "git",
Expand Down
63 changes: 63 additions & 0 deletions src/buttons/claimTicket.js
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,
});
},
};
104 changes: 104 additions & 0 deletions src/buttons/closeTicket.js
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);
},
};
115 changes: 115 additions & 0 deletions src/buttons/createTicket.js
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,
});
});
},
};
Loading

0 comments on commit 778a301

Please sign in to comment.