Compare commits
12
Commits
v8.4-Beta-2
..
v8.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3fa8b6d72 | ||
|
|
71e33dbf66 | ||
|
|
d468ab1575 | ||
|
|
74482af471 | ||
|
|
3cdfaef942 | ||
|
|
fcf441a190 | ||
|
|
58eb37124e | ||
|
|
afeeda3a8d | ||
|
|
357a85fa3d | ||
|
|
1bb343e49a | ||
|
|
dffa5d4161 | ||
|
|
6e14ce209d |
No files matched your search
@@ -0,0 +1,26 @@
|
|||||||
|
const Discord = require("discord.js");
|
||||||
|
const fs = require("fs");
|
||||||
|
const yaml = require("js-yaml");
|
||||||
|
const { Command } = require('../Structures/Addon.js'); // Adjust the path as needed
|
||||||
|
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||||
|
|
||||||
|
module.exports = new Command({
|
||||||
|
name: "addon",
|
||||||
|
description: "This is a sample addon!",
|
||||||
|
options: [],
|
||||||
|
permissions: ["Administrator"],
|
||||||
|
|
||||||
|
async run(interaction) {
|
||||||
|
let disableCommand = true;
|
||||||
|
|
||||||
|
const PingEmbed = new Discord.EmbedBuilder()
|
||||||
|
.setDescription(
|
||||||
|
`This is a sample addon.\n\nPong! \`${interaction.client.ws.ping} ms\``
|
||||||
|
)
|
||||||
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
|
interaction.reply({
|
||||||
|
embeds: [PingEmbed],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -1,296 +0,0 @@
|
|||||||
const {
|
|
||||||
EmbedBuilder,
|
|
||||||
ModalBuilder,
|
|
||||||
TextInputBuilder,
|
|
||||||
TextInputStyle,
|
|
||||||
ApplicationCommandType,
|
|
||||||
ActionRowBuilder,
|
|
||||||
ButtonBuilder,
|
|
||||||
ButtonStyle,
|
|
||||||
ApplicationCommandOptionType
|
|
||||||
} = require("discord.js");
|
|
||||||
const fs = require("fs");
|
|
||||||
const yaml = require("js-yaml");
|
|
||||||
const db = require("../../Structures/Database.js");
|
|
||||||
const Command = require("../../Structures/Command.js");
|
|
||||||
|
|
||||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
|
||||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
|
||||||
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
|
||||||
|
|
||||||
const clockedInUsers = new Set();
|
|
||||||
|
|
||||||
function updateClockedInStatus(embed, clockedIn) {
|
|
||||||
embed.data.fields = embed.data.fields.map(f =>
|
|
||||||
f.name === "Clocked In Status"
|
|
||||||
? { ...f, value: clockedIn ? "✅ Clocked In" : "❌ Clocked Out" }
|
|
||||||
: f
|
|
||||||
);
|
|
||||||
return embed;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = new Command({
|
|
||||||
name: cmdconfig.Profile.Command,
|
|
||||||
description: cmdconfig.Profile.Description,
|
|
||||||
type: ApplicationCommandType.ChatInput,
|
|
||||||
permissions: cmdconfig.Profile.Permission,
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: "user",
|
|
||||||
description: "The user to view the profile of",
|
|
||||||
type: ApplicationCommandOptionType.User,
|
|
||||||
required: false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
async run(interaction) {
|
|
||||||
await interaction.deferReply({ ephemeral: true });
|
|
||||||
|
|
||||||
const viewingUser = interaction.options.getUser("user") || interaction.user;
|
|
||||||
const viewingUserId = viewingUser.id;
|
|
||||||
const interactionUserId = interaction.user.id;
|
|
||||||
|
|
||||||
const member = await interaction.guild.members.fetch(viewingUserId);
|
|
||||||
const { getRole } = interaction.client;
|
|
||||||
const Staff = await getRole(supportbot.Roles.StaffMember.Staff, interaction.guild);
|
|
||||||
const Admin = await getRole(supportbot.Roles.StaffMember.Admin, interaction.guild);
|
|
||||||
|
|
||||||
if (!Staff || !Admin) {
|
|
||||||
return interaction.editReply({
|
|
||||||
content: "Some roles seem to be missing!\nPlease check for errors when starting the bot.",
|
|
||||||
ephemeral: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const isStaff = member.roles.cache.has(Staff.id) || member.roles.cache.has(Admin.id);
|
|
||||||
const isOwnProfile = interactionUserId === viewingUserId;
|
|
||||||
|
|
||||||
const profileData = db.getProfile(viewingUserId);
|
|
||||||
let { bio, timezone, clockedIn } = profileData;
|
|
||||||
clockedIn = Boolean(clockedIn);
|
|
||||||
|
|
||||||
let profileEmbed = new EmbedBuilder()
|
|
||||||
.setTitle(`${viewingUser.username}'s Profile`)
|
|
||||||
.setColor(supportbot.Embed.Colours.General)
|
|
||||||
.setThumbnail(viewingUser.displayAvatarURL())
|
|
||||||
.addFields(
|
|
||||||
{ name: "Bio", value: bio || "No bio set.", inline: false },
|
|
||||||
{ name: "Timezone", value: timezone || "No timezone set.", inline: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isStaff) {
|
|
||||||
profileEmbed.addFields({
|
|
||||||
name: "Clocked In Status",
|
|
||||||
value: clockedIn ? "✅ Clocked In" : "❌ Clocked Out",
|
|
||||||
inline: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const buttonRow = new ActionRowBuilder();
|
|
||||||
if (isOwnProfile) {
|
|
||||||
buttonRow.addComponents(
|
|
||||||
new ButtonBuilder()
|
|
||||||
.setCustomId("editProfile")
|
|
||||||
.setLabel("Edit Profile")
|
|
||||||
.setStyle(ButtonStyle.Secondary)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isStaff) {
|
|
||||||
buttonRow.addComponents(
|
|
||||||
new ButtonBuilder()
|
|
||||||
.setCustomId("clockInOut")
|
|
||||||
.setLabel(clockedIn ? "Clock Out" : "Clock In")
|
|
||||||
.setStyle(ButtonStyle.Secondary)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isStaff && supportbot.Ticket.ClaimTickets.Enabled) {
|
|
||||||
buttonRow.addComponents(
|
|
||||||
new ButtonBuilder()
|
|
||||||
.setCustomId("viewTicketStats")
|
|
||||||
.setLabel("View Ticket Stats")
|
|
||||||
.setStyle(ButtonStyle.Secondary)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
await interaction.editReply({
|
|
||||||
embeds: [profileEmbed],
|
|
||||||
components: buttonRow.components.length ? [buttonRow] : []
|
|
||||||
});
|
|
||||||
|
|
||||||
const filter = i =>
|
|
||||||
["editProfile", "clockInOut", "viewTicketStats", "showOpenTickets", "backToStats", "backToProfile"]
|
|
||||||
.includes(i.customId) &&
|
|
||||||
i.user.id === interactionUserId;
|
|
||||||
|
|
||||||
const collector = interaction.channel.createMessageComponentCollector({ filter, time: 60000 });
|
|
||||||
|
|
||||||
collector.on("collect", async i => {
|
|
||||||
if (i.customId === "editProfile") {
|
|
||||||
const modal = new ModalBuilder()
|
|
||||||
.setCustomId("editProfileModal")
|
|
||||||
.setTitle("Edit Profile")
|
|
||||||
.addComponents(
|
|
||||||
new ActionRowBuilder().addComponents(
|
|
||||||
new TextInputBuilder()
|
|
||||||
.setCustomId("bio")
|
|
||||||
.setLabel("Bio")
|
|
||||||
.setStyle(TextInputStyle.Paragraph)
|
|
||||||
.setPlaceholder("Enter your bio")
|
|
||||||
.setValue(String(bio || ""))
|
|
||||||
.setRequired(false)
|
|
||||||
),
|
|
||||||
new ActionRowBuilder().addComponents(
|
|
||||||
new TextInputBuilder()
|
|
||||||
.setCustomId("timezone")
|
|
||||||
.setLabel("Timezone")
|
|
||||||
.setStyle(TextInputStyle.Short)
|
|
||||||
.setPlaceholder("Enter your timezone")
|
|
||||||
.setValue(String(timezone || ""))
|
|
||||||
.setRequired(false)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return i.showModal(modal);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i.customId === "clockInOut") {
|
|
||||||
const newStatus = !clockedIn;
|
|
||||||
db.setClockedIn(viewingUserId, newStatus);
|
|
||||||
clockedIn = newStatus;
|
|
||||||
profileEmbed = updateClockedInStatus(profileEmbed, newStatus);
|
|
||||||
|
|
||||||
if (newStatus) clockedInUsers.add(viewingUserId);
|
|
||||||
else clockedInUsers.delete(viewingUserId);
|
|
||||||
|
|
||||||
const updatedRow = new ActionRowBuilder().addComponents(
|
|
||||||
new ButtonBuilder()
|
|
||||||
.setCustomId("editProfile")
|
|
||||||
.setLabel("Edit Profile")
|
|
||||||
.setStyle(ButtonStyle.Secondary)
|
|
||||||
);
|
|
||||||
if (isStaff) {
|
|
||||||
updatedRow.addComponents(
|
|
||||||
new ButtonBuilder()
|
|
||||||
.setCustomId("clockInOut")
|
|
||||||
.setLabel(newStatus ? "Clock Out" : "Clock In")
|
|
||||||
.setStyle(ButtonStyle.Secondary)
|
|
||||||
);
|
|
||||||
if (supportbot.Ticket.ClaimTickets.Enabled) {
|
|
||||||
updatedRow.addComponents(
|
|
||||||
new ButtonBuilder()
|
|
||||||
.setCustomId("viewTicketStats")
|
|
||||||
.setLabel("View Ticket Stats")
|
|
||||||
.setStyle(ButtonStyle.Secondary)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await i.update({ embeds: [profileEmbed], components: [updatedRow] });
|
|
||||||
|
|
||||||
const clockEmbed = new EmbedBuilder()
|
|
||||||
.setTitle(newStatus ? "Clocked In!" : "Clocked Out!")
|
|
||||||
.setDescription(newStatus ? "You have successfully clocked in." : "You have successfully clocked out.")
|
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
|
||||||
|
|
||||||
return interaction.followUp({ embeds: [clockEmbed], ephemeral: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i.customId === "viewTicketStats") {
|
|
||||||
const TicketData = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
|
||||||
const ticketsClaimed = TicketData.tickets.filter(t => t.claimedBy === viewingUserId);
|
|
||||||
const ticketsOpen = ticketsClaimed.filter(t => t.open);
|
|
||||||
const totalTickets = ticketsClaimed.length;
|
|
||||||
|
|
||||||
let totalResponseTime = 0;
|
|
||||||
let responseCount = 0;
|
|
||||||
ticketsClaimed.forEach(t => {
|
|
||||||
if (t.claimedAt && t.createdAt) {
|
|
||||||
totalResponseTime += new Date(t.claimedAt) - new Date(t.createdAt);
|
|
||||||
responseCount++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const avgMinutes = responseCount ? Math.round(totalResponseTime / responseCount / 60000) : 0;
|
|
||||||
|
|
||||||
const statsEmbed = new EmbedBuilder()
|
|
||||||
.setTitle(msgconfig.TicketStats.Title)
|
|
||||||
.setDescription(`> Ticket stats for <@${viewingUserId}>`)
|
|
||||||
.setColor(supportbot.Embed.Colours.General)
|
|
||||||
.addFields(
|
|
||||||
{ name: msgconfig.TicketStats.OpenTickets, value: `${ticketsOpen.length}`, inline: true },
|
|
||||||
{ name: msgconfig.TicketStats.TotalTickets, value: `${totalTickets}`, inline: true },
|
|
||||||
{ name: msgconfig.TicketStats.ResponseTime, value: `${avgMinutes} minutes`, inline: false }
|
|
||||||
);
|
|
||||||
|
|
||||||
const statsRow = new ActionRowBuilder().addComponents(
|
|
||||||
new ButtonBuilder().setCustomId("showOpenTickets").setLabel("Show Open Tickets").setStyle(ButtonStyle.Secondary),
|
|
||||||
new ButtonBuilder().setCustomId("backToProfile").setLabel("Back to Profile").setStyle(ButtonStyle.Secondary)
|
|
||||||
);
|
|
||||||
|
|
||||||
return i.update({ embeds: [statsEmbed], components: [statsRow] });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i.customId === "showOpenTickets") {
|
|
||||||
const TicketData = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
|
||||||
const ticketsOpen = TicketData.tickets.filter(t => t.claimedBy === viewingUserId && t.open);
|
|
||||||
|
|
||||||
const openEmbed = new EmbedBuilder()
|
|
||||||
.setTitle("Active Tickets")
|
|
||||||
.setDescription(ticketsOpen.map(t => `<#${t.id}>`).join("\n") || "No active tickets.")
|
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
|
||||||
|
|
||||||
const backRow = new ActionRowBuilder().addComponents(
|
|
||||||
new ButtonBuilder().setCustomId("backToStats").setLabel("Back to Stats").setStyle(ButtonStyle.Secondary)
|
|
||||||
);
|
|
||||||
|
|
||||||
return i.update({ embeds: [openEmbed], components: [backRow] });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i.customId === "backToStats") {
|
|
||||||
|
|
||||||
const TicketData = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
|
||||||
const ticketsClaimed = TicketData.tickets.filter(t => t.claimedBy === viewingUserId);
|
|
||||||
const ticketsOpen = ticketsClaimed.filter(t => t.open);
|
|
||||||
const totalTickets = ticketsClaimed.length;
|
|
||||||
|
|
||||||
let totalResponseTime = 0;
|
|
||||||
let responseCount = 0;
|
|
||||||
ticketsClaimed.forEach(t => {
|
|
||||||
if (t.claimedAt && t.createdAt) {
|
|
||||||
totalResponseTime += new Date(t.claimedAt) - new Date(t.createdAt);
|
|
||||||
responseCount++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const avgMinutes = responseCount ? Math.round(totalResponseTime / responseCount / 60000) : 0;
|
|
||||||
|
|
||||||
const statsEmbed = new EmbedBuilder()
|
|
||||||
.setTitle(msgconfig.TicketStats.Title)
|
|
||||||
.setDescription(`> Ticket stats for <@${viewingUserId}>`)
|
|
||||||
.setColor(supportbot.Embed.Colours.General)
|
|
||||||
.addFields(
|
|
||||||
{ name: msgconfig.TicketStats.OpenTickets, value: `${ticketsOpen.length}`, inline: true },
|
|
||||||
{ name: msgconfig.TicketStats.TotalTickets, value: `${totalTickets}`, inline: true },
|
|
||||||
{ name: msgconfig.TicketStats.ResponseTime, value: `${avgMinutes} minutes`, inline: false }
|
|
||||||
);
|
|
||||||
|
|
||||||
const statsRow = new ActionRowBuilder().addComponents(
|
|
||||||
new ButtonBuilder().setCustomId("showOpenTickets").setLabel("Show Open Tickets").setStyle(ButtonStyle.Secondary),
|
|
||||||
new ButtonBuilder().setCustomId("backToProfile").setLabel("Back to Profile").setStyle(ButtonStyle.Secondary)
|
|
||||||
);
|
|
||||||
|
|
||||||
return i.update({ embeds: [statsEmbed], components: [statsRow] });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i.customId === "backToProfile") {
|
|
||||||
return i.update({
|
|
||||||
embeds: [profileEmbed],
|
|
||||||
components: buttonRow.components.length ? [buttonRow] : []
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports.clockedInUsers = clockedInUsers;
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
const fs = require("fs");
|
|
||||||
const Discord = require("discord.js");
|
|
||||||
const yaml = require("js-yaml");
|
|
||||||
const path = require("path");
|
|
||||||
|
|
||||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
|
||||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
|
||||||
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
|
||||||
|
|
||||||
const Command = require("../../Structures/Command.js");
|
|
||||||
const DB = require("../../Structures/Database.js");
|
|
||||||
|
|
||||||
module.exports = new Command({
|
|
||||||
name: "suggest",
|
|
||||||
description: cmdconfig.Suggestion?.Description || "Submit a new suggestion",
|
|
||||||
type: Discord.ApplicationCommandType.ChatInput,
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: "text",
|
|
||||||
description: "Your suggestion text",
|
|
||||||
type: Discord.ApplicationCommandOptionType.String,
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
async run(interaction) {
|
|
||||||
const suggestion = interaction.options.getString("text");
|
|
||||||
const mode = supportbot.Suggestions.Mode || "Channel";
|
|
||||||
|
|
||||||
const embed = new Discord.EmbedBuilder()
|
|
||||||
.addFields(
|
|
||||||
{ name: "Suggestion", value: suggestion, inline: true },
|
|
||||||
{ name: "From", value: `<@${interaction.user.id}>` },
|
|
||||||
{ name: `${supportbot.Suggestions.UpvoteEmoji} ${supportbot.Suggestions.UpvoteTitle}`, value: "0", inline: true },
|
|
||||||
{ name: `${supportbot.Suggestions.DownvoteEmoji} ${supportbot.Suggestions.DownvoteTitle}`, value: "0", inline: true }
|
|
||||||
)
|
|
||||||
.setThumbnail(interaction.user.displayAvatarURL())
|
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
|
||||||
|
|
||||||
const row = new Discord.ActionRowBuilder().addComponents(
|
|
||||||
new Discord.ButtonBuilder()
|
|
||||||
.setCustomId("upvote")
|
|
||||||
.setEmoji(supportbot.Suggestions.UpvoteEmoji)
|
|
||||||
.setStyle(supportbot.Suggestions.Buttons.Upvote),
|
|
||||||
new Discord.ButtonBuilder()
|
|
||||||
.setCustomId("downvote")
|
|
||||||
.setEmoji(supportbot.Suggestions.DownvoteEmoji)
|
|
||||||
.setStyle(supportbot.Suggestions.Buttons.Downvote),
|
|
||||||
new Discord.ButtonBuilder()
|
|
||||||
.setCustomId("removevote")
|
|
||||||
.setLabel(supportbot.Suggestions.Buttons.RemoveVote_Title)
|
|
||||||
.setStyle(supportbot.Suggestions.Buttons.RemoveVote)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (mode === "Forum") {
|
|
||||||
const forum = await interaction.guild.channels
|
|
||||||
.fetch(supportbot.Suggestions.ForumChannel)
|
|
||||||
.catch(() => null);
|
|
||||||
|
|
||||||
if (!forum || forum.type !== Discord.ChannelType.GuildForum) {
|
|
||||||
return interaction.reply({
|
|
||||||
embeds: [
|
|
||||||
new Discord.EmbedBuilder()
|
|
||||||
.setTitle("⚠ Missing Forum Channel")
|
|
||||||
.setDescription(msgconfig.Error.MissingChannel)
|
|
||||||
.setColor(supportbot.Embed.Colours.Error)
|
|
||||||
],
|
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const appliedTags = supportbot.Suggestions.Tags?.Created
|
|
||||||
? [supportbot.Suggestions.Tags.Created]
|
|
||||||
: [];
|
|
||||||
|
|
||||||
const thread = await forum.threads.create({
|
|
||||||
name: suggestion.slice(0, 100),
|
|
||||||
message: {
|
|
||||||
content: "\u200B",
|
|
||||||
embeds: [embed],
|
|
||||||
components: [row]
|
|
||||||
},
|
|
||||||
appliedTags,
|
|
||||||
autoArchiveDuration: Discord.ThreadAutoArchiveDuration.OneDay,
|
|
||||||
reason: "New Suggestion"
|
|
||||||
});
|
|
||||||
|
|
||||||
embed.setFooter({
|
|
||||||
text: `${supportbot.Embed.Footer} | Suggestion ID: ${thread.id}`,
|
|
||||||
iconURL: interaction.user.displayAvatarURL()
|
|
||||||
});
|
|
||||||
const starter = await thread.fetchStarterMessage();
|
|
||||||
await starter.edit({ embeds: [embed], components: [row] });
|
|
||||||
|
|
||||||
DB.add(thread.id, interaction.user.id, suggestion);
|
|
||||||
|
|
||||||
return interaction.reply({
|
|
||||||
embeds: [
|
|
||||||
new Discord.EmbedBuilder()
|
|
||||||
.setTitle(msgconfig.Suggestions.Sent_Title)
|
|
||||||
.setDescription(`${msgconfig.Suggestions.Sent}`)
|
|
||||||
.addFields({ name: 'Posted in:', value: `<#${forum.id}>` })
|
|
||||||
.setColor(supportbot.Embed.Colours.Success)
|
|
||||||
],
|
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- Channel Mode ----------
|
|
||||||
const channel = await interaction.guild.channels
|
|
||||||
.fetch(supportbot.Suggestions.Channel)
|
|
||||||
.catch(() => null);
|
|
||||||
|
|
||||||
if (!channel) {
|
|
||||||
return interaction.reply({
|
|
||||||
embeds: [
|
|
||||||
new Discord.EmbedBuilder()
|
|
||||||
.setTitle("⚠ Missing Suggestion Channel")
|
|
||||||
.setDescription(msgconfig.Error.MissingChannel)
|
|
||||||
.setColor(supportbot.Embed.Colours.Error)
|
|
||||||
],
|
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const message = await channel.send({ embeds: [embed], components: [row] });
|
|
||||||
|
|
||||||
embed.setFooter({
|
|
||||||
text: `${supportbot.Embed.Footer} | Suggestion ID: ${message.id}`,
|
|
||||||
iconURL: interaction.user.displayAvatarURL()
|
|
||||||
});
|
|
||||||
await message.edit({ embeds: [embed], components: [row] });
|
|
||||||
|
|
||||||
DB.add(message.id, interaction.user.id, suggestion);
|
|
||||||
|
|
||||||
return interaction.reply({
|
|
||||||
embeds: [
|
|
||||||
new Discord.EmbedBuilder()
|
|
||||||
.setTitle(msgconfig.Suggestions.Sent_Title)
|
|
||||||
.setDescription(`${msgconfig.Suggestions.Sent}`)
|
|
||||||
.addFields({ name: 'Posted in:', value: `<#${channel.id}>` })
|
|
||||||
.setColor(supportbot.Embed.Colours.Success)
|
|
||||||
],
|
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -1,183 +0,0 @@
|
|||||||
const Discord = require("discord.js");
|
|
||||||
const fs = require("fs");
|
|
||||||
const yaml = require("js-yaml");
|
|
||||||
|
|
||||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
|
||||||
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
|
||||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
|
||||||
const SuggestionDB = require("../../Structures/Database.js");
|
|
||||||
const Command = require("../../Structures/Command.js");
|
|
||||||
|
|
||||||
module.exports = new Command({
|
|
||||||
name: cmdconfig.SuggestionAdmin.Command,
|
|
||||||
description: cmdconfig.SuggestionAdmin.Description,
|
|
||||||
type: Discord.ApplicationCommandType.ChatInput,
|
|
||||||
permissions: cmdconfig.SuggestionAdmin.Permission,
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: "status",
|
|
||||||
description: "New status",
|
|
||||||
type: Discord.ApplicationCommandOptionType.String,
|
|
||||||
required: true,
|
|
||||||
choices: [
|
|
||||||
{ name: "Solved", value: "Solved" },
|
|
||||||
{ name: "Denied", value: "Denied" },
|
|
||||||
{ name: "Considering", value: "Considering" }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "id",
|
|
||||||
description: "Message ID (required in Channel mode)",
|
|
||||||
type: Discord.ApplicationCommandOptionType.String,
|
|
||||||
required: false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
async run(interaction) {
|
|
||||||
const status = interaction.options.getString("status");
|
|
||||||
const idOption = interaction.options.getString("id");
|
|
||||||
const mode = supportbot.Suggestions.Mode || "Channel";
|
|
||||||
|
|
||||||
const { getRole } = interaction.client;
|
|
||||||
const staffRole = await getRole(supportbot.Roles.StaffMember.Staff, interaction.guild);
|
|
||||||
const adminRole = await getRole(supportbot.Roles.StaffMember.Admin, interaction.guild);
|
|
||||||
if (
|
|
||||||
!interaction.member.roles.cache.has(staffRole?.id) &&
|
|
||||||
!interaction.member.roles.cache.has(adminRole?.id)
|
|
||||||
) {
|
|
||||||
return interaction.reply({
|
|
||||||
embeds: [
|
|
||||||
new Discord.EmbedBuilder()
|
|
||||||
.setTitle("Invalid Permissions!")
|
|
||||||
.setDescription(
|
|
||||||
`${msgconfig.Error.IncorrectPerms}\nRequired: ${supportbot.Roles.StaffMember.Staff} or ${supportbot.Roles.StaffMember.Admin}`
|
|
||||||
)
|
|
||||||
.setColor(supportbot.Embed.Colours.Warn)
|
|
||||||
],
|
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode === "Forum") {
|
|
||||||
const thread = interaction.channel;
|
|
||||||
if (!thread.isThread() || thread.parentId !== supportbot.Suggestions.ForumChannel) {
|
|
||||||
return interaction.reply({
|
|
||||||
embeds: [
|
|
||||||
new Discord.EmbedBuilder()
|
|
||||||
.setTitle("Not a Suggestion Thread")
|
|
||||||
.setDescription(msgconfig.Error.MissingChannel)
|
|
||||||
.setColor(supportbot.Embed.Colours.Error)
|
|
||||||
],
|
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const tagMap = {
|
|
||||||
Solved: supportbot.Suggestions.Tags.Solved,
|
|
||||||
Denied: supportbot.Suggestions.Tags.Denied,
|
|
||||||
Considering: supportbot.Suggestions.Tags.Considering
|
|
||||||
};
|
|
||||||
const tagId = tagMap[status];
|
|
||||||
if (!tagId) {
|
|
||||||
return interaction.reply({
|
|
||||||
embeds: [
|
|
||||||
new Discord.EmbedBuilder()
|
|
||||||
.setTitle("Tag Missing")
|
|
||||||
.setDescription("No forum tag configured for this status.")
|
|
||||||
.setColor(supportbot.Embed.Colours.Error)
|
|
||||||
],
|
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
await thread.setAppliedTags([tagId]).catch(() => null);
|
|
||||||
SuggestionDB.setStatus(thread.id, status);
|
|
||||||
|
|
||||||
return interaction.reply({
|
|
||||||
embeds: [
|
|
||||||
new Discord.EmbedBuilder()
|
|
||||||
.setTitle("Suggestion Updated")
|
|
||||||
.setDescription(`Status set to **${status}**.`)
|
|
||||||
.setColor(supportbot.Embed.Colours.Success)
|
|
||||||
],
|
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!idOption) {
|
|
||||||
return interaction.reply({
|
|
||||||
embeds: [
|
|
||||||
new Discord.EmbedBuilder()
|
|
||||||
.setTitle("Message ID Required")
|
|
||||||
.setDescription("Provide the suggestion’s message ID when in Channel mode.")
|
|
||||||
.setColor(supportbot.Embed.Colours.Error)
|
|
||||||
],
|
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const channel = await interaction.guild.channels
|
|
||||||
.fetch(supportbot.Suggestions.Channel)
|
|
||||||
.catch(() => null);
|
|
||||||
if (!channel) {
|
|
||||||
return interaction.reply({
|
|
||||||
embeds: [
|
|
||||||
new Discord.EmbedBuilder()
|
|
||||||
.setTitle("Missing Suggestion Channel")
|
|
||||||
.setDescription(msgconfig.Error.MissingChannel)
|
|
||||||
.setColor(supportbot.Embed.Colours.Error)
|
|
||||||
],
|
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const targetMsg = await channel.messages.fetch(idOption).catch(() => null);
|
|
||||||
if (!targetMsg) {
|
|
||||||
return interaction.reply({
|
|
||||||
embeds: [
|
|
||||||
new Discord.EmbedBuilder()
|
|
||||||
.setTitle("Message Not Found")
|
|
||||||
.setDescription("Could not fetch a suggestion with that ID.")
|
|
||||||
.setColor(supportbot.Embed.Colours.Error)
|
|
||||||
],
|
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const oldEmbed = targetMsg.embeds[0];
|
|
||||||
if (!oldEmbed) {
|
|
||||||
return interaction.reply({
|
|
||||||
embeds: [
|
|
||||||
new Discord.EmbedBuilder()
|
|
||||||
.setTitle("No Embed Found")
|
|
||||||
.setDescription("The target message has no suggestion embed.")
|
|
||||||
.setColor(supportbot.Embed.Colours.Error)
|
|
||||||
],
|
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const colorMap = {
|
|
||||||
Solved: supportbot.Embed.Colours.Success,
|
|
||||||
Denied: supportbot.Embed.Colours.Error,
|
|
||||||
Considering: supportbot.Embed.Colours.Warn
|
|
||||||
};
|
|
||||||
|
|
||||||
const newEmbed = Discord.EmbedBuilder.from(oldEmbed)
|
|
||||||
.setColor(colorMap[status])
|
|
||||||
.addFields({ name: "Status", value: status, inline: true });
|
|
||||||
|
|
||||||
await targetMsg.edit({ embeds: [newEmbed], components: targetMsg.components });
|
|
||||||
SuggestionDB.setStatus(idOption, status);
|
|
||||||
|
|
||||||
return interaction.reply({
|
|
||||||
embeds: [
|
|
||||||
new Discord.EmbedBuilder()
|
|
||||||
.setTitle("Suggestion Updated")
|
|
||||||
.setDescription(`Suggestion **${idOption}** marked as **${status}**.`)
|
|
||||||
.setColor(supportbot.Embed.Colours.Success)
|
|
||||||
],
|
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
const fs = require("fs");
|
|
||||||
const {
|
|
||||||
EmbedBuilder,
|
|
||||||
ApplicationCommandOptionType,
|
|
||||||
ApplicationCommandType,
|
|
||||||
ChannelType,
|
|
||||||
MessageFlags,
|
|
||||||
} = require("discord.js");
|
|
||||||
const yaml = require("js-yaml");
|
|
||||||
|
|
||||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
|
||||||
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
|
||||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
|
||||||
|
|
||||||
const Command = require("../../Structures/Command.js");
|
|
||||||
const db = require("../../Structures/Database.js");
|
|
||||||
|
|
||||||
module.exports = new Command({
|
|
||||||
name: cmdconfig.ForceAddUser.Command,
|
|
||||||
description: cmdconfig.ForceAddUser.Description,
|
|
||||||
type: ApplicationCommandType.ChatInput,
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: "user",
|
|
||||||
description: "The user to forcefully add",
|
|
||||||
type: ApplicationCommandOptionType.User,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
permissions: cmdconfig.ForceAddUser.Permission,
|
|
||||||
|
|
||||||
async run(interaction) {
|
|
||||||
const userToAdd = interaction.options.getUser("user");
|
|
||||||
const ticketChannel = interaction.channel;
|
|
||||||
|
|
||||||
if (
|
|
||||||
(supportbot.Ticket.TicketType === "threads" && !ticketChannel.isThread()) ||
|
|
||||||
(supportbot.Ticket.TicketType === "channels" && ticketChannel.type !== ChannelType.GuildText)
|
|
||||||
) {
|
|
||||||
const onlyInTicket = new EmbedBuilder()
|
|
||||||
.setTitle(msgconfig.ForceAddUser.NotInTicket_Title)
|
|
||||||
.setDescription(msgconfig.ForceAddUser.NotInTicket_Description)
|
|
||||||
.setColor(supportbot.Embed.Colours.Error);
|
|
||||||
|
|
||||||
return interaction.reply({
|
|
||||||
embeds: [onlyInTicket],
|
|
||||||
flags: MessageFlags.Ephemeral,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const ticketRow = db.getTicket(ticketChannel.id);
|
|
||||||
if (!ticketRow) {
|
|
||||||
const notFound = new EmbedBuilder()
|
|
||||||
.setTitle(msgconfig.ForceAddUser.NotInTicket_Title)
|
|
||||||
.setDescription(msgconfig.ForceAddUser.NotInTicket_Description)
|
|
||||||
.setColor(supportbot.Embed.Colours.Error);
|
|
||||||
|
|
||||||
return interaction.reply({
|
|
||||||
embeds: [notFound],
|
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (supportbot.Ticket.TicketType === "threads") {
|
|
||||||
const botMember = await ticketChannel.members.fetch(interaction.client.user.id).catch(() => null);
|
|
||||||
if (!botMember) await ticketChannel.join();
|
|
||||||
await new Promise(res => setTimeout(res, 1000));
|
|
||||||
await ticketChannel.members.add(userToAdd.id);
|
|
||||||
} else if (supportbot.Ticket.TicketType === "channels") {
|
|
||||||
await ticketChannel.permissionOverwrites.create(userToAdd.id, {
|
|
||||||
ViewChannel: true,
|
|
||||||
SendMessages: true,
|
|
||||||
ReadMessageHistory: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
db.addUserToTicket(ticketChannel.id, userToAdd.id);
|
|
||||||
|
|
||||||
const addedEmbed = new EmbedBuilder()
|
|
||||||
.setTitle(msgconfig.ForceAddUser.Added_Title)
|
|
||||||
.setDescription(
|
|
||||||
msgconfig.ForceAddUser.Added_Description.replace("%username%", userToAdd.username)
|
|
||||||
)
|
|
||||||
.setColor(supportbot.Embed.Colours.Success);
|
|
||||||
|
|
||||||
await interaction.reply({
|
|
||||||
embeds: [addedEmbed],
|
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
|
||||||
});
|
|
||||||
|
|
||||||
const addedToTicketEmbed = new EmbedBuilder()
|
|
||||||
.setTitle(msgconfig.ForceAddUser.AddedToTicket_Title)
|
|
||||||
.setDescription(
|
|
||||||
msgconfig.ForceAddUser.AddedToTicket_Description.replace(
|
|
||||||
"%channel_link%",
|
|
||||||
`[${ticketChannel.name}](https://discord.com/channels/${ticketChannel.guild.id}/${ticketChannel.id})`
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
|
||||||
|
|
||||||
await userToAdd.send({
|
|
||||||
embeds: [addedToTicketEmbed],
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error("Error adding user to the ticket:", err);
|
|
||||||
|
|
||||||
const errorEmbed = new EmbedBuilder()
|
|
||||||
.setTitle(msgconfig.ForceAddUser.Error_Title)
|
|
||||||
.setDescription(msgconfig.ForceAddUser.Error_Adding)
|
|
||||||
.setColor(supportbot.Embed.Colours.Error);
|
|
||||||
|
|
||||||
await interaction.reply({
|
|
||||||
embeds: [errorEmbed],
|
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
// SupportBot | Emerald Services
|
|
||||||
// Remove user from a ticket
|
|
||||||
|
|
||||||
const {
|
|
||||||
EmbedBuilder,
|
|
||||||
ApplicationCommandOptionType,
|
|
||||||
ApplicationCommandType,
|
|
||||||
ChannelType,
|
|
||||||
MessageFlags,
|
|
||||||
} = require("discord.js");
|
|
||||||
const yaml = require("js-yaml");
|
|
||||||
const fs = require("fs");
|
|
||||||
|
|
||||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
|
||||||
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
|
||||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
|
||||||
|
|
||||||
const Command = require("../../Structures/Command.js");
|
|
||||||
const db = require("../../Structures/Database.js");
|
|
||||||
|
|
||||||
module.exports = new Command({
|
|
||||||
name: cmdconfig.RemoveUser.Command,
|
|
||||||
description: cmdconfig.RemoveUser.Description,
|
|
||||||
type: ApplicationCommandType.ChatInput,
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: "user",
|
|
||||||
description: "The user to remove",
|
|
||||||
type: ApplicationCommandOptionType.User,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
permissions: cmdconfig.RemoveUser.Permission,
|
|
||||||
|
|
||||||
async run(interaction) {
|
|
||||||
const { getRole } = interaction.client;
|
|
||||||
const SupportStaff = await getRole(supportbot.Roles.StaffMember.Staff, interaction.guild);
|
|
||||||
const Admin = await getRole(supportbot.Roles.StaffMember.Admin, interaction.guild);
|
|
||||||
|
|
||||||
if (!SupportStaff || !Admin) {
|
|
||||||
return interaction.reply("Missing staff/admin roles in config.");
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
!interaction.member.roles.cache.has(SupportStaff.id) &&
|
|
||||||
!interaction.member.roles.cache.has(Admin.id)
|
|
||||||
) {
|
|
||||||
const NoPerms = new EmbedBuilder()
|
|
||||||
.setTitle("Invalid Permissions!")
|
|
||||||
.setDescription(
|
|
||||||
`${msgconfig.Error.IncorrectPerms}\n\nRole Required: \`${supportbot.Roles.StaffMember.Staff}\` or \`${supportbot.Roles.StaffMember.Admin}\``
|
|
||||||
)
|
|
||||||
.setColor(supportbot.Embed.Colours.Warn);
|
|
||||||
return interaction.reply({ embeds: [NoPerms], flags: MessageFlags.Ephemeral });
|
|
||||||
}
|
|
||||||
|
|
||||||
const userToRemove = interaction.options.getUser("user");
|
|
||||||
const ticketChannel = interaction.channel;
|
|
||||||
|
|
||||||
if (
|
|
||||||
(supportbot.Ticket.TicketType === "threads" && !ticketChannel.isThread()) ||
|
|
||||||
(supportbot.Ticket.TicketType === "channels" && ticketChannel.type !== ChannelType.GuildText)
|
|
||||||
) {
|
|
||||||
const onlyInTicket = new EmbedBuilder()
|
|
||||||
.setTitle(msgconfig.RemoveUser.NotInTicket_Title)
|
|
||||||
.setDescription(msgconfig.RemoveUser.NotInTicket_Description)
|
|
||||||
.setColor(supportbot.Embed.Colours.Error);
|
|
||||||
return interaction.reply({ embeds: [onlyInTicket], flags: MessageFlags.Ephemeral });
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (supportbot.Ticket.TicketType === "threads") {
|
|
||||||
await ticketChannel.members.remove(userToRemove.id);
|
|
||||||
} else {
|
|
||||||
await ticketChannel.permissionOverwrites.delete(userToRemove.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
db.removeUserFromTicket(ticketChannel.id, userToRemove.id);
|
|
||||||
|
|
||||||
const removedEmbed = new EmbedBuilder()
|
|
||||||
.setTitle(msgconfig.RemoveUser.Removed_Title)
|
|
||||||
.setDescription(msgconfig.RemoveUser.Removed_Message)
|
|
||||||
.setColor(supportbot.Embed.Colours.Success);
|
|
||||||
|
|
||||||
await interaction.reply({ embeds: [removedEmbed], flags: MessageFlags.Ephemeral });
|
|
||||||
|
|
||||||
const removedFromTicketEmbed = new EmbedBuilder()
|
|
||||||
.setTitle(msgconfig.RemoveUser.RemovedFromTicket_Title)
|
|
||||||
.setDescription(
|
|
||||||
msgconfig.RemoveUser.RemovedFromTicket_Description.replace(
|
|
||||||
"%channel_link%",
|
|
||||||
`[${ticketChannel.name}](https://discord.com/channels/${ticketChannel.guild.id}/${ticketChannel.id})`
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
|
||||||
|
|
||||||
await userToRemove.send({ embeds: [removedFromTicketEmbed] }).catch(() => {});
|
|
||||||
} catch (err) {
|
|
||||||
console.error("Error removing user from the ticket:", err);
|
|
||||||
|
|
||||||
const errorEmbed = new EmbedBuilder()
|
|
||||||
.setTitle(msgconfig.RemoveUser.Error_Title)
|
|
||||||
.setDescription(msgconfig.RemoveUser.Error_Removing)
|
|
||||||
.setColor(supportbot.Embed.Colours.Error);
|
|
||||||
|
|
||||||
await interaction.reply({ embeds: [errorEmbed], flags: MessageFlags.Ephemeral });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
const fs = require("fs");
|
|
||||||
const {
|
|
||||||
EmbedBuilder,
|
|
||||||
ApplicationCommandType,
|
|
||||||
ActionRowBuilder,
|
|
||||||
ButtonBuilder,
|
|
||||||
MessageFlags,
|
|
||||||
} = require("discord.js");
|
|
||||||
const yaml = require("js-yaml");
|
|
||||||
|
|
||||||
const panelconfig = yaml.load(fs.readFileSync("./Configs/ticket-panel.yml", "utf8"));
|
|
||||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
|
||||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
|
||||||
|
|
||||||
const Command = require("../../Structures/Command.js");
|
|
||||||
const db = require("../../Structures/Database.js");
|
|
||||||
|
|
||||||
module.exports = new Command({
|
|
||||||
name: cmdconfig.TicketPanel.Command,
|
|
||||||
description: cmdconfig.TicketPanel.Description,
|
|
||||||
type: ApplicationCommandType.ChatInput,
|
|
||||||
options: [],
|
|
||||||
permissions: cmdconfig.TicketPanel.Permission,
|
|
||||||
|
|
||||||
async run(interaction) {
|
|
||||||
if (!panelconfig.Panel) {
|
|
||||||
console.log(
|
|
||||||
"\u001b[31m",
|
|
||||||
`[TICKET PANEL]`,
|
|
||||||
"\u001b[33m",
|
|
||||||
"Ticket Panel is not setup, You can set this in", `\u001b[31m`, '/Configs/ticket-panel.yml', `\n `,
|
|
||||||
);
|
|
||||||
return interaction.reply({
|
|
||||||
content: "Ticket Panel is not set up. Please configure it in `/Configs/ticket-panel.yml`.",
|
|
||||||
flags: MessageFlags.Ephemeral
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const { getChannel } = interaction.client;
|
|
||||||
|
|
||||||
const channel = await getChannel(
|
|
||||||
supportbot.Ticket.TicketHome,
|
|
||||||
interaction.guild
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!channel) {
|
|
||||||
console.log(`[TICKET PANEL] ${channelName} channel not found. Please check your config file.`);
|
|
||||||
return interaction.reply({
|
|
||||||
content: `${channelName} channel not found. Please check your config file.`,
|
|
||||||
flags: MessageFlags.Ephemeral
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const panelRow = db.getTicketPanel();
|
|
||||||
if (panelRow) {
|
|
||||||
try {
|
|
||||||
await channel.messages.fetch(panelRow.message_id);
|
|
||||||
return interaction.reply({
|
|
||||||
content: "Ticket panel message already exists.",
|
|
||||||
flags: MessageFlags.Ephemeral
|
|
||||||
});
|
|
||||||
} catch (err) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
let embed = new EmbedBuilder()
|
|
||||||
.setTitle(panelconfig.PanelTitle)
|
|
||||||
.setColor(panelconfig.PanelColour)
|
|
||||||
.setFooter({
|
|
||||||
text: supportbot.Embed.Footer,
|
|
||||||
iconURL: interaction.user.displayAvatarURL(),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (panelconfig.TicketPanel_Description) {
|
|
||||||
embed.setDescription(panelconfig.PanelMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (panelconfig.TicketPanel_Thumbnail) {
|
|
||||||
embed.setThumbnail(panelconfig.PanelThumbnail);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (panelconfig.TicketPanel_Image) {
|
|
||||||
embed.setImage(panelconfig.PanelImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
const createTicketButton = new ButtonBuilder()
|
|
||||||
.setCustomId("createticket")
|
|
||||||
.setLabel(panelconfig.Button.Text)
|
|
||||||
.setEmoji(panelconfig.Button.Emoji)
|
|
||||||
.setStyle(panelconfig.Button.Color);
|
|
||||||
|
|
||||||
let row = new ActionRowBuilder().addComponents(createTicketButton);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const message = await channel.send({
|
|
||||||
embeds: [embed],
|
|
||||||
components: [row],
|
|
||||||
});
|
|
||||||
|
|
||||||
db.saveTicketPanel(message.id, channel.id);
|
|
||||||
|
|
||||||
return interaction.reply({
|
|
||||||
content: "Ticket panel message has been sent!",
|
|
||||||
flags: MessageFlags.Ephemeral
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
console.log("Error sending message:", e);
|
|
||||||
return interaction.reply({
|
|
||||||
content: "An error occurred while sending the ticket panel message.",
|
|
||||||
flags: MessageFlags.Ephemeral
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -0,0 +1,217 @@
|
|||||||
|
const fs = require("fs");
|
||||||
|
const {
|
||||||
|
EmbedBuilder,
|
||||||
|
ApplicationCommandOptionType,
|
||||||
|
ApplicationCommandType,
|
||||||
|
ActionRowBuilder,
|
||||||
|
ButtonBuilder,
|
||||||
|
ButtonStyle,
|
||||||
|
ChannelType,
|
||||||
|
} = require("discord.js");
|
||||||
|
const yaml = require("js-yaml");
|
||||||
|
|
||||||
|
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||||
|
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
||||||
|
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
||||||
|
|
||||||
|
const Command = require("../Structures/Command.js");
|
||||||
|
|
||||||
|
module.exports = new Command({
|
||||||
|
name: cmdconfig.AddUser.Command,
|
||||||
|
description: cmdconfig.AddUser.Description,
|
||||||
|
type: ApplicationCommandType.ChatInput,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "user",
|
||||||
|
description: "The user to add",
|
||||||
|
type: ApplicationCommandOptionType.User,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
permissions: cmdconfig.AddUser.Permission,
|
||||||
|
|
||||||
|
async run(interaction) {
|
||||||
|
const userToAdd = interaction.options.getUser("user");
|
||||||
|
const ticketChannel = interaction.channel;
|
||||||
|
const ticketDataPath = "./Data/TicketData.json";
|
||||||
|
|
||||||
|
if (
|
||||||
|
(supportbot.Ticket.TicketType === "threads" && !ticketChannel.isThread()) ||
|
||||||
|
(supportbot.Ticket.TicketType === "channels" && ticketChannel.type !== ChannelType.GuildText)
|
||||||
|
) {
|
||||||
|
const onlyInTicket = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.NotInTicket_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.NotInTicket_Description)
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
return interaction.reply({
|
||||||
|
embeds: [onlyInTicket],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const ticketInviteEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.Invite_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.Invite_Description.replace("%username%", userToAdd.username))
|
||||||
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
|
await interaction.reply({
|
||||||
|
embeds: [ticketInviteEmbed],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const dmEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.DM_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.DM_Description.replace("%channelname%", ticketChannel.name))
|
||||||
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
|
const acceptButton = new ButtonBuilder()
|
||||||
|
.setCustomId("accept_invite")
|
||||||
|
.setLabel(msgconfig.AddUser.Accept_Label)
|
||||||
|
.setEmoji("✅")
|
||||||
|
.setStyle(ButtonStyle.Primary);
|
||||||
|
|
||||||
|
const rejectButton = new ButtonBuilder()
|
||||||
|
.setCustomId("reject_invite")
|
||||||
|
.setLabel(msgconfig.AddUser.Reject_Label)
|
||||||
|
.setEmoji("❌")
|
||||||
|
.setStyle(ButtonStyle.Secondary);
|
||||||
|
|
||||||
|
const row = new ActionRowBuilder().addComponents(acceptButton, rejectButton);
|
||||||
|
|
||||||
|
const dmMessage = await userToAdd.send({
|
||||||
|
embeds: [dmEmbed],
|
||||||
|
components: [row],
|
||||||
|
});
|
||||||
|
|
||||||
|
const filter = (i) => i.user.id === userToAdd.id;
|
||||||
|
const collector = dmMessage.createMessageComponentCollector({
|
||||||
|
filter,
|
||||||
|
time: 60000,
|
||||||
|
});
|
||||||
|
|
||||||
|
collector.on("collect", async (i) => {
|
||||||
|
if (i.customId === "accept_invite") {
|
||||||
|
try {
|
||||||
|
// Add user to thread or channel based on TicketType
|
||||||
|
if (supportbot.Ticket.TicketType === "threads") {
|
||||||
|
await ticketChannel.members.add(userToAdd.id); // For threads
|
||||||
|
} else if (supportbot.Ticket.TicketType === "channels") {
|
||||||
|
await ticketChannel.permissionOverwrites.create(userToAdd.id, {
|
||||||
|
ViewChannel: true,
|
||||||
|
SendMessages: true,
|
||||||
|
ReadMessageHistory: true,
|
||||||
|
}); // For channels
|
||||||
|
}
|
||||||
|
|
||||||
|
const ticketData = JSON.parse(fs.readFileSync(ticketDataPath, "utf8"));
|
||||||
|
const ticketIndex = ticketData.tickets.findIndex((t) => t.id === ticketChannel.id);
|
||||||
|
if (ticketIndex !== -1) {
|
||||||
|
ticketData.tickets[ticketIndex].subUsers.push(userToAdd.id);
|
||||||
|
fs.writeFileSync(ticketDataPath, JSON.stringify(ticketData, null, 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
const acceptedEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.Accepted_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.Accepted_Message)
|
||||||
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
|
|
||||||
|
await i.update({
|
||||||
|
embeds: [acceptedEmbed],
|
||||||
|
components: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Send the added user ticket message in the ticket channel
|
||||||
|
|
||||||
|
const addeduserTicket = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.Added_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.Added_Description.replace('%username%', userToAdd.username))
|
||||||
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
|
await ticketChannel.send({
|
||||||
|
embeds: [addeduserTicket],
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const addedToTicketEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.AddedToTicket_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.AddedToTicket_Description.replace(
|
||||||
|
"%channel_link%",
|
||||||
|
`[${ticketChannel.name}](https://discord.com/channels/${ticketChannel.guild.id}/${ticketChannel.id})`
|
||||||
|
))
|
||||||
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
|
const ticketLinkButton = new ButtonBuilder()
|
||||||
|
.setLabel(msgconfig.AddUser.ViewTicket_Label)
|
||||||
|
.setURL(`https://discord.com/channels/${ticketChannel.guild.id}/${ticketChannel.id}`)
|
||||||
|
.setStyle(ButtonStyle.Link);
|
||||||
|
|
||||||
|
await userToAdd.send({
|
||||||
|
embeds: [addedToTicketEmbed],
|
||||||
|
components: [new ActionRowBuilder().addComponents(ticketLinkButton)],
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Error adding user to the ticket:", err);
|
||||||
|
|
||||||
|
const errorEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.Error_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.Error_Adding)
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
await i.update({
|
||||||
|
embeds: [errorEmbed],
|
||||||
|
components: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const declinedEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.Declined_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.Declined_Message)
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
await i.update({
|
||||||
|
embeds: [declinedEmbed],
|
||||||
|
components: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
collector.on("end", (collected) => {
|
||||||
|
if (collected.size === 0) {
|
||||||
|
userToAdd.send({
|
||||||
|
embeds: [
|
||||||
|
new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.NoResponse_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.NoResponse_Message)
|
||||||
|
.setColor(supportbot.Embed.Colours.Warning),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
if (error.code === 50007) {
|
||||||
|
const errorEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.DM_Error_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.DM_Error_Description.replace("%username%", userToAdd.username))
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
await ticketChannel.send({
|
||||||
|
embeds: [errorEmbed],
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.error("Error sending DM:", error);
|
||||||
|
|
||||||
|
const unexpectedErrorEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.Unexpected_Error_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.Unexpected_Error_Description.replace("%error%", error.message))
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
await ticketChannel.send({
|
||||||
|
embeds: [unexpectedErrorEmbed],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -2,13 +2,11 @@ const fs = require("fs");
|
|||||||
const Discord = require("discord.js");
|
const Discord = require("discord.js");
|
||||||
const yaml = require("js-yaml");
|
const yaml = require("js-yaml");
|
||||||
|
|
||||||
const db = require("../../Structures/Database.js");
|
|
||||||
|
|
||||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
||||||
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
||||||
|
|
||||||
const Command = require("../../Structures/Command.js");
|
const Command = require("../Structures/Command.js");
|
||||||
|
|
||||||
module.exports = new Command({
|
module.exports = new Command({
|
||||||
name: cmdconfig.CloseTicket.Command,
|
name: cmdconfig.CloseTicket.Command,
|
||||||
@@ -59,9 +57,18 @@ module.exports = new Command({
|
|||||||
|
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
const ticket = db.getTicket(interaction.channel.id);
|
let tickets;
|
||||||
|
try {
|
||||||
|
tickets = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Error reading ticket data file:", err);
|
||||||
|
return interaction.followUp({ content: "There was an error loading ticket data." });
|
||||||
|
}
|
||||||
|
|
||||||
if (!ticket) {
|
let TicketData = tickets.tickets.findIndex((t) => t.id === interaction.channel.id);
|
||||||
|
let ticket = tickets.tickets[TicketData];
|
||||||
|
|
||||||
|
if (TicketData === -1) {
|
||||||
const Exists = new Discord.EmbedBuilder()
|
const Exists = new Discord.EmbedBuilder()
|
||||||
.setTitle("No Ticket Found!")
|
.setTitle("No Ticket Found!")
|
||||||
.setDescription(msgconfig.Error.NoValidTicket)
|
.setDescription(msgconfig.Error.NoValidTicket)
|
||||||
@@ -113,9 +120,9 @@ module.exports = new Command({
|
|||||||
await interaction.followUp({ embeds: [reviewEmbed] });
|
await interaction.followUp({ embeds: [reviewEmbed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
await handleCloseTicket(interaction, reason, ticket);
|
await handleCloseTicket(interaction, reason, ticket, TicketData);
|
||||||
} else {
|
} else {
|
||||||
await handleCloseTicket(interaction, reason, ticket);
|
await handleCloseTicket(interaction, reason, ticket, TicketData);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -143,7 +150,7 @@ async function collectReviewRating(interaction, ticketUserId) {
|
|||||||
content: `<@${ticketUserId}>`,
|
content: `<@${ticketUserId}>`,
|
||||||
embeds: [reviewPrompt],
|
embeds: [reviewPrompt],
|
||||||
components: [stars],
|
components: [stars],
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const starRating = await interaction.channel.awaitMessageComponent({
|
const starRating = await interaction.channel.awaitMessageComponent({
|
||||||
@@ -163,7 +170,7 @@ async function collectReviewComment(interaction, ticketUserId) {
|
|||||||
await interaction.followUp({
|
await interaction.followUp({
|
||||||
content: `<@${ticketUserId}>`,
|
content: `<@${ticketUserId}>`,
|
||||||
embeds: [commentPrompt],
|
embeds: [commentPrompt],
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const filter = (response) => response.author.id === ticketUserId;
|
const filter = (response) => response.author.id === ticketUserId;
|
||||||
@@ -172,10 +179,18 @@ async function collectReviewComment(interaction, ticketUserId) {
|
|||||||
const comment = commentCollection.first()?.content;
|
const comment = commentCollection.first()?.content;
|
||||||
return comment && comment.toLowerCase() !== "no" ? comment : "No Comment Provided";
|
return comment && comment.toLowerCase() !== "no" ? comment : "No Comment Provided";
|
||||||
}
|
}
|
||||||
async function handleCloseTicket(interaction, reason, ticket) {
|
async function handleCloseTicket(interaction, reason, ticket, TicketData) {
|
||||||
const { getChannel } = interaction.client;
|
const { getChannel } = interaction.client;
|
||||||
|
|
||||||
let tUser = interaction.client.users.cache.get(ticket.user_id);
|
let tickets;
|
||||||
|
try {
|
||||||
|
tickets = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Error reading ticket data:", err);
|
||||||
|
return interaction.followUp("Failed to load ticket data.");
|
||||||
|
}
|
||||||
|
|
||||||
|
let tUser = interaction.client.users.cache.get(ticket.user);
|
||||||
let transcriptChannel = await getChannel(supportbot.Ticket.Log.TicketDataLog, interaction.guild);
|
let transcriptChannel = await getChannel(supportbot.Ticket.Log.TicketDataLog, interaction.guild);
|
||||||
|
|
||||||
if (!transcriptChannel) {
|
if (!transcriptChannel) {
|
||||||
@@ -184,6 +199,7 @@ async function handleCloseTicket(interaction, reason, ticket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Fetch all messages from the channel
|
||||||
let allMessages = [];
|
let allMessages = [];
|
||||||
let lastId = null;
|
let lastId = null;
|
||||||
|
|
||||||
@@ -202,8 +218,10 @@ async function handleCloseTicket(interaction, reason, ticket) {
|
|||||||
if (messages.size < 100) break;
|
if (messages.size < 100) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort messages by timestamp
|
||||||
allMessages.sort((a, b) => a.createdTimestamp - b.createdTimestamp);
|
allMessages.sort((a, b) => a.createdTimestamp - b.createdTimestamp);
|
||||||
|
|
||||||
|
// Create transcript data
|
||||||
const transcriptData = allMessages.map(msg => ({
|
const transcriptData = allMessages.map(msg => ({
|
||||||
content: msg.content || "No content",
|
content: msg.content || "No content",
|
||||||
username: msg.author.username,
|
username: msg.author.username,
|
||||||
@@ -221,7 +239,10 @@ async function handleCloseTicket(interaction, reason, ticket) {
|
|||||||
}))
|
}))
|
||||||
}));
|
}));
|
||||||
|
|
||||||
db.updateTicketStatus(interaction.channel.id, "closed");
|
// Update ticket status
|
||||||
|
tickets.tickets[TicketData].open = false;
|
||||||
|
tickets.tickets[TicketData].messages = transcriptData;
|
||||||
|
fs.writeFileSync("./Data/TicketData.json", JSON.stringify(tickets, null, 4));
|
||||||
|
|
||||||
const transcriptEmbed = new Discord.EmbedBuilder()
|
const transcriptEmbed = new Discord.EmbedBuilder()
|
||||||
.setTitle(msgconfig.TicketLog.Title)
|
.setTitle(msgconfig.TicketLog.Title)
|
||||||
@@ -229,7 +250,7 @@ async function handleCloseTicket(interaction, reason, ticket) {
|
|||||||
.setFooter({ text: supportbot.Embed.Footer, iconURL: interaction.user.displayAvatarURL() })
|
.setFooter({ text: supportbot.Embed.Footer, iconURL: interaction.user.displayAvatarURL() })
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`> **Ticket:** ${interaction.channel.name} (\`${interaction.channel.id}\`)\n` +
|
`> **Ticket:** ${interaction.channel.name} (\`${interaction.channel.id}\`)\n` +
|
||||||
`> **User:** ${tUser?.tag || "Unknown User"} (\`${tUser?.id || ticket.user_id}\`)` +
|
`> **User:** ${tUser?.tag || "Unknown User"} (\`${tUser?.id || ticket.user}\`)\n` +
|
||||||
`> **Closed by:** <@${interaction.user.id}>\n` +
|
`> **Closed by:** <@${interaction.user.id}>\n` +
|
||||||
`> **Message Count:** ${transcriptData.length}`
|
`> **Message Count:** ${transcriptData.length}`
|
||||||
)
|
)
|
||||||
@@ -244,12 +265,6 @@ async function handleCloseTicket(interaction, reason, ticket) {
|
|||||||
reason
|
reason
|
||||||
);
|
);
|
||||||
|
|
||||||
const transcriptDir = "./Data/Transcripts";
|
|
||||||
|
|
||||||
if (!fs.existsSync(transcriptDir)) {
|
|
||||||
fs.mkdirSync(transcriptDir, { recursive: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
const fileName = `${interaction.channel.id}-transcript.html`;
|
const fileName = `${interaction.channel.id}-transcript.html`;
|
||||||
fs.writeFileSync(`./Data/Transcripts/${fileName}`, html);
|
fs.writeFileSync(`./Data/Transcripts/${fileName}`, html);
|
||||||
|
|
||||||
@@ -273,14 +288,19 @@ async function handleCloseTicket(interaction, reason, ticket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseMarkdown(content) {
|
function parseMarkdown(content) {
|
||||||
|
// Convert **bold** text to <strong> tags
|
||||||
content = content.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
|
content = content.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
|
||||||
|
|
||||||
|
// Convert _italic_ text to <em> tags
|
||||||
content = content.replace(/_(.*?)_/g, '<em>$1</em>');
|
content = content.replace(/_(.*?)_/g, '<em>$1</em>');
|
||||||
|
|
||||||
|
// Convert inline `code` to <code> tags
|
||||||
content = content.replace(/`(.*?)`/g, '<code>$1</code>');
|
content = content.replace(/`(.*?)`/g, '<code>$1</code>');
|
||||||
|
|
||||||
|
// Convert [text](link) to <a> tags
|
||||||
content = content.replace(/\[(.*?)\]\((.*?)\)/g, '<a href="$2" target="_blank">$1</a>');
|
content = content.replace(/\[(.*?)\]\((.*?)\)/g, '<a href="$2" target="_blank">$1</a>');
|
||||||
|
|
||||||
|
// Convert multiline code blocks ```code``` to <pre><code> tags
|
||||||
content = content.replace(/```(.*?)```/gs, '<pre><code>$1</code></pre>');
|
content = content.replace(/```(.*?)```/gs, '<pre><code>$1</code></pre>');
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
@@ -288,154 +308,119 @@ function parseMarkdown(content) {
|
|||||||
|
|
||||||
function createTranscriptHTML(ticket, reason) {
|
function createTranscriptHTML(ticket, reason) {
|
||||||
return `
|
return `
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
background: url('file-EWLgzFEYsq16ANVg6ENJrP.png') no-repeat center center fixed;
|
background-color: #1a1a1a;
|
||||||
background-size: cover;
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
color: white;
|
||||||
color: #ffffff;
|
margin: 0;
|
||||||
margin: 0;
|
padding: 20px;
|
||||||
padding: 20px;
|
}
|
||||||
}
|
.container {
|
||||||
|
max-width: 1000px;
|
||||||
|
margin: 0 auto;
|
||||||
|
background-color: rgba(0, 0, 0, 0.3);
|
||||||
|
border-radius: 15px;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
.message {
|
||||||
|
background-color: rgba(255, 255, 255, 0.1);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 15px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
.message-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.avatar {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-right: 15px;
|
||||||
|
}
|
||||||
|
.username {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #4CAF50;
|
||||||
|
}
|
||||||
|
.timestamp {
|
||||||
|
margin-left: auto;
|
||||||
|
color: #888;
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
.content {
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
.embed {
|
||||||
|
border-left: 4px solid #4CAF50;
|
||||||
|
padding-left: 10px;
|
||||||
|
margin: 10px 0;
|
||||||
|
background-color: rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
.attachment {
|
||||||
|
display: inline-block;
|
||||||
|
background-color: rgba(76, 175, 80, 0.1);
|
||||||
|
border: 1px solid #4CAF50;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 5px 10px;
|
||||||
|
margin: 5px 0;
|
||||||
|
color: #4CAF50;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="mb-6">
|
||||||
|
<h1 class="text-3xl font-bold mb-4">Ticket Transcript</h1>
|
||||||
|
<p><strong>Channel:</strong> ${ticket.name}</p>
|
||||||
|
<p><strong>Ticket ID:</strong> ${ticket.id}</p>
|
||||||
|
<p><strong>Message Count:</strong> ${ticket.messages.length}</p>
|
||||||
|
<p><strong>Close Reason:</strong> ${reason}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
.container {
|
<div class="messages">
|
||||||
max-width: 1000px;
|
${ticket.messages.map(msg => `
|
||||||
margin: 0 auto;
|
<div class="message">
|
||||||
padding: 20px;
|
<div class="message-header">
|
||||||
backdrop-filter: blur(10px);
|
<img src="${msg.avatar}" alt="Avatar" class="avatar">
|
||||||
background: rgba(0,0,0,0.4);
|
<span class="username">${msg.username}</span>
|
||||||
border-radius: 20px;
|
<span class="timestamp">${new Date(msg.timestamp).toLocaleString()}</span>
|
||||||
box-shadow: 0 8px 32px rgba(0,0,0,0.5);
|
</div>
|
||||||
}
|
<div class="content">
|
||||||
|
${parseMarkdown(msg.content)}
|
||||||
|
|
||||||
h1 {
|
${msg.embeds.map(embed => `
|
||||||
font-size: 2.5rem;
|
<div class="embed">
|
||||||
font-weight: bold;
|
${embed.title ? `<div class="font-bold">${embed.title}</div>` : ''}
|
||||||
text-align: center;
|
${embed.description ? `<div>${embed.description}</div>` : ''}
|
||||||
margin-bottom: 20px;
|
${embed.fields.map(field => `
|
||||||
}
|
<div class="mt-2">
|
||||||
|
<strong>${field.name}:</strong>
|
||||||
|
<div>${field.value}</div>
|
||||||
|
</div>
|
||||||
|
`).join('')}
|
||||||
|
</div>
|
||||||
|
`).join('')}
|
||||||
|
|
||||||
.ticket-info p {
|
${msg.attachments.map(att => `
|
||||||
margin: 5px 0;
|
<a href="${att.url}" class="attachment" target="_blank">
|
||||||
}
|
📎 ${att.name}
|
||||||
|
</a>
|
||||||
.message {
|
`).join('')}
|
||||||
backdrop-filter: blur(15px);
|
</div>
|
||||||
background: rgba(255, 255, 255, 0.05);
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
||||||
border-radius: 15px;
|
|
||||||
padding: 15px;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
transition: transform 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message:hover {
|
|
||||||
transform: scale(1.02);
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar {
|
|
||||||
width: 50px;
|
|
||||||
height: 50px;
|
|
||||||
border-radius: 50%;
|
|
||||||
margin-right: 15px;
|
|
||||||
border: 2px solid rgba(255,255,255,0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.username {
|
|
||||||
font-weight: bold;
|
|
||||||
color: #00ffe4;
|
|
||||||
font-size: 1.1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.timestamp {
|
|
||||||
margin-left: auto;
|
|
||||||
color: #aaa;
|
|
||||||
font-size: 0.85rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
word-break: break-word;
|
|
||||||
font-size: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.embed {
|
|
||||||
border-left: 4px solid #00ffe4;
|
|
||||||
padding-left: 10px;
|
|
||||||
margin: 10px 0;
|
|
||||||
background: rgba(255, 255, 255, 0.05);
|
|
||||||
border-radius: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.attachment {
|
|
||||||
display: inline-block;
|
|
||||||
background-color: rgba(0, 255, 228, 0.1);
|
|
||||||
border: 1px solid #00ffe4;
|
|
||||||
border-radius: 5px;
|
|
||||||
padding: 5px 10px;
|
|
||||||
margin: 5px 0;
|
|
||||||
color: #00ffe4;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container">
|
|
||||||
<h1>Ticket Transcript</h1>
|
|
||||||
<div class="ticket-info mb-6">
|
|
||||||
<p><strong>Channel:</strong> ${ticket.name}</p>
|
|
||||||
<p><strong>Ticket ID:</strong> ${ticket.id}</p>
|
|
||||||
<p><strong>Message Count:</strong> ${ticket.messages.length}</p>
|
|
||||||
<p><strong>Close Reason:</strong> ${reason}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="messages">
|
|
||||||
${ticket.messages.map(msg => `
|
|
||||||
<div class="message">
|
|
||||||
<div class="message-header">
|
|
||||||
<img src="${msg.avatar}" alt="Avatar" class="avatar">
|
|
||||||
<span class="username">${msg.username}</span>
|
|
||||||
<span class="timestamp">${new Date(msg.timestamp).toLocaleString()}</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
`).join('')}
|
||||||
${parseMarkdown(msg.content)}
|
</div>
|
||||||
|
|
||||||
${msg.embeds.map(embed => `
|
|
||||||
<div class="embed">
|
|
||||||
${embed.title ? `<div class="font-bold">${embed.title}</div>` : ''}
|
|
||||||
${embed.description ? `<div>${embed.description}</div>` : ''}
|
|
||||||
${embed.fields.map(field => `
|
|
||||||
<div class="mt-2">
|
|
||||||
<strong>${field.name}:</strong>
|
|
||||||
<div>${field.value}</div>
|
|
||||||
</div>
|
|
||||||
`).join('')}
|
|
||||||
</div>
|
|
||||||
`).join('')}
|
|
||||||
|
|
||||||
${msg.attachments.map(att => `
|
|
||||||
<a href="${att.url}" class="attachment" target="_blank">
|
|
||||||
📎 ${att.name}
|
|
||||||
</a>
|
|
||||||
`).join('')}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`).join('')}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</body>
|
||||||
</body>
|
</html>
|
||||||
</html>
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -9,10 +9,9 @@ const {
|
|||||||
TextInputBuilder,
|
TextInputBuilder,
|
||||||
TextInputStyle,
|
TextInputStyle,
|
||||||
ButtonStyle,
|
ButtonStyle,
|
||||||
ComponentType,
|
ComponentType
|
||||||
MessageFlags,
|
|
||||||
} = require('discord.js');
|
} = require('discord.js');
|
||||||
const Command = require('../../Structures/Command.js');
|
const Command = require('../Structures/Command.js');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const yaml = require('js-yaml');
|
const yaml = require('js-yaml');
|
||||||
|
|
||||||
@@ -20,6 +19,7 @@ const supportbot = yaml.load(fs.readFileSync('./Configs/supportbot.yml', 'utf8')
|
|||||||
const cmdconfig = yaml.load(fs.readFileSync('./Configs/commands.yml', 'utf8'));
|
const cmdconfig = yaml.load(fs.readFileSync('./Configs/commands.yml', 'utf8'));
|
||||||
const msgconfig = yaml.load(fs.readFileSync('./Configs/messages.yml', 'utf8'));
|
const msgconfig = yaml.load(fs.readFileSync('./Configs/messages.yml', 'utf8'));
|
||||||
|
|
||||||
|
// Helper function to validate and convert hex color
|
||||||
function parseColor(color) {
|
function parseColor(color) {
|
||||||
if (!color) return 0x5865F2;
|
if (!color) return 0x5865F2;
|
||||||
if (typeof color === 'number') return color;
|
if (typeof color === 'number') return color;
|
||||||
@@ -46,6 +46,7 @@ module.exports = new Command({
|
|||||||
permissions: cmdconfig.Embed.Permission,
|
permissions: cmdconfig.Embed.Permission,
|
||||||
|
|
||||||
async run(interaction) {
|
async run(interaction) {
|
||||||
|
// Permission check
|
||||||
const { getRole } = interaction.client;
|
const { getRole } = interaction.client;
|
||||||
let SupportStaff = await getRole(supportbot.Roles.StaffMember.Staff, interaction.guild);
|
let SupportStaff = await getRole(supportbot.Roles.StaffMember.Staff, interaction.guild);
|
||||||
let Admin = await getRole(supportbot.Roles.StaffMember.Admin, interaction.guild);
|
let Admin = await getRole(supportbot.Roles.StaffMember.Admin, interaction.guild);
|
||||||
@@ -60,11 +61,12 @@ module.exports = new Command({
|
|||||||
.setTitle('Invalid Permissions!')
|
.setTitle('Invalid Permissions!')
|
||||||
.setDescription(`${msgconfig.Error.IncorrectPerms}\n\nRole Required: \`${supportbot.Roles.StaffMember.Staff}\` or \`${supportbot.Roles.StaffMember.Admin}\``)
|
.setDescription(`${msgconfig.Error.IncorrectPerms}\n\nRole Required: \`${supportbot.Roles.StaffMember.Staff}\` or \`${supportbot.Roles.StaffMember.Admin}\``)
|
||||||
.setColor(0xFF0000);
|
.setColor(0xFF0000);
|
||||||
return interaction.reply({ embeds: [NoPerms], flags: MessageFlags.Ephemeral });
|
return interaction.reply({ embeds: [NoPerms], ephemeral: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
const channel = interaction.options.getChannel('channel');
|
const channel = interaction.options.getChannel('channel');
|
||||||
|
|
||||||
|
// Initial message state
|
||||||
const messageData = {
|
const messageData = {
|
||||||
type: 'embed',
|
type: 'embed',
|
||||||
title: 'New Embed',
|
title: 'New Embed',
|
||||||
@@ -77,6 +79,7 @@ module.exports = new Command({
|
|||||||
timestamp: false
|
timestamp: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Create initial embed
|
||||||
function createEmbed() {
|
function createEmbed() {
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle(messageData.title)
|
.setTitle(messageData.title)
|
||||||
@@ -102,6 +105,7 @@ module.exports = new Command({
|
|||||||
return embed;
|
return embed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create type selector
|
||||||
const typeRow = new ActionRowBuilder()
|
const typeRow = new ActionRowBuilder()
|
||||||
.addComponents(
|
.addComponents(
|
||||||
new StringSelectMenuBuilder()
|
new StringSelectMenuBuilder()
|
||||||
@@ -121,10 +125,12 @@ module.exports = new Command({
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Create button rows function
|
||||||
function createButtons(messageType) {
|
function createButtons(messageType) {
|
||||||
const buttons = [];
|
const buttons = [];
|
||||||
|
|
||||||
if (messageType === 'embed') {
|
if (messageType === 'embed') {
|
||||||
|
// Only show these buttons for embed mode
|
||||||
const row1 = new ActionRowBuilder()
|
const row1 = new ActionRowBuilder()
|
||||||
.addComponents(
|
.addComponents(
|
||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
@@ -167,6 +173,7 @@ module.exports = new Command({
|
|||||||
|
|
||||||
buttons.push(row1, row2);
|
buttons.push(row1, row2);
|
||||||
} else {
|
} else {
|
||||||
|
// Text mode only shows edit text button
|
||||||
const textRow = new ActionRowBuilder()
|
const textRow = new ActionRowBuilder()
|
||||||
.addComponents(
|
.addComponents(
|
||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
@@ -191,6 +198,7 @@ module.exports = new Command({
|
|||||||
return buttons;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to update the message preview
|
||||||
async function updatePreview(i) {
|
async function updatePreview(i) {
|
||||||
if (messageData.type === 'embed') {
|
if (messageData.type === 'embed') {
|
||||||
await i.update({
|
await i.update({
|
||||||
@@ -199,6 +207,7 @@ module.exports = new Command({
|
|||||||
components: [typeRow, ...createButtons('embed')]
|
components: [typeRow, ...createButtons('embed')]
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
// For text mode, just show the text directly
|
||||||
await i.update({
|
await i.update({
|
||||||
content: messageData.description,
|
content: messageData.description,
|
||||||
embeds: [],
|
embeds: [],
|
||||||
@@ -207,13 +216,15 @@ module.exports = new Command({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send initial message
|
||||||
const message = await interaction.reply({
|
const message = await interaction.reply({
|
||||||
content: messageData.type === 'text' ? messageData.description : 'Customize your message:',
|
content: messageData.type === 'text' ? messageData.description : 'Customize your message:',
|
||||||
components: [typeRow, ...createButtons(messageData.type)],
|
components: [typeRow, ...createButtons(messageData.type)],
|
||||||
embeds: messageData.type === 'embed' ? [createEmbed()] : [],
|
embeds: messageData.type === 'embed' ? [createEmbed()] : [],
|
||||||
flags: MessageFlags.Ephemeral
|
ephemeral: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Create collector for interactions
|
||||||
const collector = message.createMessageComponentCollector({
|
const collector = message.createMessageComponentCollector({
|
||||||
time: 900000
|
time: 900000
|
||||||
});
|
});
|
||||||
@@ -222,7 +233,7 @@ module.exports = new Command({
|
|||||||
if (i.user.id !== interaction.user.id) {
|
if (i.user.id !== interaction.user.id) {
|
||||||
return i.reply({
|
return i.reply({
|
||||||
content: 'You cannot edit this message.',
|
content: 'You cannot edit this message.',
|
||||||
flags: MessageFlags.Ephemeral
|
ephemeral: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,7 +422,7 @@ module.exports = new Command({
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
await i.reply({
|
await i.reply({
|
||||||
content: 'Failed to send message. Please check channel permissions.',
|
content: 'Failed to send message. Please check channel permissions.',
|
||||||
flags: MessageFlags.Ephemeral
|
ephemeral: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -4,7 +4,6 @@ const {
|
|||||||
ApplicationCommandOptionType,
|
ApplicationCommandOptionType,
|
||||||
ApplicationCommandType,
|
ApplicationCommandType,
|
||||||
ChannelType,
|
ChannelType,
|
||||||
MessageFlags,
|
|
||||||
} = require("discord.js");
|
} = require("discord.js");
|
||||||
const yaml = require("js-yaml");
|
const yaml = require("js-yaml");
|
||||||
|
|
||||||
@@ -12,8 +11,7 @@ const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8")
|
|||||||
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
||||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
||||||
|
|
||||||
const Command = require("../../Structures/Command.js");
|
const Command = require("../Structures/Command.js");
|
||||||
const db = require("../../Structures/Database.js");
|
|
||||||
|
|
||||||
module.exports = new Command({
|
module.exports = new Command({
|
||||||
name: cmdconfig.ForceAddUser.Command,
|
name: cmdconfig.ForceAddUser.Command,
|
||||||
@@ -32,6 +30,7 @@ module.exports = new Command({
|
|||||||
async run(interaction) {
|
async run(interaction) {
|
||||||
const userToAdd = interaction.options.getUser("user");
|
const userToAdd = interaction.options.getUser("user");
|
||||||
const ticketChannel = interaction.channel;
|
const ticketChannel = interaction.channel;
|
||||||
|
const ticketDataPath = "./Data/TicketData.json";
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(supportbot.Ticket.TicketType === "threads" && !ticketChannel.isThread()) ||
|
(supportbot.Ticket.TicketType === "threads" && !ticketChannel.isThread()) ||
|
||||||
@@ -44,29 +43,40 @@ module.exports = new Command({
|
|||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
embeds: [onlyInTicket],
|
embeds: [onlyInTicket],
|
||||||
flags: MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const ticketRow = db.getTicket(ticketChannel.id);
|
|
||||||
if (!ticketRow) {
|
|
||||||
const notFound = new EmbedBuilder()
|
|
||||||
.setTitle(msgconfig.ForceAddUser.NotInTicket_Title)
|
|
||||||
.setDescription(msgconfig.ForceAddUser.NotInTicket_Description)
|
|
||||||
.setColor(supportbot.Embed.Colours.Error);
|
|
||||||
|
|
||||||
return interaction.reply({
|
|
||||||
embeds: [notFound],
|
|
||||||
flags: MessageFlags.Ephemeral,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (supportbot.Ticket.TicketType === "threads") {
|
if (supportbot.Ticket.TicketType === "threads") {
|
||||||
const botMember = await ticketChannel.members.fetch(interaction.client.user.id).catch(() => null);
|
try {
|
||||||
if (!botMember) await ticketChannel.join();
|
// Explicitly ensure the bot is in the thread
|
||||||
await new Promise(res => setTimeout(res, 1000));
|
const botMember = await ticketChannel.members.fetch(interaction.client.user.id).catch(() => null);
|
||||||
await ticketChannel.members.add(userToAdd.id);
|
if (!botMember) {
|
||||||
|
await ticketChannel.join();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delay to ensure API has processed the bot's membership
|
||||||
|
await new Promise(res => setTimeout(res, 1000));
|
||||||
|
|
||||||
|
// Attempt to add the user to the thread
|
||||||
|
await ticketChannel.members.add(userToAdd.id);
|
||||||
|
|
||||||
|
console.log("User successfully added to the thread.");
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Error adding user to the thread:", err.message);
|
||||||
|
const errorEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.ForceAddUser.Error_Title)
|
||||||
|
.setDescription(`An error occurred: ${err.message}`)
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
return interaction.reply({
|
||||||
|
embeds: [errorEmbed],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
} else if (supportbot.Ticket.TicketType === "channels") {
|
} else if (supportbot.Ticket.TicketType === "channels") {
|
||||||
await ticketChannel.permissionOverwrites.create(userToAdd.id, {
|
await ticketChannel.permissionOverwrites.create(userToAdd.id, {
|
||||||
ViewChannel: true,
|
ViewChannel: true,
|
||||||
@@ -75,7 +85,12 @@ module.exports = new Command({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
db.addUserToTicket(ticketChannel.id, userToAdd.id);
|
const ticketData = JSON.parse(fs.readFileSync(ticketDataPath, "utf8"));
|
||||||
|
const ticketIndex = ticketData.tickets.findIndex((t) => t.id === ticketChannel.id);
|
||||||
|
if (ticketIndex !== -1) {
|
||||||
|
ticketData.tickets[ticketIndex].subUsers.push(userToAdd.id);
|
||||||
|
fs.writeFileSync(ticketDataPath, JSON.stringify(ticketData, null, 4));
|
||||||
|
}
|
||||||
|
|
||||||
const addedEmbed = new EmbedBuilder()
|
const addedEmbed = new EmbedBuilder()
|
||||||
.setTitle(msgconfig.ForceAddUser.Added_Title)
|
.setTitle(msgconfig.ForceAddUser.Added_Title)
|
||||||
@@ -86,7 +101,7 @@ module.exports = new Command({
|
|||||||
|
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [addedEmbed],
|
embeds: [addedEmbed],
|
||||||
flags: MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const addedToTicketEmbed = new EmbedBuilder()
|
const addedToTicketEmbed = new EmbedBuilder()
|
||||||
@@ -112,7 +127,7 @@ module.exports = new Command({
|
|||||||
|
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [errorEmbed],
|
embeds: [errorEmbed],
|
||||||
flags: MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -5,7 +5,7 @@ const yaml = require("js-yaml");
|
|||||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
||||||
|
|
||||||
const Command = require("../../Structures/Command.js");
|
const Command = require("../Structures/Command.js");
|
||||||
|
|
||||||
module.exports = new Command({
|
module.exports = new Command({
|
||||||
name: cmdconfig.Help.Command,
|
name: cmdconfig.Help.Command,
|
||||||
@@ -55,7 +55,7 @@ module.exports = new Command({
|
|||||||
});
|
});
|
||||||
|
|
||||||
interaction.reply({
|
interaction.reply({
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
embeds: [HelpEmbed1],
|
embeds: [HelpEmbed1],
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -18,7 +18,7 @@ const msgconfig = yaml.load(
|
|||||||
fs.readFileSync("./Configs/messages.yml", "utf8")
|
fs.readFileSync("./Configs/messages.yml", "utf8")
|
||||||
);
|
);
|
||||||
|
|
||||||
const Command = require("../../Structures/Command.js");
|
const Command = require("../Structures/Command.js");
|
||||||
|
|
||||||
module.exports = new Command({
|
module.exports = new Command({
|
||||||
name: cmdconfig.Info.Command,
|
name: cmdconfig.Info.Command,
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const { ApplicationCommandOptionType, ApplicationCommandType, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType, MessageFlags } = require("discord.js");
|
const { ApplicationCommandOptionType, ApplicationCommandType, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType } = require("discord.js");
|
||||||
const yaml = require("js-yaml");
|
const yaml = require("js-yaml");
|
||||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
||||||
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
||||||
|
|
||||||
const Command = require("../../Structures/Command.js");
|
const Command = require("../Structures/Command.js");
|
||||||
|
|
||||||
// Function to chunk array into smaller arrays
|
// Function to chunk array into smaller arrays
|
||||||
function chunkArray(arr, size) {
|
function chunkArray(arr, size) {
|
||||||
@@ -116,7 +116,7 @@ module.exports = new Command({
|
|||||||
const alreadyBlacklistedEmbed = new EmbedBuilder()
|
const alreadyBlacklistedEmbed = new EmbedBuilder()
|
||||||
.setDescription(msgconfig.Mod.TicketBlacklist.Add.AlreadyBlacklisted.replace("{userTag}", user.tag) || ":x: User is already blacklisted.")
|
.setDescription(msgconfig.Mod.TicketBlacklist.Add.AlreadyBlacklisted.replace("{userTag}", user.tag) || ":x: User is already blacklisted.")
|
||||||
.setColor(supportbot.Embed.Colours.Warn);
|
.setColor(supportbot.Embed.Colours.Warn);
|
||||||
return interaction.reply({ embeds: [alreadyBlacklistedEmbed], flags: MessageFlags.Ephemeral });
|
return interaction.reply({ embeds: [alreadyBlacklistedEmbed], ephemeral: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
blacklistedUsers.push(user.id);
|
blacklistedUsers.push(user.id);
|
||||||
@@ -141,7 +141,7 @@ module.exports = new Command({
|
|||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
embeds: [successEmbed],
|
embeds: [successEmbed],
|
||||||
flags: MessageFlags.Ephemeral
|
ephemeral: true
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if (subcommand === cmdconfig.Mod.TicketBlacklist.Remove.Command) {
|
} else if (subcommand === cmdconfig.Mod.TicketBlacklist.Remove.Command) {
|
||||||
@@ -149,7 +149,7 @@ module.exports = new Command({
|
|||||||
const notBlacklistedEmbed = new EmbedBuilder()
|
const notBlacklistedEmbed = new EmbedBuilder()
|
||||||
.setDescription(msgconfig.Mod.TicketBlacklist.Remove.NotBlacklisted.replace("{userTag}", user.tag) || ":x: User is not blacklisted.")
|
.setDescription(msgconfig.Mod.TicketBlacklist.Remove.NotBlacklisted.replace("{userTag}", user.tag) || ":x: User is not blacklisted.")
|
||||||
.setColor(supportbot.Embed.Colours.Warn);
|
.setColor(supportbot.Embed.Colours.Warn);
|
||||||
return interaction.reply({ embeds: [notBlacklistedEmbed], flags: MessageFlags.Ephemeral });
|
return interaction.reply({ embeds: [notBlacklistedEmbed], ephemeral: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
blacklistedUsers = blacklistedUsers.filter(id => id !== user.id);
|
blacklistedUsers = blacklistedUsers.filter(id => id !== user.id);
|
||||||
@@ -172,14 +172,14 @@ module.exports = new Command({
|
|||||||
blacklistChannel.send({ embeds: [blacklistLogEmbed] });
|
blacklistChannel.send({ embeds: [blacklistLogEmbed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
return interaction.reply({ embeds: [removedEmbed], flags: MessageFlags.Ephemeral });
|
return interaction.reply({ embeds: [removedEmbed], ephemeral: true });
|
||||||
|
|
||||||
} else if (subcommand === "view") {
|
} else if (subcommand === "view") {
|
||||||
if (blacklistedUsers.length === 0) {
|
if (blacklistedUsers.length === 0) {
|
||||||
const noBlacklistedUsersEmbed = new EmbedBuilder()
|
const noBlacklistedUsersEmbed = new EmbedBuilder()
|
||||||
.setDescription(msgconfig.Mod.TicketBlacklist.View.NoBlacklistedUsers || "No users are blacklisted.")
|
.setDescription(msgconfig.Mod.TicketBlacklist.View.NoBlacklistedUsers || "No users are blacklisted.")
|
||||||
.setColor(supportbot.Embed.Colours.Success);
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
return interaction.reply({ embeds: [noBlacklistedUsersEmbed], flags: MessageFlags.Ephemeral });
|
return interaction.reply({ embeds: [noBlacklistedUsersEmbed], ephemeral: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
const chunkedUsers = chunkArray(blacklistedUsers, 5);
|
const chunkedUsers = chunkArray(blacklistedUsers, 5);
|
||||||
@@ -210,7 +210,7 @@ module.exports = new Command({
|
|||||||
const response = await interaction.reply({
|
const response = await interaction.reply({
|
||||||
embeds: [createEmbed(currentPage)],
|
embeds: [createEmbed(currentPage)],
|
||||||
components: chunkedUsers.length > 1 ? [buttons] : [],
|
components: chunkedUsers.length > 1 ? [buttons] : [],
|
||||||
flags: MessageFlags.Ephemeral
|
ephemeral: true
|
||||||
});
|
});
|
||||||
|
|
||||||
if (chunkedUsers.length <= 1) return;
|
if (chunkedUsers.length <= 1) return;
|
||||||
@@ -224,7 +224,7 @@ module.exports = new Command({
|
|||||||
if (i.user.id !== interaction.user.id) {
|
if (i.user.id !== interaction.user.id) {
|
||||||
return i.reply({
|
return i.reply({
|
||||||
content: 'You cannot use these buttons.',
|
content: 'You cannot use these buttons.',
|
||||||
flags: MessageFlags.Ephemeral
|
ephemeral: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ module.exports = new Command({
|
|||||||
const errorEmbed = new EmbedBuilder()
|
const errorEmbed = new EmbedBuilder()
|
||||||
.setDescription(msgconfig.Error.ActionFailed || "An error occurred while processing your request.")
|
.setDescription(msgconfig.Error.ActionFailed || "An error occurred while processing your request.")
|
||||||
.setColor(supportbot.Embed.Colours.Warn);
|
.setColor(supportbot.Embed.Colours.Warn);
|
||||||
interaction.reply({ embeds: [errorEmbed], flags: MessageFlags.Ephemeral });
|
interaction.reply({ embeds: [errorEmbed], ephemeral: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -10,7 +10,7 @@ const supportbot = yaml.load(
|
|||||||
);
|
);
|
||||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
||||||
|
|
||||||
const Command = require("../../Structures/Command.js");
|
const Command = require("../Structures/Command.js");
|
||||||
|
|
||||||
module.exports = new Command({
|
module.exports = new Command({
|
||||||
name: cmdconfig.Ping.Command,
|
name: cmdconfig.Ping.Command,
|
||||||
@@ -0,0 +1,320 @@
|
|||||||
|
const { EmbedBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ApplicationCommandType, ActionRowBuilder, ButtonBuilder, ButtonStyle, ApplicationCommandOptionType } = require("discord.js");
|
||||||
|
const fs = require("fs");
|
||||||
|
const yaml = require("js-yaml");
|
||||||
|
|
||||||
|
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||||
|
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
||||||
|
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
||||||
|
|
||||||
|
const Command = require("../Structures/Command.js");
|
||||||
|
|
||||||
|
const clockedInUsers = new Set();
|
||||||
|
|
||||||
|
function updateClockedInStatus(profileEmbed, clockedIn) {
|
||||||
|
profileEmbed.data.fields = profileEmbed.data.fields.map(field => {
|
||||||
|
if (field.name === 'Clocked In Status') {
|
||||||
|
field.value = clockedIn ? '✅ Clocked In' : '❌ Clocked Out';
|
||||||
|
}
|
||||||
|
return field;
|
||||||
|
});
|
||||||
|
return profileEmbed;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new Command({
|
||||||
|
name: cmdconfig.Profile.Command,
|
||||||
|
description: cmdconfig.Profile.Description,
|
||||||
|
type: ApplicationCommandType.ChatInput,
|
||||||
|
permissions: cmdconfig.Profile.Permission,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'user',
|
||||||
|
description: 'The user to view the profile of',
|
||||||
|
type: ApplicationCommandOptionType.User,
|
||||||
|
required: false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
async run(interaction) {
|
||||||
|
await interaction.deferReply({ ephemeral: true });
|
||||||
|
|
||||||
|
const userOption = interaction.options.getUser('user');
|
||||||
|
const viewingUser = userOption || interaction.user;
|
||||||
|
const viewingUserId = viewingUser.id;
|
||||||
|
const interactionUserId = interaction.user.id;
|
||||||
|
|
||||||
|
const user = interaction.guild.members.cache.get(viewingUserId);
|
||||||
|
const { getRole, getChannel } = interaction.client;
|
||||||
|
|
||||||
|
const Staff = await getRole(supportbot.Roles.StaffMember.Staff, interaction.guild);
|
||||||
|
const Admin = await getRole(supportbot.Roles.StaffMember.Admin, interaction.guild);
|
||||||
|
|
||||||
|
if (!Staff || !Admin) {
|
||||||
|
return interaction.editReply({
|
||||||
|
content: "Some roles seem to be missing!\nPlease check for errors when starting the bot.",
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const isStaff = user.roles.cache.has(Staff.id) || user.roles.cache.has(Admin.id);
|
||||||
|
const isOwnProfile = interactionUserId === viewingUserId;
|
||||||
|
|
||||||
|
const profilePath = `./Data/Profiles/${viewingUserId}.json`;
|
||||||
|
let profileData;
|
||||||
|
|
||||||
|
if (fs.existsSync(profilePath)) {
|
||||||
|
profileData = JSON.parse(fs.readFileSync(profilePath, "utf8"));
|
||||||
|
} else {
|
||||||
|
profileData = {
|
||||||
|
bio: "",
|
||||||
|
timezone: "",
|
||||||
|
clockedIn: false
|
||||||
|
};
|
||||||
|
fs.writeFileSync(profilePath, JSON.stringify(profileData, null, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
const { bio, timezone, clockedIn } = profileData;
|
||||||
|
|
||||||
|
let profileEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(`${viewingUser.username}'s Profile`)
|
||||||
|
.setColor(supportbot.Embed.Colours.General)
|
||||||
|
.setThumbnail(viewingUser.displayAvatarURL())
|
||||||
|
.addFields(
|
||||||
|
{ name: 'Bio', value: bio || 'No bio set.', inline: false },
|
||||||
|
{ name: 'Timezone', value: timezone || 'No timezone set.', inline: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isStaff) {
|
||||||
|
profileEmbed.addFields({ name: 'Clocked In Status', value: clockedIn ? '✅ Clocked In' : '❌ Clocked Out', inline: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const buttonRow = new ActionRowBuilder();
|
||||||
|
if (isOwnProfile) {
|
||||||
|
buttonRow.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId('editProfile')
|
||||||
|
.setLabel('Edit Profile')
|
||||||
|
.setStyle(ButtonStyle.Secondary)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isStaff) {
|
||||||
|
buttonRow.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId('clockInOut')
|
||||||
|
.setLabel(clockedIn ? 'Clock Out' : 'Clock In')
|
||||||
|
.setStyle(ButtonStyle.Secondary)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isStaff && supportbot.Ticket.ClaimTickets.Enabled) {
|
||||||
|
buttonRow.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId('viewTicketStats')
|
||||||
|
.setLabel('View Ticket Stats')
|
||||||
|
.setStyle(ButtonStyle.Secondary)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await interaction.editReply({ embeds: [profileEmbed], components: buttonRow.components.length > 0 ? [buttonRow] : [] });
|
||||||
|
|
||||||
|
const filter = i => (
|
||||||
|
['editProfile', 'clockInOut', 'viewTicketStats', 'showOpenTickets', 'backToStats', 'backToProfile'].includes(i.customId)
|
||||||
|
&& i.user.id === interactionUserId
|
||||||
|
);
|
||||||
|
|
||||||
|
const collector = interaction.channel.createMessageComponentCollector({ filter, time: 60000 });
|
||||||
|
|
||||||
|
collector.on('collect', async i => {
|
||||||
|
if (i.customId === 'editProfile') {
|
||||||
|
const modal = new ModalBuilder()
|
||||||
|
.setCustomId('editProfileModal')
|
||||||
|
.setTitle('Edit Profile')
|
||||||
|
.addComponents(
|
||||||
|
new ActionRowBuilder().addComponents(
|
||||||
|
new TextInputBuilder()
|
||||||
|
.setCustomId('bio')
|
||||||
|
.setLabel('Bio')
|
||||||
|
.setStyle(TextInputStyle.Paragraph)
|
||||||
|
.setPlaceholder('Enter your bio')
|
||||||
|
.setValue(String(bio))
|
||||||
|
.setRequired(false)
|
||||||
|
),
|
||||||
|
new ActionRowBuilder().addComponents(
|
||||||
|
new TextInputBuilder()
|
||||||
|
.setCustomId('timezone')
|
||||||
|
.setLabel('Timezone')
|
||||||
|
.setStyle(TextInputStyle.Short)
|
||||||
|
.setPlaceholder('Enter your timezone')
|
||||||
|
.setValue(String(timezone))
|
||||||
|
.setRequired(false)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
await i.showModal(modal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i.customId === 'clockInOut') {
|
||||||
|
profileData.clockedIn = !profileData.clockedIn;
|
||||||
|
fs.writeFileSync(profilePath, JSON.stringify(profileData, null, 2));
|
||||||
|
profileEmbed = updateClockedInStatus(profileEmbed, profileData.clockedIn);
|
||||||
|
|
||||||
|
if (profileData.clockedIn) {
|
||||||
|
clockedInUsers.add(viewingUserId);
|
||||||
|
} else {
|
||||||
|
clockedInUsers.delete(viewingUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
const updatedButtonRow = new ActionRowBuilder()
|
||||||
|
.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId('editProfile')
|
||||||
|
.setLabel('Edit Profile')
|
||||||
|
.setStyle(ButtonStyle.Secondary)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isStaff) {
|
||||||
|
updatedButtonRow.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId('clockInOut')
|
||||||
|
.setLabel(profileData.clockedIn ? 'Clock Out' : 'Clock In')
|
||||||
|
.setStyle(ButtonStyle.Secondary)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (supportbot.Ticket.ClaimTickets.Enabled) {
|
||||||
|
updatedButtonRow.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId('viewTicketStats')
|
||||||
|
.setLabel('View Ticket Stats')
|
||||||
|
.setStyle(ButtonStyle.Secondary)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await i.update({ embeds: [profileEmbed], components: [updatedButtonRow] });
|
||||||
|
|
||||||
|
let clockedinout = new EmbedBuilder()
|
||||||
|
.setTitle(profileData.clockedIn ? 'Clocked In!' : 'Clocked Out!')
|
||||||
|
.setDescription(profileData.clockedIn ? 'You have successfully clocked in.' : 'You have successfully clocked out.')
|
||||||
|
.setColor(supportbot.Embed.Colours.General)
|
||||||
|
|
||||||
|
await interaction.followUp({ embeds: [clockedinout], ephemeral: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i.customId === 'viewTicketStats') {
|
||||||
|
const TicketData = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
||||||
|
const ticketsClaimed = TicketData.tickets.filter(t => t.claimedBy === viewingUserId);
|
||||||
|
const ticketsOpen = ticketsClaimed.filter(t => t.open);
|
||||||
|
const totalTickets = ticketsClaimed.length;
|
||||||
|
|
||||||
|
let totalResponseTime = 0;
|
||||||
|
let responseCount = 0;
|
||||||
|
|
||||||
|
ticketsClaimed.forEach(ticket => {
|
||||||
|
if (ticket.claimedAt && ticket.createdAt) {
|
||||||
|
const responseTime = new Date(ticket.claimedAt) - new Date(ticket.createdAt);
|
||||||
|
totalResponseTime += responseTime;
|
||||||
|
responseCount++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const averageResponseTime = responseCount ? totalResponseTime / responseCount : 0;
|
||||||
|
const averageResponseTimeMinutes = Math.round(averageResponseTime / 60000);
|
||||||
|
|
||||||
|
const statsEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.TicketStats.Title)
|
||||||
|
.setDescription(`> Ticket stats for <@${viewingUserId}>`)
|
||||||
|
.setColor(supportbot.Embed.Colours.General)
|
||||||
|
.addFields(
|
||||||
|
{ name: msgconfig.TicketStats.OpenTickets, value: `${ticketsOpen.length}`, inline: true },
|
||||||
|
{ name: msgconfig.TicketStats.TotalTickets, value: `${totalTickets}`, inline: true },
|
||||||
|
{ name: msgconfig.TicketStats.ResponseTime, value: `${averageResponseTimeMinutes} minutes`, inline: false }
|
||||||
|
);
|
||||||
|
|
||||||
|
const statsButtonRow = new ActionRowBuilder()
|
||||||
|
.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId('showOpenTickets')
|
||||||
|
.setLabel('Show Open Tickets')
|
||||||
|
.setStyle(ButtonStyle.Secondary),
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId('backToProfile')
|
||||||
|
.setLabel('Back to Profile')
|
||||||
|
.setStyle(ButtonStyle.Secondary)
|
||||||
|
);
|
||||||
|
|
||||||
|
await i.update({ embeds: [statsEmbed], components: [statsButtonRow] });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i.customId === 'showOpenTickets') {
|
||||||
|
const TicketData = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
||||||
|
const ticketsOpen = TicketData.tickets.filter(t => t.claimedBy === viewingUserId && t.open);
|
||||||
|
|
||||||
|
const openTicketsEmbed = new EmbedBuilder()
|
||||||
|
.setTitle('Active Tickets')
|
||||||
|
.setDescription(ticketsOpen.map(t => `<#${t.id}>`).join('\n') || 'No active tickets.')
|
||||||
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
|
const openTicketsButtonRow = new ActionRowBuilder()
|
||||||
|
.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId('backToStats')
|
||||||
|
.setLabel('Back to Stats')
|
||||||
|
.setStyle(ButtonStyle.Secondary)
|
||||||
|
);
|
||||||
|
|
||||||
|
await i.update({ embeds: [openTicketsEmbed], components: [openTicketsButtonRow] });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i.customId === 'backToStats') {
|
||||||
|
const TicketData = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
||||||
|
const ticketsClaimed = TicketData.tickets.filter(t => t.claimedBy === viewingUserId);
|
||||||
|
const ticketsOpen = ticketsClaimed.filter(t => t.open);
|
||||||
|
const totalTickets = ticketsClaimed.length;
|
||||||
|
|
||||||
|
let totalResponseTime = 0;
|
||||||
|
let responseCount = 0;
|
||||||
|
|
||||||
|
ticketsClaimed.forEach(ticket => {
|
||||||
|
if (ticket.claimedAt && ticket.createdAt) {
|
||||||
|
const responseTime = new Date(ticket.claimedAt) - new Date(ticket.createdAt);
|
||||||
|
totalResponseTime += responseTime;
|
||||||
|
responseCount++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const averageResponseTime = responseCount ? totalResponseTime / responseCount : 0;
|
||||||
|
const averageResponseTimeMinutes = Math.round(averageResponseTime / 60000);
|
||||||
|
|
||||||
|
const statsEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.TicketStats.Title)
|
||||||
|
.setDescription(`> Ticket stats for <@${viewingUserId}>`)
|
||||||
|
.setColor(supportbot.Embed.Colours.General)
|
||||||
|
.addFields(
|
||||||
|
{ name: msgconfig.TicketStats.OpenTickets, value: `${ticketsOpen.length}`, inline: true },
|
||||||
|
{ name: msgconfig.TicketStats.TotalTickets, value: `${totalTickets}`, inline: true },
|
||||||
|
{ name: msgconfig.TicketStats.ResponseTime, value: `${averageResponseTimeMinutes} minutes`, inline: false }
|
||||||
|
);
|
||||||
|
|
||||||
|
const statsButtonRow = new ActionRowBuilder()
|
||||||
|
.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId('showOpenTickets')
|
||||||
|
.setLabel('Show Open Tickets')
|
||||||
|
.setStyle(ButtonStyle.Secondary),
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId('backToProfile')
|
||||||
|
.setLabel('Back to Profile')
|
||||||
|
.setStyle(ButtonStyle.Secondary)
|
||||||
|
);
|
||||||
|
|
||||||
|
await i.update({ embeds: [statsEmbed], components: [statsButtonRow] });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i.customId === 'backToProfile') {
|
||||||
|
await i.update({ embeds: [profileEmbed], components: buttonRow.components.length > 0 ? [buttonRow] : [] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports.clockedInUsers = clockedInUsers;
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
const fs = require("fs");
|
||||||
|
const {
|
||||||
|
EmbedBuilder,
|
||||||
|
ApplicationCommandOptionType,
|
||||||
|
ApplicationCommandType,
|
||||||
|
ChannelType,
|
||||||
|
ActionRowBuilder,
|
||||||
|
ButtonBuilder,
|
||||||
|
ButtonStyle,
|
||||||
|
} = require("discord.js");
|
||||||
|
const yaml = require("js-yaml");
|
||||||
|
|
||||||
|
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||||
|
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
||||||
|
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
||||||
|
|
||||||
|
const Command = require("../Structures/Command.js");
|
||||||
|
|
||||||
|
module.exports = new Command({
|
||||||
|
name: cmdconfig.RemoveUser.Command,
|
||||||
|
description: cmdconfig.RemoveUser.Description,
|
||||||
|
type: ApplicationCommandType.ChatInput,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "user",
|
||||||
|
description: "The user to remove",
|
||||||
|
type: ApplicationCommandOptionType.User,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
permissions: cmdconfig.RemoveUser.Permission,
|
||||||
|
|
||||||
|
async run(interaction) {
|
||||||
|
|
||||||
|
const { getRole } = interaction.client;
|
||||||
|
let SupportStaff = await getRole(supportbot.Roles.StaffMember.Staff, interaction.guild);
|
||||||
|
let Admin = await getRole(supportbot.Roles.StaffMember.Admin, interaction.guild);
|
||||||
|
if (!SupportStaff || !Admin) {
|
||||||
|
return interaction.reply(
|
||||||
|
"Some roles seem to be missing!\nPlease check for errors when starting the bot."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const NoPerms = new EmbedBuilder()
|
||||||
|
.setTitle("Invalid Permissions!")
|
||||||
|
.setDescription(
|
||||||
|
`${msgconfig.Error.IncorrectPerms}\n\nRole Required: \`${supportbot.Roles.StaffMember.Staff}\` or \`${supportbot.Roles.StaffMember.Admin}\``
|
||||||
|
)
|
||||||
|
.setColor(supportbot.Embed.Colours.Warn);
|
||||||
|
|
||||||
|
if (
|
||||||
|
!interaction.member.roles.cache.has(SupportStaff.id) &&
|
||||||
|
!interaction.member.roles.cache.has(Admin.id)
|
||||||
|
) {
|
||||||
|
return interaction.reply({ embeds: [NoPerms] });
|
||||||
|
}
|
||||||
|
|
||||||
|
const userToRemove = interaction.options.getUser("user");
|
||||||
|
const ticketChannel = interaction.channel;
|
||||||
|
const ticketDataPath = "./Data/TicketData.json";
|
||||||
|
|
||||||
|
// Check if the channel is a ticket thread or text channel based on TicketType
|
||||||
|
if (
|
||||||
|
(supportbot.Ticket.TicketType === "threads" && !ticketChannel.isThread()) ||
|
||||||
|
(supportbot.Ticket.TicketType === "channels" && ticketChannel.type !== ChannelType.GuildText)
|
||||||
|
) {
|
||||||
|
const onlyInTicket = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.RemoveUser.NotInTicket_Title)
|
||||||
|
.setDescription(msgconfig.RemoveUser.NotInTicket_Description)
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
return interaction.reply({
|
||||||
|
embeds: [onlyInTicket],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Remove user from thread or channel based on TicketType
|
||||||
|
if (supportbot.Ticket.TicketType === "threads") {
|
||||||
|
await ticketChannel.members.remove(userToRemove.id); // For threads
|
||||||
|
} else if (supportbot.Ticket.TicketType === "channels") {
|
||||||
|
await ticketChannel.permissionOverwrites.delete(userToRemove.id); // For channels
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the ticket data
|
||||||
|
const ticketData = JSON.parse(fs.readFileSync(ticketDataPath, "utf8"));
|
||||||
|
const ticketIndex = ticketData.tickets.findIndex((t) => t.id === ticketChannel.id);
|
||||||
|
if (ticketIndex !== -1) {
|
||||||
|
const subUsers = ticketData.tickets[ticketIndex].subUsers;
|
||||||
|
const userIndex = subUsers.indexOf(userToRemove.id);
|
||||||
|
if (userIndex !== -1) {
|
||||||
|
subUsers.splice(userIndex, 1);
|
||||||
|
fs.writeFileSync(ticketDataPath, JSON.stringify(ticketData, null, 4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const removedEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.RemoveUser.Removed_Title)
|
||||||
|
.setDescription(msgconfig.RemoveUser.Removed_Message)
|
||||||
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
|
|
||||||
|
await interaction.reply({
|
||||||
|
embeds: [removedEmbed],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const removedFromTicketEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.RemoveUser.RemovedFromTicket_Title)
|
||||||
|
.setDescription(msgconfig.RemoveUser.RemovedFromTicket_Description.replace(
|
||||||
|
"%channel_link%",
|
||||||
|
`[${ticketChannel.name}](https://discord.com/channels/${ticketChannel.guild.id}/${ticketChannel.id})`
|
||||||
|
))
|
||||||
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
|
await userToRemove.send({
|
||||||
|
embeds: [removedFromTicketEmbed],
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Error removing user from the ticket:", err);
|
||||||
|
|
||||||
|
const errorEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.RemoveUser.Error_Title)
|
||||||
|
.setDescription(msgconfig.RemoveUser.Error_Removing)
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
await interaction.reply({
|
||||||
|
embeds: [errorEmbed],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -1,35 +1,33 @@
|
|||||||
const { Command } = require('../../Structures/Addon.js');
|
const { Command } = require('../Structures/Addon.js');
|
||||||
const Discord = require("discord.js");
|
const Discord = require("discord.js");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const yaml = require("js-yaml");
|
const yaml = require("js-yaml");
|
||||||
const db = require("../../Structures/Database.js");
|
const path = require("path");
|
||||||
|
|
||||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
||||||
|
const settingsFilePath = path.resolve(__dirname, '../Data/settings.json');
|
||||||
|
|
||||||
async function loadSettings() {
|
function loadSettings() {
|
||||||
return new Promise((resolve, reject) => {
|
try {
|
||||||
db.get("SELECT data FROM settings WHERE id = 1", (err, row) => {
|
if (fs.existsSync(settingsFilePath)) {
|
||||||
if (err) return reject(err);
|
const data = fs.readFileSync(settingsFilePath, 'utf8');
|
||||||
if (!row) return resolve({});
|
return JSON.parse(data);
|
||||||
try {
|
} else {
|
||||||
resolve(JSON.parse(row.data));
|
return {};
|
||||||
} catch (e) {
|
}
|
||||||
resolve({});
|
} catch (error) {
|
||||||
}
|
console.error("Error reading settings file:", error);
|
||||||
});
|
return {};
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveSettings(settings) {
|
function saveSettings(settings) {
|
||||||
const data = JSON.stringify(settings);
|
try {
|
||||||
return new Promise((resolve, reject) => {
|
fs.writeFileSync(settingsFilePath, JSON.stringify(settings, null, 2), 'utf8');
|
||||||
db.run(
|
} catch (error) {
|
||||||
"INSERT INTO settings (id, data) VALUES (1, ?) ON CONFLICT(id) DO UPDATE SET data = excluded.data",
|
console.error("Error writing settings file:", error);
|
||||||
[data],
|
}
|
||||||
(err) => (err ? reject(err) : resolve())
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = new Command({
|
module.exports = new Command({
|
||||||
@@ -121,7 +119,7 @@ module.exports = new Command({
|
|||||||
|
|
||||||
async run(interaction) {
|
async run(interaction) {
|
||||||
const subcommand = interaction.options.getSubcommand();
|
const subcommand = interaction.options.getSubcommand();
|
||||||
const settings = await loadSettings();
|
const settings = loadSettings();
|
||||||
|
|
||||||
if (subcommand === 'setstatus') {
|
if (subcommand === 'setstatus') {
|
||||||
const status = interaction.options.getString('status');
|
const status = interaction.options.getString('status');
|
||||||
@@ -133,15 +131,15 @@ module.exports = new Command({
|
|||||||
});
|
});
|
||||||
|
|
||||||
settings.status = status;
|
settings.status = status;
|
||||||
await saveSettings(settings);
|
saveSettings(settings);
|
||||||
|
|
||||||
const embed = new Discord.EmbedBuilder()
|
const embed = new Discord.EmbedBuilder()
|
||||||
.setDescription(`Status set to **${status.charAt(0).toUpperCase() + status.slice(1)}**`)
|
.setDescription(`Status set to **${status.charAt(0).toUpperCase() + status.slice(1)}**`)
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
return interaction.reply({ embeds: [embed], flags: Discord.MessageFlags.Ephemeral });
|
return interaction.reply({ embeds: [embed], ephemeral: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return interaction.reply({ content: `Failed to set status: ${error.message}`, flags: Discord.MessageFlags.Ephemeral });
|
return interaction.reply({ content: `Failed to set status: ${error.message}`, ephemeral: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,15 +154,15 @@ module.exports = new Command({
|
|||||||
});
|
});
|
||||||
|
|
||||||
settings.activity = { type: activityType, message: activityMessage };
|
settings.activity = { type: activityType, message: activityMessage };
|
||||||
await saveSettings(settings);
|
saveSettings(settings);
|
||||||
|
|
||||||
const embed = new Discord.EmbedBuilder()
|
const embed = new Discord.EmbedBuilder()
|
||||||
.setDescription(`Activity set to **${activityType.toLowerCase()} ${activityMessage}**`)
|
.setDescription(`Activity set to **${activityType.toLowerCase()} ${activityMessage}**`)
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
return interaction.reply({ embeds: [embed], flags: Discord.MessageFlags.Ephemeral });
|
return interaction.reply({ embeds: [embed], ephemeral: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return interaction.reply({ content: `Failed to set activity: ${error.message}`, flags: Discord.MessageFlags.Ephemeral });
|
return interaction.reply({ content: `Failed to set activity: ${error.message}`, ephemeral: true });
|
||||||
}
|
}
|
||||||
} else if (subcommand === 'streammode') {
|
} else if (subcommand === 'streammode') {
|
||||||
const toggle = interaction.options.getString('toggle');
|
const toggle = interaction.options.getString('toggle');
|
||||||
@@ -172,7 +170,7 @@ module.exports = new Command({
|
|||||||
|
|
||||||
if (toggle === 'on') {
|
if (toggle === 'on') {
|
||||||
if (!twitchUrl) {
|
if (!twitchUrl) {
|
||||||
return interaction.reply({ content: 'Please provide a Twitch URL to stream.', flags: Discord.MessageFlags.Ephemeral });
|
return interaction.reply({ content: 'Please provide a Twitch URL to stream.', ephemeral: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -182,15 +180,15 @@ module.exports = new Command({
|
|||||||
});
|
});
|
||||||
|
|
||||||
settings.streaming = { active: true, url: twitchUrl };
|
settings.streaming = { active: true, url: twitchUrl };
|
||||||
await saveSettings(settings);
|
saveSettings(settings);
|
||||||
|
|
||||||
const embed = new Discord.EmbedBuilder()
|
const embed = new Discord.EmbedBuilder()
|
||||||
.setDescription(`**Streaming mode enabled!**\nStreaming: [Twitch](${twitchUrl})`)
|
.setDescription(`**Streaming mode enabled!**\nStreaming: [Twitch](${twitchUrl})`)
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
return interaction.reply({ embeds: [embed], flags: Discord.MessageFlags.Ephemeral });
|
return interaction.reply({ embeds: [embed], ephemeral: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return interaction.reply({ content: `Failed to enable streaming mode: ${error.message}`, flags: Discord.MessageFlags.Ephemeral });
|
return interaction.reply({ content: `Failed to enable streaming mode: ${error.message}`, ephemeral: true });
|
||||||
}
|
}
|
||||||
} else if (toggle === 'off') {
|
} else if (toggle === 'off') {
|
||||||
try {
|
try {
|
||||||
@@ -200,15 +198,15 @@ module.exports = new Command({
|
|||||||
});
|
});
|
||||||
|
|
||||||
settings.streaming = { active: false };
|
settings.streaming = { active: false };
|
||||||
await saveSettings(settings);
|
saveSettings(settings);
|
||||||
|
|
||||||
const embed = new Discord.EmbedBuilder()
|
const embed = new Discord.EmbedBuilder()
|
||||||
.setDescription(`**Streaming mode disabled!**`)
|
.setDescription(`**Streaming mode disabled!**`)
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
return interaction.reply({ embeds: [embed], flags: Discord.MessageFlags.Ephemeral });
|
return interaction.reply({ embeds: [embed], ephemeral: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return interaction.reply({ content: `Failed to disable streaming mode: ${error.message}`, flags: Discord.MessageFlags.Ephemeral });
|
return interaction.reply({ content: `Failed to disable streaming mode: ${error.message}`, ephemeral: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (subcommand === 'setnickname') {
|
} else if (subcommand === 'setnickname') {
|
||||||
@@ -220,18 +218,18 @@ module.exports = new Command({
|
|||||||
await botMember.setNickname(nickname);
|
await botMember.setNickname(nickname);
|
||||||
|
|
||||||
settings.nickname = nickname;
|
settings.nickname = nickname;
|
||||||
await saveSettings(settings);
|
saveSettings(settings);
|
||||||
|
|
||||||
const embed = new Discord.EmbedBuilder()
|
const embed = new Discord.EmbedBuilder()
|
||||||
.setDescription(`Bot nickname set to **${nickname}**`)
|
.setDescription(`Bot nickname set to **${nickname}**`)
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
return interaction.reply({ embeds: [embed], flags: Discord.MessageFlags.Ephemeral });
|
return interaction.reply({ embeds: [embed], ephemeral: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return interaction.reply({ content: `Failed to set nickname: ${error.message}`, flags: Discord.MessageFlags.Ephemeral });
|
return interaction.reply({ content: `Failed to set nickname: ${error.message}`, ephemeral: true });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return interaction.reply({ content: 'Invalid command usage.', flags: Discord.MessageFlags.Ephemeral });
|
return interaction.reply({ content: 'Invalid command usage.', ephemeral: true });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
const fs = require("fs");
|
||||||
|
const Discord = require("discord.js");
|
||||||
|
const yaml = require("js-yaml");
|
||||||
|
|
||||||
|
// Load configurations
|
||||||
|
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||||
|
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
||||||
|
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
||||||
|
|
||||||
|
const Command = require("../Structures/Command.js");
|
||||||
|
|
||||||
|
// Ensure suggestions file exists and is correctly loaded
|
||||||
|
let suggestions;
|
||||||
|
try {
|
||||||
|
suggestions = require("../Data/SuggestionData.json");
|
||||||
|
} catch (error) {
|
||||||
|
suggestions = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new Command({
|
||||||
|
name: cmdconfig.Suggestion.Command,
|
||||||
|
description: cmdconfig.Suggestion.Description,
|
||||||
|
type: Discord.ApplicationCommandType.ChatInput,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "suggestion",
|
||||||
|
description: "Create a Suggestion",
|
||||||
|
type: Discord.ApplicationCommandOptionType.String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
permissions: cmdconfig.Suggestion.Permission,
|
||||||
|
|
||||||
|
async run(interaction) {
|
||||||
|
const { getChannel } = interaction.client;
|
||||||
|
|
||||||
|
const suggestChannel = await getChannel(
|
||||||
|
supportbot.Suggestions.Channel,
|
||||||
|
interaction.guild
|
||||||
|
);
|
||||||
|
|
||||||
|
const NoChannel = new Discord.EmbedBuilder()
|
||||||
|
.setTitle("Missing Channel!")
|
||||||
|
.setDescription(msgconfig.Error.InvalidChannel)
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
if (!suggestChannel) return interaction.reply({ embeds: [NoChannel] });
|
||||||
|
|
||||||
|
let suggestion = interaction.options.getString("suggestion");
|
||||||
|
|
||||||
|
const SuggestEmbed = new Discord.EmbedBuilder()
|
||||||
|
.addFields(
|
||||||
|
{ name: "Suggestion", value: suggestion, inline: true },
|
||||||
|
{ name: "From", value: `<@${interaction.user.id}>` },
|
||||||
|
{ name: `${supportbot.Suggestions.UpvoteEmoji} ${supportbot.Suggestions.UpvoteTitle}`, value: "0", inline: true },
|
||||||
|
{ name: `${supportbot.Suggestions.DownvoteEmoji} ${supportbot.Suggestions.DownvoteTitle}`, value: "0", inline: true }
|
||||||
|
)
|
||||||
|
.setThumbnail(interaction.user.displayAvatarURL())
|
||||||
|
.setFooter({
|
||||||
|
text: supportbot.Embed.Footer,
|
||||||
|
iconURL: interaction.user.displayAvatarURL(),
|
||||||
|
})
|
||||||
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
|
const UpvoteButton = new Discord.ButtonBuilder()
|
||||||
|
.setCustomId("upvote")
|
||||||
|
.setEmoji(supportbot.Suggestions.UpvoteEmoji)
|
||||||
|
.setStyle(supportbot.Suggestions.Buttons.Upvote);
|
||||||
|
|
||||||
|
const DownvoteButton = new Discord.ButtonBuilder()
|
||||||
|
.setCustomId("downvote")
|
||||||
|
.setEmoji(supportbot.Suggestions.DownvoteEmoji)
|
||||||
|
.setStyle(supportbot.Suggestions.Buttons.Downvote);
|
||||||
|
|
||||||
|
const RemoveVoteButton = new Discord.ButtonBuilder()
|
||||||
|
.setCustomId("removevote")
|
||||||
|
.setLabel(supportbot.Suggestions.Buttons.RemoveVote_Title)
|
||||||
|
.setStyle(supportbot.Suggestions.Buttons.RemoveVote); // Red button
|
||||||
|
|
||||||
|
const row = new Discord.ActionRowBuilder().addComponents(UpvoteButton, DownvoteButton, RemoveVoteButton);
|
||||||
|
|
||||||
|
const suggestionMsg = await suggestChannel.send({ embeds: [SuggestEmbed], components: [row] });
|
||||||
|
|
||||||
|
suggestions[suggestionMsg.id] = {
|
||||||
|
suggestion: suggestion,
|
||||||
|
author: interaction.user.id,
|
||||||
|
upvotes: [],
|
||||||
|
downvotes: []
|
||||||
|
};
|
||||||
|
|
||||||
|
fs.writeFileSync("./Data/SuggestionData.json", JSON.stringify(suggestions, null, 2));
|
||||||
|
|
||||||
|
if (supportbot.Suggestions.Threads.Enabled) {
|
||||||
|
await suggestionMsg.startThread({
|
||||||
|
name: supportbot.Suggestions.Threads.Title,
|
||||||
|
autoArchiveDuration: 60,
|
||||||
|
type: Discord.ChannelType.PublicThread,
|
||||||
|
reason: supportbot.Suggestions.Threads.Reason,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const Submitted = new Discord.EmbedBuilder()
|
||||||
|
.setTitle(`${msgconfig.Suggestions.Sent_Title}`)
|
||||||
|
.setDescription(`${msgconfig.Suggestions.Sent}`)
|
||||||
|
.addFields(
|
||||||
|
{ name: "Sent to:", value: `<#${suggestChannel.id}>` },
|
||||||
|
)
|
||||||
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
|
|
||||||
|
await interaction.reply({
|
||||||
|
ephemeral: true,
|
||||||
|
embeds: [Submitted]
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -10,19 +10,16 @@ const {
|
|||||||
StringSelectMenuOptionBuilder,
|
StringSelectMenuOptionBuilder,
|
||||||
ButtonStyle,
|
ButtonStyle,
|
||||||
MessageCollector,
|
MessageCollector,
|
||||||
MessageFlags,
|
|
||||||
} = require("discord.js");
|
} = require("discord.js");
|
||||||
const yaml = require("js-yaml");
|
const yaml = require("js-yaml");
|
||||||
|
|
||||||
const db = require("../../Structures/Database.js");
|
|
||||||
|
|
||||||
const panelconfig = yaml.load(fs.readFileSync("./Configs/ticket-panel.yml", "utf8"));
|
const panelconfig = yaml.load(fs.readFileSync("./Configs/ticket-panel.yml", "utf8"));
|
||||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
||||||
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
||||||
|
|
||||||
const Command = require("../../Structures/Command.js");
|
const Command = require("../Structures/Command.js");
|
||||||
const TicketNumberID = require("../../Structures/TicketID.js");
|
const TicketNumberID = require("../Structures/TicketID.js");
|
||||||
|
|
||||||
async function isBlacklisted(userId) {
|
async function isBlacklisted(userId) {
|
||||||
let blacklistData;
|
let blacklistData;
|
||||||
@@ -43,11 +40,16 @@ async function isBlacklisted(userId) {
|
|||||||
|
|
||||||
async function getClockedInUsers(guild) {
|
async function getClockedInUsers(guild) {
|
||||||
const clockedInUsers = new Set();
|
const clockedInUsers = new Set();
|
||||||
const rows = guild.members.cache.map(m => m.id);
|
|
||||||
for (const id of rows) {
|
const profilesDir = './Data/Profiles';
|
||||||
const profile = db.getProfile(id);
|
const profileFiles = fs.readdirSync(profilesDir);
|
||||||
if (profile && profile.clockedIn) {
|
|
||||||
clockedInUsers.add(id);
|
for (const file of profileFiles) {
|
||||||
|
const profileData = JSON.parse(fs.readFileSync(`${profilesDir}/${file}`, "utf8"));
|
||||||
|
if (profileData.clockedIn) {
|
||||||
|
const userId = file.replace('.json', '');
|
||||||
|
const member = await guild.members.fetch(userId);
|
||||||
|
if (member) clockedInUsers.add(member.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return clockedInUsers;
|
return clockedInUsers;
|
||||||
@@ -59,11 +61,14 @@ async function askTicketQuestions(ticketChannel, interaction, questions) {
|
|||||||
|
|
||||||
const sendNextQuestion = async () => {
|
const sendNextQuestion = async () => {
|
||||||
if (questionIndex < questions.length) {
|
if (questionIndex < questions.length) {
|
||||||
|
|
||||||
const questionsEmbed = new EmbedBuilder()
|
const questionsEmbed = new EmbedBuilder()
|
||||||
.setDescription(`**${questionIndex + 1}.** ${questions[questionIndex]}`)
|
.setDescription(`**${questionIndex + 1}.** ${questions[questionIndex]}`)
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
.setColor(supportbot.Embed.Colours.General)
|
||||||
|
|
||||||
const questionMessage = await ticketChannel.send({ embeds: [questionsEmbed] });
|
const questionMessage = await ticketChannel.send({
|
||||||
|
embeds: [questionsEmbed],
|
||||||
|
});
|
||||||
|
|
||||||
const collector = new MessageCollector(ticketChannel, {
|
const collector = new MessageCollector(ticketChannel, {
|
||||||
filter: (m) => m.author.id === interaction.user.id,
|
filter: (m) => m.author.id === interaction.user.id,
|
||||||
@@ -78,12 +83,12 @@ async function askTicketQuestions(ticketChannel, interaction, questions) {
|
|||||||
await questionMessage.delete();
|
await questionMessage.delete();
|
||||||
sendNextQuestion();
|
sendNextQuestion();
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const summaryEmbed = new EmbedBuilder()
|
const summaryEmbed = new EmbedBuilder()
|
||||||
.setTitle(msgconfig.Ticket.TicketQuestions.Details.Title)
|
.setTitle(msgconfig.Ticket.TicketQuestions.Details.Title)
|
||||||
.setDescription(
|
.setDescription(msgconfig.Ticket.TicketQuestions.Details.Description.replace('%user%', interaction.user.id))
|
||||||
msgconfig.Ticket.TicketQuestions.Details.Description.replace("%user%", interaction.user.id)
|
|
||||||
)
|
|
||||||
.setColor(supportbot.Embed.Colours.General)
|
.setColor(supportbot.Embed.Colours.General)
|
||||||
.addFields(
|
.addFields(
|
||||||
answers.map((a) => ({
|
answers.map((a) => ({
|
||||||
@@ -94,14 +99,18 @@ async function askTicketQuestions(ticketChannel, interaction, questions) {
|
|||||||
)
|
)
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
await ticketChannel.send({ embeds: [summaryEmbed] });
|
await ticketChannel.send({
|
||||||
|
embeds: [summaryEmbed]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Start asking the first question
|
||||||
sendNextQuestion();
|
sendNextQuestion();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function assignTicketToUser(ticketChannel, Staff, Admin, interaction, attempts = 0) {
|
async function assignTicketToUser(ticketChannel, Staff, Admin, interaction, attempts = 0) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const clockedInUsers = await getClockedInUsers(interaction.guild);
|
const clockedInUsers = await getClockedInUsers(interaction.guild);
|
||||||
|
|
||||||
@@ -115,7 +124,7 @@ async function assignTicketToUser(ticketChannel, Staff, Admin, interaction, atte
|
|||||||
|
|
||||||
const claimButton = new ButtonBuilder()
|
const claimButton = new ButtonBuilder()
|
||||||
.setCustomId(`claimticket-${ticketChannel.id}`)
|
.setCustomId(`claimticket-${ticketChannel.id}`)
|
||||||
.setLabel(supportbot.Ticket.ClaimTickets.ButtonTitle || "Claim Ticket")
|
.setLabel(supportbot.Ticket.ClaimTickets.ButtonTitle || 'Claim Ticket')
|
||||||
.setStyle(ButtonStyle.Primary);
|
.setStyle(ButtonStyle.Primary);
|
||||||
|
|
||||||
const row = new ActionRowBuilder().addComponents(claimButton);
|
const row = new ActionRowBuilder().addComponents(claimButton);
|
||||||
@@ -126,25 +135,20 @@ async function assignTicketToUser(ticketChannel, Staff, Admin, interaction, atte
|
|||||||
components: [row],
|
components: [row],
|
||||||
});
|
});
|
||||||
|
|
||||||
const filter = (i) =>
|
const filter = i => i.customId === `claimticket-${ticketChannel.id}` && i.member.roles.cache.has(Staff.id);
|
||||||
i.customId === `claimticket-${ticketChannel.id}` &&
|
|
||||||
i.member.roles.cache.has(Staff.id);
|
|
||||||
const collector = claimMessage.createMessageComponentCollector({ filter, time: 120000 });
|
const collector = claimMessage.createMessageComponentCollector({ filter, time: 120000 });
|
||||||
|
|
||||||
collector.on("collect", async (i) => {
|
collector.on('collect', async i => {
|
||||||
await ticketChannel.send({ content: `<@${i.user.id}> has claimed the ticket.` });
|
await ticketChannel.send({ content: `<@${i.user.id}> has claimed the ticket.` });
|
||||||
});
|
});
|
||||||
|
|
||||||
collector.on("end", async (collected) => {
|
collector.on('end', async collected => {
|
||||||
if (collected.size === 0) {
|
if (collected.size === 0) {
|
||||||
await claimMessage.delete();
|
await claimMessage.delete();
|
||||||
|
|
||||||
await claimChannel.send({
|
await claimChannel.send({
|
||||||
content: `Ticket is still unclaimed. \nCC: [<@&${Staff.id}> <@&${Admin.id}>]`,
|
content: `Ticket is still unclaimed. \nCC: [<@&${Staff.id}> <@&${Admin.id}]`,
|
||||||
embeds: [
|
embeds: [new EmbedBuilder().setDescription(`Ticket is still unclaimed: <#${ticketChannel.id}>`).setColor(supportbot.Embed.Colours.Warn)],
|
||||||
new EmbedBuilder()
|
|
||||||
.setDescription(`Ticket is still unclaimed: <#${ticketChannel.id}>`)
|
|
||||||
.setColor(supportbot.Embed.Colours.Warn),
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -157,27 +161,22 @@ async function assignTicketToUser(ticketChannel, Staff, Admin, interaction, atte
|
|||||||
}
|
}
|
||||||
|
|
||||||
const clockedInArray = Array.from(clockedInUsers);
|
const clockedInArray = Array.from(clockedInUsers);
|
||||||
const assignedUserId =
|
const assignedUserId = clockedInArray[Math.floor(Math.random() * clockedInArray.length)];
|
||||||
clockedInArray[Math.floor(Math.random() * clockedInArray.length)];
|
|
||||||
const assignedUser = await interaction.guild.members.fetch(assignedUserId);
|
const assignedUser = await interaction.guild.members.fetch(assignedUserId);
|
||||||
|
|
||||||
const claimEmbed = new EmbedBuilder()
|
const claimEmbed = new EmbedBuilder()
|
||||||
.setTitle(msgconfig.Ticket.ClaimTickets.ClaimTitle)
|
.setTitle(msgconfig.Ticket.ClaimTickets.ClaimTitle)
|
||||||
.setDescription(
|
.setDescription(msgconfig.Ticket.ClaimTickets.ClaimMessage.replace('%user%', interaction.user.id))
|
||||||
msgconfig.Ticket.ClaimTickets.ClaimMessage.replace("%user%", interaction.user.id)
|
|
||||||
)
|
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
const claimButton = new ButtonBuilder()
|
const claimButton = new ButtonBuilder()
|
||||||
.setCustomId(`claimticket-${ticketChannel.id}`)
|
.setCustomId(`claimticket-${ticketChannel.id}`)
|
||||||
.setLabel(supportbot.Ticket.ClaimTickets.ButtonTitle || "Claim Ticket")
|
.setLabel(supportbot.Ticket.ClaimTickets.ButtonTitle || 'Claim Ticket')
|
||||||
.setStyle(ButtonStyle.Primary);
|
.setStyle(ButtonStyle.Primary);
|
||||||
|
|
||||||
const row = new ActionRowBuilder().addComponents(claimButton);
|
const row = new ActionRowBuilder().addComponents(claimButton);
|
||||||
|
|
||||||
const claimChannel = await interaction.guild.channels.cache.get(
|
const claimChannel = await interaction.guild.channels.cache.get(supportbot.Ticket.ClaimTickets.Channel);
|
||||||
supportbot.Ticket.ClaimTickets.Channel
|
|
||||||
);
|
|
||||||
if (!claimChannel) {
|
if (!claimChannel) {
|
||||||
console.error("Claim channel not found");
|
console.error("Claim channel not found");
|
||||||
return null;
|
return null;
|
||||||
@@ -189,28 +188,21 @@ async function assignTicketToUser(ticketChannel, Staff, Admin, interaction, atte
|
|||||||
components: [row],
|
components: [row],
|
||||||
});
|
});
|
||||||
|
|
||||||
const filter = (i) =>
|
const filter = i => i.customId === `claimticket-${ticketChannel.id}` && i.user.id === assignedUserId;
|
||||||
i.customId === `claimticket-${ticketChannel.id}` && i.user.id === assignedUserId;
|
|
||||||
const collector = claimMessage.createMessageComponentCollector({ filter, time: 120000 });
|
const collector = claimMessage.createMessageComponentCollector({ filter, time: 120000 });
|
||||||
|
|
||||||
collector.on("collect", async (i) => {
|
collector.on('collect', async i => {
|
||||||
await ticketChannel
|
await ticketChannel.send({ content: `<@${assignedUserId}>` }).then(msg => setTimeout(() => msg.delete(), 5000));
|
||||||
.send({ content: `<@${assignedUserId}>` })
|
|
||||||
.then((msg) => setTimeout(() => msg.delete(), 5000));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
collector.on("end", async (collected) => {
|
collector.on('end', async collected => {
|
||||||
if (collected.size === 0) {
|
if (collected.size === 0) {
|
||||||
await claimMessage.delete();
|
await claimMessage.delete();
|
||||||
|
|
||||||
if (attempts >= 1) {
|
if (attempts >= 1) {
|
||||||
await claimChannel.send({
|
await claimChannel.send({
|
||||||
content: `No one claimed the ticket. Tagging roles: <@&${Staff.id}> <@&${Admin.id}>`,
|
content: `No one claimed the ticket. Tagging roles: <@&${Staff.id}> <@&${Admin.id}>`,
|
||||||
embeds: [
|
embeds: [new EmbedBuilder().setDescription(`Ticket is still unclaimed: <#${ticketChannel.id}>`).setColor(supportbot.Embed.Colours.Warn)],
|
||||||
new EmbedBuilder()
|
|
||||||
.setDescription(`Ticket is still unclaimed: <#${ticketChannel.id}>`)
|
|
||||||
.setColor(supportbot.Embed.Colours.Warn),
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const claimEmbed = new EmbedBuilder()
|
const claimEmbed = new EmbedBuilder()
|
||||||
@@ -231,24 +223,17 @@ async function assignTicketToUser(ticketChannel, Staff, Admin, interaction, atte
|
|||||||
components: [row],
|
components: [row],
|
||||||
});
|
});
|
||||||
|
|
||||||
const filter = (i) =>
|
const filter = i => i.customId === `claimticket-${ticketChannel.id}` && i.member.roles.cache.has(Staff.id);
|
||||||
i.customId === `claimticket-${ticketChannel.id}` &&
|
const collector = claimMessage.createMessageComponentCollector({ filter, time: 120000 });
|
||||||
i.member.roles.cache.has(Staff.id);
|
|
||||||
const collector = claimMessage.createMessageComponentCollector({
|
|
||||||
filter,
|
|
||||||
time: 120000,
|
|
||||||
});
|
|
||||||
|
|
||||||
collector.on("collect", async (i) => {
|
collector.on('collect', async i => {
|
||||||
console.log(`Ticket ${ticketChannel.id} claimed by user ${i.user.id}`);
|
console.log(`Ticket ${ticketChannel.id} claimed by user ${i.user.id}`);
|
||||||
await ticketChannel.member.add(i.user.id);
|
await ticketChannel.member.add(i.user.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
collector.on("end", async (collected) => {
|
collector.on('end', async collected => {
|
||||||
if (collected.size === 0) {
|
if (collected.size === 0) {
|
||||||
console.log(
|
console.log(`No one claimed the ticket (${ticketChannel.id}), notifying all staff`);
|
||||||
`No one claimed the ticket (${ticketChannel.id}), notifying all staff`
|
|
||||||
);
|
|
||||||
await claimMessage.delete();
|
await claimMessage.delete();
|
||||||
|
|
||||||
await claimChannel.send({
|
await claimChannel.send({
|
||||||
@@ -259,9 +244,7 @@ async function assignTicketToUser(ticketChannel, Staff, Admin, interaction, atte
|
|||||||
} else {
|
} else {
|
||||||
const ReassigningEmbed = new EmbedBuilder()
|
const ReassigningEmbed = new EmbedBuilder()
|
||||||
.setTitle(msgconfig.Ticket.ClaimTickets.ReassigningTitle)
|
.setTitle(msgconfig.Ticket.ClaimTickets.ReassigningTitle)
|
||||||
.setDescription(
|
.setDescription(msgconfig.Ticket.ClaimTickets.ReassigningMessage.replace('%user%', assignedUserId))
|
||||||
msgconfig.Ticket.ClaimTickets.ReassigningMessage.replace("%user%", assignedUserId)
|
|
||||||
)
|
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
await claimChannel.send({ embeds: [ReassigningEmbed], components: [] });
|
await claimChannel.send({ embeds: [ReassigningEmbed], components: [] });
|
||||||
@@ -273,6 +256,9 @@ async function assignTicketToUser(ticketChannel, Staff, Admin, interaction, atte
|
|||||||
return assignedUserId;
|
return assignedUserId;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error in assignTicketToUser function:", error);
|
console.error("Error in assignTicketToUser function:", error);
|
||||||
|
if (error instanceof CombinedError) {
|
||||||
|
console.error("CombinedError details:", error.errors);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,17 +283,16 @@ module.exports = new Command({
|
|||||||
if (await isBlacklisted(interaction.user.id)) {
|
if (await isBlacklisted(interaction.user.id)) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: msgconfig.Ticket.Blacklisted,
|
content: msgconfig.Ticket.Blacklisted,
|
||||||
flags: MessageFlags.Ephemeral
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let TicketReason = null;
|
let TicketReason = null;
|
||||||
if (supportbot.Ticket.TicketReason) {
|
if (supportbot.Ticket.TicketReason) {
|
||||||
TicketReason = interaction.reason || null;
|
TicketReason = interaction.reason || null; // Retrieve the reason from the interaction object
|
||||||
}
|
}
|
||||||
|
|
||||||
let TicketData = { tickets: db.getAllTickets() };
|
let TicketData = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
||||||
|
|
||||||
const { getRole, getChannel } = interaction.client;
|
const { getRole, getChannel } = interaction.client;
|
||||||
let User = interaction.guild.members.cache.get(interaction.user.id);
|
let User = interaction.guild.members.cache.get(interaction.user.id);
|
||||||
|
|
||||||
@@ -323,7 +308,7 @@ module.exports = new Command({
|
|||||||
color: supportbot.Embed.Colours.Warn,
|
color: supportbot.Embed.Colours.Warn,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
flags: MessageFlags.Ephemeral
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,7 +326,7 @@ module.exports = new Command({
|
|||||||
) {
|
) {
|
||||||
return await interaction.reply({
|
return await interaction.reply({
|
||||||
embeds: [TicketExists],
|
embeds: [TicketExists],
|
||||||
flags: MessageFlags.Ephemeral
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,7 +335,7 @@ module.exports = new Command({
|
|||||||
if (!Staff || !Admin)
|
if (!Staff || !Admin)
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "Some roles seem to be missing!\nPlease check for errors when starting the bot.",
|
content: "Some roles seem to be missing!\nPlease check for errors when starting the bot.",
|
||||||
flags: MessageFlags.Ephemeral
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
let ticketChannel;
|
let ticketChannel;
|
||||||
@@ -376,7 +361,7 @@ module.exports = new Command({
|
|||||||
if (!category) {
|
if (!category) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "The ticket category does not exist!",
|
content: "The ticket category does not exist!",
|
||||||
flags: MessageFlags.Ephemeral
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,6 +372,7 @@ module.exports = new Command({
|
|||||||
reason: 'support ticket',
|
reason: 'support ticket',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Move to secondary category if the primary one is full
|
||||||
if (category.children.size >= 50) {
|
if (category.children.size >= 50) {
|
||||||
const secondaryCategory = interaction.guild.channels.cache.find(
|
const secondaryCategory = interaction.guild.channels.cache.find(
|
||||||
(c) => c.name === supportbot.Ticket.TicketChannelsCategory2 || c.id === supportbot.Ticket.TicketChannelsCategory2
|
(c) => c.name === supportbot.Ticket.TicketChannelsCategory2 || c.id === supportbot.Ticket.TicketChannelsCategory2
|
||||||
@@ -397,12 +383,13 @@ module.exports = new Command({
|
|||||||
} else {
|
} else {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "The secondary ticket category does not exist!",
|
content: "The secondary ticket category does not exist!",
|
||||||
flags: MessageFlags.Ephemeral
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assign ticket to a user if claiming tickets is enabled
|
||||||
if (supportbot.Ticket.ClaimTickets.Enabled) {
|
if (supportbot.Ticket.ClaimTickets.Enabled) {
|
||||||
const assignedUserId = await assignTicketToUser(ticketChannel, Staff, Admin, interaction);
|
const assignedUserId = await assignTicketToUser(ticketChannel, Staff, Admin, interaction);
|
||||||
if (!assignedUserId) {
|
if (!assignedUserId) {
|
||||||
@@ -432,7 +419,16 @@ module.exports = new Command({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
db.addTicket({
|
// Ask questions to the user after the ticket is opened
|
||||||
|
if (supportbot.Ticket.Questions.Enabled) {
|
||||||
|
const questions = supportbot.Ticket.Questions.List || [];
|
||||||
|
if (questions.length > 0) {
|
||||||
|
await askTicketQuestions(ticketChannel, interaction, questions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save ticket data
|
||||||
|
TicketData.tickets.push({
|
||||||
id: ticketChannel.id,
|
id: ticketChannel.id,
|
||||||
name: ticketChannel.name,
|
name: ticketChannel.name,
|
||||||
user: interaction.user.id,
|
user: interaction.user.id,
|
||||||
@@ -443,8 +439,16 @@ module.exports = new Command({
|
|||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
claimedAt: null,
|
claimedAt: null,
|
||||||
});
|
});
|
||||||
TicketData.tickets = db.getAllTickets();
|
|
||||||
|
|
||||||
|
fs.writeFileSync(
|
||||||
|
"./Data/TicketData.json",
|
||||||
|
JSON.stringify(TicketData, null, 4),
|
||||||
|
(err) => {
|
||||||
|
if (err) console.error(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Notify the user that the ticket was created
|
||||||
const CreatedTicket = new EmbedBuilder()
|
const CreatedTicket = new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
msgconfig.Ticket.TicketCreatedAlert.replace(/%ticketauthor%/g, interaction.user.id)
|
msgconfig.Ticket.TicketCreatedAlert.replace(/%ticketauthor%/g, interaction.user.id)
|
||||||
@@ -453,8 +457,9 @@ module.exports = new Command({
|
|||||||
.replace(/%ticketreason%/g, TicketSubject)
|
.replace(/%ticketreason%/g, TicketSubject)
|
||||||
)
|
)
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
await interaction.reply({ embeds: [CreatedTicket], flags: MessageFlags.Ephemeral });
|
await interaction.reply({ embeds: [CreatedTicket], ephemeral: true });
|
||||||
|
|
||||||
|
// Create the ticket message
|
||||||
const TicketMessage = new EmbedBuilder()
|
const TicketMessage = new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor({
|
||||||
name: msgconfig.Ticket.TicketAuthorTitle.replace(/%ticketauthor%/g, interaction.user.id)
|
name: msgconfig.Ticket.TicketAuthorTitle.replace(/%ticketauthor%/g, interaction.user.id)
|
||||||
@@ -481,6 +486,7 @@ module.exports = new Command({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the control panel
|
||||||
const SelectMenus = new StringSelectMenuBuilder()
|
const SelectMenus = new StringSelectMenuBuilder()
|
||||||
.setCustomId("ticketcontrolpanel")
|
.setCustomId("ticketcontrolpanel")
|
||||||
.setPlaceholder("Ticket Control Panel")
|
.setPlaceholder("Ticket Control Panel")
|
||||||
@@ -536,13 +542,6 @@ module.exports = new Command({
|
|||||||
components: [row2],
|
components: [row2],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (supportbot.Ticket.Questions.Enabled) {
|
|
||||||
const questions = supportbot.Ticket.Questions.List || [];
|
|
||||||
|
|
||||||
if (questions.length > 0) {
|
|
||||||
await askTicketQuestions(ticketChannel, interaction, questions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error in run method:", error);
|
console.error("Error in run method:", error);
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
// ticketpanel.js
|
||||||
|
const fs = require("fs");
|
||||||
|
const {
|
||||||
|
EmbedBuilder,
|
||||||
|
ApplicationCommandType,
|
||||||
|
ActionRowBuilder,
|
||||||
|
ButtonBuilder,
|
||||||
|
} = require("discord.js");
|
||||||
|
const yaml = require("js-yaml");
|
||||||
|
|
||||||
|
const panelconfig = yaml.load(fs.readFileSync("./Configs/ticket-panel.yml", "utf8"));
|
||||||
|
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||||
|
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
||||||
|
|
||||||
|
const Command = require("../Structures/Command.js");
|
||||||
|
|
||||||
|
module.exports = new Command({
|
||||||
|
name: cmdconfig.TicketPanel.Command,
|
||||||
|
description: cmdconfig.TicketPanel.Description,
|
||||||
|
type: ApplicationCommandType.ChatInput,
|
||||||
|
options: [],
|
||||||
|
permissions: cmdconfig.TicketPanel.Permission,
|
||||||
|
|
||||||
|
async run(interaction) {
|
||||||
|
if (!panelconfig.Panel) {
|
||||||
|
console.log(
|
||||||
|
"\u001b[31m",
|
||||||
|
`[TICKET PANEL]`,
|
||||||
|
"\u001b[33m",
|
||||||
|
"Ticket Panel is not setup, You can set this in", `\u001b[31m`, '/Configs/ticket-panel.yml', `\n `,
|
||||||
|
);
|
||||||
|
return interaction.reply({
|
||||||
|
content: "Ticket Panel is not set up. Please configure it in `/Configs/ticket-panel.yml`.",
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const { getChannel } = interaction.client;
|
||||||
|
|
||||||
|
const channel = await getChannel(
|
||||||
|
supportbot.Ticket.TicketHome,
|
||||||
|
interaction.guild
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!channel) {
|
||||||
|
console.log(`[TICKET PANEL] ${channelName} channel not found. Please check your config file.`);
|
||||||
|
return interaction.reply({
|
||||||
|
content: `${channelName} channel not found. Please check your config file.`,
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const panelid = JSON.parse(fs.readFileSync("./Data/ticket-panel-id.json", "utf8"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
await channel.messages.fetch(panelid.TicketPanelID);
|
||||||
|
return interaction.reply({
|
||||||
|
content: "Ticket panel message already exists.",
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
let embed = new EmbedBuilder()
|
||||||
|
.setTitle(panelconfig.PanelTitle)
|
||||||
|
.setColor(panelconfig.PanelColour)
|
||||||
|
.setFooter({
|
||||||
|
text: supportbot.Embed.Footer,
|
||||||
|
iconURL: interaction.user.displayAvatarURL(),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (panelconfig.TicketPanel_Description) {
|
||||||
|
embed.setDescription(panelconfig.PanelMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (panelconfig.TicketPanel_Thumbnail) {
|
||||||
|
embed.setThumbnail(panelconfig.PanelThumbnail);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (panelconfig.TicketPanel_Image) {
|
||||||
|
embed.setImage(panelconfig.PanelImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
const createTicketButton = new ButtonBuilder()
|
||||||
|
.setCustomId("createticket")
|
||||||
|
.setLabel(panelconfig.Button.Text)
|
||||||
|
.setEmoji(panelconfig.Button.Emoji)
|
||||||
|
.setStyle(panelconfig.Button.Color);
|
||||||
|
|
||||||
|
let row = new ActionRowBuilder().addComponents(createTicketButton);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const message = await channel.send({
|
||||||
|
embeds: [embed],
|
||||||
|
components: [row],
|
||||||
|
});
|
||||||
|
|
||||||
|
let data = {
|
||||||
|
id: panelid.id,
|
||||||
|
TicketPanelID: message.id,
|
||||||
|
};
|
||||||
|
|
||||||
|
fs.writeFileSync(
|
||||||
|
"./Data/ticket-panel-id.json",
|
||||||
|
JSON.stringify(data),
|
||||||
|
"utf8"
|
||||||
|
);
|
||||||
|
|
||||||
|
return interaction.reply({
|
||||||
|
content: "Ticket panel message has been sent!",
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Error sending message:", e);
|
||||||
|
return interaction.reply({
|
||||||
|
content: "An error occurred while sending the ticket panel message.",
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -18,7 +18,7 @@ const msgconfig = yaml.load(
|
|||||||
fs.readFileSync("./Configs/messages.yml", "utf8")
|
fs.readFileSync("./Configs/messages.yml", "utf8")
|
||||||
)
|
)
|
||||||
|
|
||||||
const Command = require("../../Structures/Command.js");
|
const Command = require("../Structures/Command.js");
|
||||||
const translate = require("@vitalets/google-translate-api");
|
const translate = require("@vitalets/google-translate-api");
|
||||||
|
|
||||||
module.exports = new Command({
|
module.exports = new Command({
|
||||||
@@ -89,7 +89,7 @@ module.exports = new Command({
|
|||||||
"Click the title to see which 2 letter language codes are valid."
|
"Click the title to see which 2 letter language codes are valid."
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -73,12 +73,6 @@ Suggestion:
|
|||||||
Permission: ["SendMessages"]
|
Permission: ["SendMessages"]
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
SuggestionAdmin:
|
|
||||||
Command: "suggestadmin"
|
|
||||||
Description: "Update a suggestion’s status."
|
|
||||||
Permission: ['SendMessages']
|
|
||||||
# Disable "Suggestion" to disable this command.
|
|
||||||
|
|
||||||
Embed:
|
Embed:
|
||||||
Command: "embed"
|
Command: "embed"
|
||||||
Description: "Build a discord embed."
|
Description: "Build a discord embed."
|
||||||
|
|||||||
+7
-55
@@ -22,74 +22,27 @@ Info:
|
|||||||
Description: "SupportBot is an open-sourced support system for discord. It's completely free to use with high amounts of customization to match your own brand."
|
Description: "SupportBot is an open-sourced support system for discord. It's completely free to use with high amounts of customization to match your own brand."
|
||||||
Button: "Visit Site"
|
Button: "Visit Site"
|
||||||
URL: "https://docs.emeraldsrv.com"
|
URL: "https://docs.emeraldsrv.com"
|
||||||
Colour: "#45b463"
|
Colour: "#f74343"
|
||||||
|
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
# Welcome/Leave Messages
|
# Welcome/Leave Messages
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
|
|
||||||
Welcome:
|
Welcome:
|
||||||
Enabled: true
|
|
||||||
LayoutStyle: "modern"
|
|
||||||
# Available Layout Styles
|
|
||||||
# "modern" - For the new Discord v2 components
|
|
||||||
# "classic" - Use the classic Discord look.
|
|
||||||
|
|
||||||
Embed:
|
Embed:
|
||||||
Colour: "#45b463"
|
Colour: "#f74343"
|
||||||
Title: "Welcome to ServerName"
|
Title: "Welcome to ServerName"
|
||||||
Message: ":smile: %joined_user% has just landed!\n\n🔨 **Server Rules:** <#1202667199853232129>"
|
Message: ":smile: %joined_user% has just landed!"
|
||||||
Icon:
|
Thumbnail: "BOT"
|
||||||
Mode: "USER" # USER | BOT | CUSTOM
|
|
||||||
CustomURL: "https://example.com/custom.png"
|
|
||||||
Image:
|
|
||||||
Enabled: false
|
|
||||||
URL: "https://example.com/banner.png"
|
|
||||||
Buttons:
|
|
||||||
Enabled: true
|
|
||||||
List:
|
|
||||||
- label: "BuiltByBit"
|
|
||||||
style: "Link"
|
|
||||||
url: "https://your-website.com/how-to-play-java"
|
|
||||||
emoji: "⌨️"
|
|
||||||
- label: "GitHub"
|
|
||||||
style: "Link"
|
|
||||||
url: "https://your-website.com/how-to-play-bedrock"
|
|
||||||
emoji: "👾"
|
|
||||||
- label: "Tebex"
|
|
||||||
style: "Link"
|
|
||||||
url: "https://your-store.tebex.io/"
|
|
||||||
emoji: "🛒"
|
|
||||||
|
|
||||||
Modern:
|
ImageEnabled: false
|
||||||
Colour: "#45b463"
|
ImageURL: "https://animagelink.png/"
|
||||||
Title: "**Welcome to ServerName**"
|
|
||||||
Body: ":smile: %joined_user% has just landed!\n\n🔨 **Server Rules:** <#1202667199853232129>"
|
|
||||||
Icon:
|
|
||||||
Mode: "BOT" # USER | BOT | CUSTOM
|
|
||||||
CustomURL: "https://example.com/custom-icon.png"
|
|
||||||
Image:
|
|
||||||
Enabled: false
|
|
||||||
URL: "https://example.com/banner.png"
|
|
||||||
Buttons:
|
|
||||||
- label: "BuiltByBit"
|
|
||||||
style: "Link"
|
|
||||||
url: "https://your-website.com/how-to-play-java"
|
|
||||||
emoji: "⌨️"
|
|
||||||
- label: "GitHub"
|
|
||||||
style: "Link"
|
|
||||||
url: "https://your-website.com/how-to-play-bedrock"
|
|
||||||
emoji: "👾"
|
|
||||||
- label: "Tebex"
|
|
||||||
style: "Link"
|
|
||||||
url: "https://your-store.tebex.io/"
|
|
||||||
emoji: "🛒"
|
|
||||||
|
|
||||||
Leave:
|
Leave:
|
||||||
Embed:
|
Embed:
|
||||||
Colour: "#f74343"
|
Colour: "#f74343"
|
||||||
Title: "Goodbye!"
|
Title: "Goodbye!"
|
||||||
Message: ":slight_frown: %left_user% has recently dropped out!"
|
Message: ":slight_frown: %joined_user% has recently dropped out!"
|
||||||
Thumbnail: "BOT"
|
Thumbnail: "BOT"
|
||||||
|
|
||||||
ImageEnabled: false
|
ImageEnabled: false
|
||||||
@@ -320,4 +273,3 @@ Error:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+25
-34
@@ -8,12 +8,12 @@
|
|||||||
# Installed with MIT License
|
# Installed with MIT License
|
||||||
#
|
#
|
||||||
# Discord Support: https://discord.gg/emeraldsrv
|
# Discord Support: https://discord.gg/emeraldsrv
|
||||||
# Official Documentation: https://docs.emeraldsrv.dev
|
# Official Documentation: https://docs.emeraldsrv.com
|
||||||
# Addons Marketplace: https://community.emeraldsrv.dev
|
# Addons Marketplace: https://community.emeraldsrv.com
|
||||||
#
|
#
|
||||||
# SupportBot Configuration (supportbot.yml)
|
# SupportBot Configuration (supportbot.yml)
|
||||||
|
|
||||||
SupportBot_Version: "v8.4-DEV-2"
|
SupportBot_Version: "v8.3"
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# General
|
# General
|
||||||
@@ -21,7 +21,7 @@ SupportBot_Version: "v8.4-DEV-2"
|
|||||||
|
|
||||||
General:
|
General:
|
||||||
Name: "SupportBot"
|
Name: "SupportBot"
|
||||||
Token: ""
|
Token: "BOT_TOKEN"
|
||||||
|
|
||||||
Addons:
|
Addons:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
@@ -66,12 +66,12 @@ Embed:
|
|||||||
Roles:
|
Roles:
|
||||||
AutoRole:
|
AutoRole:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Role: "1202669457751801917"
|
Role: "ROLE_ID"
|
||||||
|
|
||||||
StaffMember:
|
StaffMember:
|
||||||
Staff: "996420644373811371"
|
Staff: "ROLE_ID"
|
||||||
Admin: "996419960442208326"
|
Admin: "ROLE_ID"
|
||||||
Moderator: "996420644373811371"
|
Moderator: "ROLE_ID"
|
||||||
|
|
||||||
Mod:
|
Mod:
|
||||||
AllowSupportStaff: false
|
AllowSupportStaff: false
|
||||||
@@ -84,21 +84,18 @@ Roles:
|
|||||||
|
|
||||||
Welcome:
|
Welcome:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Channel: "1295788797065166869"
|
Channel: "JOIN_CHANNEL_ID"
|
||||||
|
|
||||||
Leave:
|
Leave:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Channel: "1295788797065166869"
|
Channel: "JOIN_CHANNEL_ID"
|
||||||
|
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
# Suggestions
|
# Suggestions
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
|
|
||||||
Suggestions:
|
Suggestions:
|
||||||
Mode: "Channel" # Channel or Forum
|
Channel: "SUGGESTIONS_CHANNEL_ID"
|
||||||
ForumChannel: "1402655496477081671"
|
|
||||||
Channel: "1295788900094316706"
|
|
||||||
|
|
||||||
UpvoteEmoji: "✅"
|
UpvoteEmoji: "✅"
|
||||||
DownvoteEmoji: "❌"
|
DownvoteEmoji: "❌"
|
||||||
|
|
||||||
@@ -129,37 +126,31 @@ Suggestions:
|
|||||||
# 3 - Green
|
# 3 - Green
|
||||||
# 4 - Red
|
# 4 - Red
|
||||||
|
|
||||||
Tags:
|
|
||||||
Created: "1418937323118137435"
|
|
||||||
Considering: "1418937237156139130"
|
|
||||||
Solved: "1418937168029679697"
|
|
||||||
Denied: "1418937185469464647"
|
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# Tickets
|
# Tickets
|
||||||
# -------------------------
|
# -------------------------
|
||||||
|
|
||||||
VoiceTickets:
|
VoiceTickets:
|
||||||
Name: "%username%'s VC"
|
Name: "%username%'s VC"
|
||||||
Category: "1419062819688550460"
|
Category: "VOICEE_CATEGORY_ID"
|
||||||
|
|
||||||
Ticket:
|
Ticket:
|
||||||
TicketType: "threads"
|
TicketType: "channels"
|
||||||
|
|
||||||
# Available TicketTypes:
|
# Available TicketTypes:
|
||||||
# channels - Tickets will be created as channels in the TicketChannelsCategory
|
# channels - Tickets will be created as channels in the TicketChannelsCategory
|
||||||
# threads - Tickets will be created as threads through the "TicketHome" channel.
|
# threads - Tickets will be created as threads through the "TicketHome" channel.
|
||||||
|
|
||||||
TicketHome: "1295784943204700171"
|
TicketHome: "TICKETHOME_CHANNEL_ID"
|
||||||
|
|
||||||
# What is TicketHome?
|
# What is TicketHome?
|
||||||
# - Channel where the Ticket creation panel is sent.
|
# - Channel where the Ticket creation panel is sent.
|
||||||
# - Channel where ticket threads are made. (only if ticket threads is enabled above.)
|
# - Channel where ticket threads are made. (only if ticket threads is enabled above.)
|
||||||
|
|
||||||
# For TicketType: channels
|
# For TicketType: channels
|
||||||
TicketChannelsCategory: "1418988408193155112"
|
TicketChannelsCategory: "TICKETCHANNEL_CATEGORY_ID"
|
||||||
TicketChannelsCategory2: "1418988456167870615" # This will be used if the first category has reached the max channel limit.
|
TicketChannelsCategory2: "TICKETCHANNEL_BACKUP_CATEGORY_ID" # This will be used if the first category has reached the max channel limit.
|
||||||
TicketArchiveCategory: "1418988434600759348"
|
TicketArchiveCategory: "ARCHIVE_CATEGORY_ID"
|
||||||
# ---
|
# ---
|
||||||
|
|
||||||
Channel: "ticket-" # The prefix for ticket channel names
|
Channel: "ticket-" # The prefix for ticket channel names
|
||||||
@@ -198,7 +189,7 @@ Ticket:
|
|||||||
|
|
||||||
ClaimTickets:
|
ClaimTickets:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Channel: "1295789389619793961"
|
Channel: "CLAIM_TICKETS_CHANNEL_ID"
|
||||||
# Channel where the ticket assignments are sent for staff to claim.
|
# Channel where the ticket assignments are sent for staff to claim.
|
||||||
|
|
||||||
ClaimAcceptTime: 120000
|
ClaimAcceptTime: 120000
|
||||||
@@ -220,8 +211,8 @@ Ticket:
|
|||||||
# 4 - Red
|
# 4 - Red
|
||||||
|
|
||||||
ReviewSystem:
|
ReviewSystem:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
Channel: "1304480728884445225"
|
Channel: "REVIEW_CHANNEL_ID"
|
||||||
UseModal: true
|
UseModal: true
|
||||||
|
|
||||||
Questions:
|
Questions:
|
||||||
@@ -232,9 +223,9 @@ Ticket:
|
|||||||
- "Have you tried resolving the issue yourself?"
|
- "Have you tried resolving the issue yourself?"
|
||||||
|
|
||||||
Log:
|
Log:
|
||||||
TicketDataLog: "1339271338761650290"
|
TicketDataLog: "TICKET_DATA_LOG_ID"
|
||||||
TickeDataTitle: "Ticket Data"
|
TickeDataTitle: "Ticket Data"
|
||||||
TicketBlacklistLog: "1339271338761650290"
|
TicketBlacklistLog: "TICKET_BLACKLIST_LOG_ID"
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# Buttons
|
# Buttons
|
||||||
@@ -287,12 +278,12 @@ SelectMenus:
|
|||||||
# -------------------------
|
# -------------------------
|
||||||
|
|
||||||
MessageDelete:
|
MessageDelete:
|
||||||
Channel: "1202671982932402246"
|
Channel: "MESSAGE_DELETE_CHANNEL_ID""
|
||||||
Colour: "#d92525"
|
Colour: "#d92525"
|
||||||
|
|
||||||
MessageUpdate:
|
MessageUpdate:
|
||||||
Channel: "1202671982932402246"
|
Channel: "MESSAGE_UPDATE_CHANNEL_ID"
|
||||||
Colour: "#f2a024"
|
Colour: "#f2a024"
|
||||||
|
|
||||||
Translate:
|
Translate:
|
||||||
TranslateLog: "1202671982932402246"
|
TranslateLog: "TRANSLATE_LOG_ID"
|
||||||
@@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
Panel: true
|
Panel: true
|
||||||
|
|
||||||
LayoutStyle: modern
|
|
||||||
|
|
||||||
# ----------------------------------------
|
# ----------------------------------------
|
||||||
# Ticket Panel Message Configuration #2b2d31
|
# Ticket Panel Message Configuration #2b2d31
|
||||||
# ----------------------------------------
|
# ----------------------------------------
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"tickets": [
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"bio": "",
|
||||||
|
"timezone": "",
|
||||||
|
"clockedIn": false
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"id": 0,
|
||||||
|
"TicketPanelID": "000000000000000"
|
||||||
|
}
|
||||||
+33
-128
@@ -1,151 +1,56 @@
|
|||||||
const {
|
|
||||||
EmbedBuilder,
|
const Discord = require('discord.js');
|
||||||
ActionRowBuilder,
|
|
||||||
ButtonBuilder,
|
|
||||||
ButtonStyle,
|
|
||||||
MessageFlags,
|
|
||||||
ContainerBuilder,
|
|
||||||
TextDisplayBuilder,
|
|
||||||
SectionBuilder,
|
|
||||||
ThumbnailBuilder,
|
|
||||||
AttachmentBuilder
|
|
||||||
} = require("discord.js");
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const yaml = require("js-yaml");
|
|
||||||
const Event = require("../Structures/Event.js");
|
const Event = require("../Structures/Event.js");
|
||||||
|
const yaml = require("js-yaml");
|
||||||
|
|
||||||
const supportbot = yaml.load(
|
const supportbot = yaml.load(
|
||||||
fs.readFileSync("./Configs/supportbot.yml", "utf8")
|
fs.readFileSync("./Configs/supportbot.yml", "utf8")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const cmdconfig = yaml.load(
|
||||||
|
fs.readFileSync("./Configs/commands.yml", "utf8")
|
||||||
|
);
|
||||||
|
|
||||||
const msgconfig = yaml.load(
|
const msgconfig = yaml.load(
|
||||||
fs.readFileSync("./Configs/messages.yml", "utf8")
|
fs.readFileSync("./Configs/messages.yml", "utf8")
|
||||||
);
|
);
|
||||||
|
|
||||||
function getWelcomeThumbnail(client, member, iconCfg) {
|
module.exports = new Event("guildMemberAdd", async (client, member, interaction, guild) => {
|
||||||
switch ((iconCfg?.Mode || "").toUpperCase()) {
|
|
||||||
case "USER":
|
|
||||||
return member.user.displayAvatarURL();
|
|
||||||
case "BOT":
|
|
||||||
return client.user.displayAvatarURL();
|
|
||||||
case "CUSTOM":
|
|
||||||
return iconCfg.CustomURL;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildModernComponents(client, member) {
|
if (supportbot.Welcome.Enabled) {
|
||||||
const container = new ContainerBuilder().setAccentColor(
|
const WelcomeChannel = member.guild.channels.cache.get(supportbot.Welcome.Channel) ||
|
||||||
parseInt(msgconfig.Welcome.Modern.Colour.replace("#", ""), 16)
|
member.guild.channels.cache.find(channel => channel.name === supportbot.Welcome.Channel);
|
||||||
);
|
|
||||||
|
|
||||||
const section = new SectionBuilder().addTextDisplayComponents(
|
const WelcomeEmbed = new Discord.EmbedBuilder()
|
||||||
new TextDisplayBuilder().setContent(
|
|
||||||
msgconfig.Welcome.Modern.Title.replace(/%joined_user%/g, member.user)
|
|
||||||
),
|
|
||||||
new TextDisplayBuilder().setContent(
|
|
||||||
msgconfig.Welcome.Modern.Body.replace(/%joined_user%/g, member.user)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
const thumbUrl = getWelcomeThumbnail(client, member, msgconfig.Welcome.Modern.Icon);
|
|
||||||
if (thumbUrl) {
|
|
||||||
section.setThumbnailAccessory(
|
|
||||||
new ThumbnailBuilder()
|
|
||||||
.setURL(thumbUrl)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
container.addSectionComponents(section);
|
|
||||||
|
|
||||||
if (msgconfig.Welcome.Modern.Image?.Enabled && msgconfig.Welcome.Modern.Image.URL) {
|
|
||||||
container.addTextDisplayComponents(
|
|
||||||
new TextDisplayBuilder().setContent(
|
|
||||||
``
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(msgconfig.Welcome.Modern.Buttons)) {
|
|
||||||
const row = new ActionRowBuilder();
|
|
||||||
msgconfig.Welcome.Modern.Buttons.slice(0, 5).forEach(b => {
|
|
||||||
const btn = new ButtonBuilder()
|
|
||||||
.setLabel(b.label)
|
|
||||||
.setStyle(ButtonStyle[b.style])
|
|
||||||
.setEmoji(b.emoji || null);
|
|
||||||
if (b.style === "Link") btn.setURL(b.url);
|
|
||||||
else if (b.customId) btn.setCustomId(b.customId);
|
|
||||||
row.addComponents(btn);
|
|
||||||
});
|
|
||||||
|
|
||||||
container.addActionRowComponents(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
return [container];
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = new Event("guildMemberAdd", async (client, member) => {
|
|
||||||
if (!supportbot.Welcome.Enabled) return;
|
|
||||||
|
|
||||||
const WelcomeChannel =
|
|
||||||
member.guild.channels.cache.get(supportbot.Welcome.Channel) ||
|
|
||||||
member.guild.channels.cache.find(c => c.name === supportbot.Welcome.Channel);
|
|
||||||
if (!WelcomeChannel) return;
|
|
||||||
|
|
||||||
const style = (msgconfig.Welcome.LayoutStyle || "classic").toLowerCase();
|
|
||||||
|
|
||||||
if (style === "classic") {
|
|
||||||
const WelcomeEmbed = new EmbedBuilder()
|
|
||||||
.setColor(msgconfig.Welcome.Embed.Colour)
|
.setColor(msgconfig.Welcome.Embed.Colour)
|
||||||
.setTitle(msgconfig.Welcome.Embed.Title || null)
|
.setTitle(msgconfig.Welcome.Embed.Title)
|
||||||
.setDescription(
|
.setDescription(msgconfig.Welcome.Embed.Message.replace(/%joined_user%/g, member.user))
|
||||||
msgconfig.Welcome.Embed.Message.replace(/%joined_user%/g, member.user)
|
|
||||||
)
|
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
const thumb = getWelcomeThumbnail(client, member, msgconfig.Welcome.Embed.Icon);
|
if (msgconfig.Welcome.Embed.Thumbnail === "BOT") {
|
||||||
if (thumb) WelcomeEmbed.setThumbnail(thumb);
|
WelcomeEmbed.setThumbnail(client.user.displayAvatarURL())
|
||||||
|
} else if (msgconfig.Welcome.Embed.Thumbnail === "USER") {
|
||||||
if (msgconfig.Welcome.Embed.Image?.Enabled && msgconfig.Welcome.Embed.Image.URL) {
|
WelcomeEmbed.setThumbnail(member.user.displayAvatarURL())
|
||||||
WelcomeEmbed.setImage(msgconfig.Welcome.Embed.Image.URL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const components = [];
|
if (msgconfig.Welcome.Embed.ImageEnabled) {
|
||||||
if (
|
WelcomeEmbed.setImage(msgconfig.Welcome.Embed.ImageURL)
|
||||||
msgconfig.Welcome.Embed.Buttons?.Enabled &&
|
|
||||||
Array.isArray(msgconfig.Welcome.Embed.Buttons.List)
|
|
||||||
) {
|
|
||||||
const row = new ActionRowBuilder();
|
|
||||||
msgconfig.Welcome.Embed.Buttons.List.slice(0, 5).forEach(b => {
|
|
||||||
const btn = new ButtonBuilder()
|
|
||||||
.setLabel(b.label)
|
|
||||||
.setStyle(ButtonStyle[b.style])
|
|
||||||
.setEmoji(b.emoji || null);
|
|
||||||
if (b.style === "Link") btn.setURL(b.url);
|
|
||||||
else if (b.customId) btn.setCustomId(b.customId);
|
|
||||||
row.addComponents(btn);
|
|
||||||
});
|
|
||||||
components.push(row);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await WelcomeChannel.send({ embeds: [WelcomeEmbed], components });
|
if (WelcomeChannel) {
|
||||||
} else if (style === "modern") {
|
WelcomeChannel.send({ embeds: [WelcomeEmbed] });
|
||||||
const components = buildModernComponents(client, member);
|
|
||||||
if (components.length > 0) {
|
|
||||||
await WelcomeChannel.send({
|
|
||||||
components,
|
|
||||||
flags: MessageFlags.IsComponentsV2
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (supportbot.Roles.AutoRole.Enabled) {
|
||||||
|
const role = member.guild.roles.cache.get(supportbot.Roles.AutoRole.Role) ||
|
||||||
|
member.guild.roles.cache.find(role => role.name === supportbot.Roles.AutoRole.Role);
|
||||||
|
if (role) {
|
||||||
|
member.roles.add(role);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`\u001b[32m`, `[+]`, `\u001b[33m`, `${member.user.username} joined the server!`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supportbot.Roles.AutoRole.Enabled) {
|
|
||||||
const role =
|
|
||||||
member.guild.roles.cache.get(supportbot.Roles.AutoRole.Role) ||
|
|
||||||
member.guild.roles.cache.find(r => r.name === supportbot.Roles.AutoRole.Role);
|
|
||||||
if (role) await member.roles.add(role);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("\u001b[32m", "[+]", "\u001b[33m", `${member.user.username} joined the server!`);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
+38
-28
@@ -1,40 +1,50 @@
|
|||||||
const { EmbedBuilder } = require("discord.js");
|
|
||||||
|
const Discord = require('discord.js');
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const yaml = require("js-yaml");
|
|
||||||
const Event = require("../Structures/Event.js");
|
const Event = require("../Structures/Event.js");
|
||||||
|
const yaml = require("js-yaml");
|
||||||
|
|
||||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
const supportbot = yaml.load(
|
||||||
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
fs.readFileSync("./Configs/supportbot.yml", "utf8")
|
||||||
|
);
|
||||||
|
|
||||||
module.exports = new Event("guildMemberRemove", async (client, member) => {
|
const cmdconfig = yaml.load(
|
||||||
|
fs.readFileSync("./Configs/commands.yml", "utf8")
|
||||||
|
);
|
||||||
|
|
||||||
if (!supportbot.Leave || !supportbot.Leave.Enabled) return;
|
const msgconfig = yaml.load(
|
||||||
|
fs.readFileSync("./Configs/messages.yml", "utf8")
|
||||||
|
);
|
||||||
|
|
||||||
const leaveChannel =
|
module.exports = new Event("guildMemberRemove", async (client, member, interaction, guild) => {
|
||||||
member.guild.channels.cache.get(supportbot.Leave.Channel) ||
|
|
||||||
member.guild.channels.cache.find(c => c.name === supportbot.Leave.Channel);
|
|
||||||
|
|
||||||
if (!leaveChannel) return;
|
if (supportbot.Leave.Enabled) {
|
||||||
|
const LeaveChannel = member.guild.channels.cache.get(supportbot.Leave.Channel) ||
|
||||||
|
member.guild.channels.cache.find(channel => channel.name === supportbot.Leave.Channel);
|
||||||
|
|
||||||
const leaveEmbed = new EmbedBuilder()
|
const LeaveEmbed = new Discord.EmbedBuilder()
|
||||||
.setColor(msgconfig.Leave.Embed.Colour)
|
.setColor(msgconfig.Leave.Embed.Colour)
|
||||||
.setTitle(msgconfig.Leave.Embed.Title)
|
.setTitle(msgconfig.Leave.Embed.Title)
|
||||||
.setDescription(
|
.setDescription(msgconfig.Leave.Embed.Message.replace(/%left_user%/g, member.user))
|
||||||
msgconfig.Leave.Embed.Message.replace(/%left_user%/g, member.user.toString())
|
.setTimestamp();
|
||||||
)
|
|
||||||
.setTimestamp();
|
|
||||||
|
|
||||||
if (msgconfig.Leave.Embed.Thumbnail === "BOT") {
|
if (msgconfig.Leave.Embed.Thumbnail === "BOT") {
|
||||||
leaveEmbed.setThumbnail(client.user.displayAvatarURL());
|
LeaveEmbed.setThumbnail(client.user.displayAvatarURL());
|
||||||
} else if (msgconfig.Leave.Embed.Thumbnail === "USER") {
|
} else if (msgconfig.Leave.Embed.Thumbnail === "USER") {
|
||||||
leaveEmbed.setThumbnail(member.user.displayAvatarURL());
|
LeaveEmbed.setThumbnail(member.user.displayAvatarURL());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msgconfig.Leave.Embed.ImageEnabled) {
|
||||||
|
LeaveEmbed.setImage(msgconfig.Leave.Embed.ImageURL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LeaveChannel) {
|
||||||
|
LeaveChannel.send({
|
||||||
|
embeds: [LeaveEmbed]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`\u001b[31m`, `[-]`, `\u001b[33m`, `${member.user.username} left the server!`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msgconfig.Leave.Embed.ImageEnabled) {
|
|
||||||
leaveEmbed.setImage(msgconfig.Leave.Embed.ImageURL);
|
|
||||||
}
|
|
||||||
|
|
||||||
await leaveChannel.send({ embeds: [leaveEmbed] });
|
|
||||||
|
|
||||||
console.log(`[-] ${member.user.tag} left the server`);
|
|
||||||
});
|
});
|
||||||
+203
-105
@@ -7,7 +7,13 @@ const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
|||||||
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
||||||
|
|
||||||
const Event = require("../Structures/Event.js");
|
const Event = require("../Structures/Event.js");
|
||||||
const db = require("../Structures/Database.js");
|
|
||||||
|
let suggestions;
|
||||||
|
try {
|
||||||
|
suggestions = require("../Data/SuggestionData.json");
|
||||||
|
} catch (error) {
|
||||||
|
suggestions = {};
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = new Event("interactionCreate", async (client, interaction) => {
|
module.exports = new Event("interactionCreate", async (client, interaction) => {
|
||||||
|
|
||||||
@@ -25,7 +31,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
if (!command)
|
if (!command)
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
embeds: [NotValid],
|
embeds: [NotValid],
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const permission = interaction.member.permissions.has(command.permissions);
|
const permission = interaction.member.permissions.has(command.permissions);
|
||||||
@@ -39,7 +45,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
if (!permission)
|
if (!permission)
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
embeds: [ValidPerms],
|
embeds: [ValidPerms],
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -66,7 +72,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
console.error("Error executing command:", error);
|
console.error("Error executing command:", error);
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content: "An error occurred while executing the command.",
|
content: "An error occurred while executing the command.",
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,7 +83,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
interaction.customId = `createticket-${reason}`;
|
interaction.customId = `createticket-${reason}`;
|
||||||
const cmd = client.commands.get(cmdconfig.OpenTicket.Command);
|
const cmd = client.commands.get(cmdconfig.OpenTicket.Command);
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
interaction.reason = reason;
|
interaction.reason = reason; // Attach the reason to the interaction object
|
||||||
await cmd.run(interaction);
|
await cmd.run(interaction);
|
||||||
} else {
|
} else {
|
||||||
console.error("Command not found.");
|
console.error("Command not found.");
|
||||||
@@ -87,37 +93,43 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
|
|
||||||
if (interaction.customId === "renameTicketModal") {
|
if (interaction.customId === "renameTicketModal") {
|
||||||
const newTicketName = interaction.fields.getTextInputValue("renameTicket");
|
const newTicketName = interaction.fields.getTextInputValue("renameTicket");
|
||||||
|
|
||||||
|
// Fixing the ticketChannelId extraction and lookup
|
||||||
const ticketChannelId = interaction.channel.id;
|
const ticketChannelId = interaction.channel.id;
|
||||||
|
|
||||||
let ticketChannel;
|
let ticketChannel;
|
||||||
if (supportbot.Ticket.TicketType === "threads") {
|
if (supportbot.Ticket.TicketType === "threads") {
|
||||||
ticketChannel = interaction.guild.channels.cache.get(ticketChannelId);
|
ticketChannel = interaction.guild.channels.cache.get(ticketChannelId);
|
||||||
} else if (supportbot.Ticket.TicketType === "channels") {
|
} else if (supportbot.Ticket.TicketType === "channels") {
|
||||||
ticketChannel = interaction.guild.channels.cache.get(ticketChannelId);
|
ticketChannel = interaction.guild.channels.cache.get(ticketChannelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ticketChannel) {
|
if (!ticketChannel) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "Ticket channel not found.",
|
content: "Ticket channel not found.",
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ticketChannel.setName(newTicketName);
|
await ticketChannel.setName(newTicketName);
|
||||||
|
|
||||||
const renamedsuccess = new Discord.EmbedBuilder()
|
const renamedsuccess = new Discord.EmbedBuilder()
|
||||||
.setDescription(msgconfig.Ticket.RenamedSuccess)
|
.setDescription(msgconfig.Ticket.RenamedSuccess)
|
||||||
.setColor(supportbot.Embed.Colours.Success);
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
embeds: [renamedsuccess],
|
embeds: [renamedsuccess],
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error renaming the ticket:", error);
|
console.error("Error renaming the ticket:", error);
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "There was an error renaming the ticket.",
|
content: "There was an error renaming the ticket.",
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interaction.isStringSelectMenu()) {
|
if (interaction.isStringSelectMenu()) {
|
||||||
if (interaction.customId === "ticketcontrolpanel") {
|
if (interaction.customId === "ticketcontrolpanel") {
|
||||||
const selectedOption = interaction.values[0];
|
const selectedOption = interaction.values[0];
|
||||||
@@ -134,107 +146,137 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "supportvc":
|
case "supportvc":
|
||||||
const ticketInfo = db.getTicket(interaction.channel.id);
|
const ticketData = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
||||||
if (!ticketInfo) {
|
const ticketInfo = ticketData.tickets.find(t => t.id === interaction.channel.id);
|
||||||
return interaction.reply({
|
|
||||||
content: "⚠️ This channel isn’t a valid ticket.",
|
if (ticketInfo) {
|
||||||
flags: Discord.MessageFlags.Ephemeral
|
const user = interaction.guild.members.cache.get(ticketInfo.user) || ticketInfo.user;
|
||||||
|
const claimedBy = interaction.guild.members.cache.get(ticketInfo.claimedBy) || ticketInfo.claimedBy;
|
||||||
|
const Admin = await interaction.guild.roles.fetch(supportbot.Roles.StaffMember.Admin);
|
||||||
|
const Staff = await interaction.guild.roles.fetch(supportbot.Roles.StaffMember.Staff);
|
||||||
|
|
||||||
|
const VCcategory = interaction.guild.channels.cache.find(
|
||||||
|
(c) => c.name === supportbot.VoiceTickets.Category || c.id === supportbot.VoiceTickets.Category
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!VCcategory) {
|
||||||
|
return interaction.reply({
|
||||||
|
content: "The Support VC category does not exist!",
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let username = user ? user.user.username : "Unknown User";
|
||||||
|
|
||||||
|
let SupportVoice = await interaction.guild.channels.create({
|
||||||
|
name: supportbot.VoiceTickets.Name.replace(/%username%/g, username),
|
||||||
|
type: Discord.ChannelType.GuildVoice,
|
||||||
|
parent: VCcategory,
|
||||||
|
permissionOverwrites: [
|
||||||
|
{
|
||||||
|
id: user,
|
||||||
|
allow: [
|
||||||
|
Discord.PermissionsBitField.Flags.Connect,
|
||||||
|
Discord.PermissionsBitField.Flags.Speak,
|
||||||
|
Discord.PermissionsBitField.Flags.ViewChannel,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: Staff,
|
||||||
|
allow: [
|
||||||
|
Discord.PermissionsBitField.Flags.Connect,
|
||||||
|
Discord.PermissionsBitField.Flags.Speak,
|
||||||
|
Discord.PermissionsBitField.Flags.ViewChannel,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: Admin,
|
||||||
|
allow: [
|
||||||
|
Discord.PermissionsBitField.Flags.Connect,
|
||||||
|
Discord.PermissionsBitField.Flags.Speak,
|
||||||
|
Discord.PermissionsBitField.Flags.ViewChannel,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: interaction.guild.id,
|
||||||
|
deny: [Discord.PermissionsBitField.Flags.ViewChannel],
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
const user = interaction.guild.members.cache.get(ticketInfo.user_id) || ticketInfo.user_id;
|
ticketInfo.voiceChannelId = SupportVoice.id;
|
||||||
const username = user?.user?.username || "Unknown User";
|
|
||||||
|
|
||||||
const VCcategory = interaction.guild.channels.cache.find(
|
fs.writeFileSync("./Data/TicketData.json", JSON.stringify(ticketData, null, 2));
|
||||||
(c) => c.name === supportbot.VoiceTickets.Category || c.id === supportbot.VoiceTickets.Category
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!VCcategory) {
|
const VCDeleteButton = new Discord.ButtonBuilder()
|
||||||
return interaction.reply({
|
.setCustomId("deleteSupportVC")
|
||||||
content: "⚠️ The Support VC category does not exist!",
|
.setLabel(supportbot.Buttons.Voice.TicketDeleteText)
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
.setEmoji(supportbot.Buttons.General.Delete)
|
||||||
|
.setStyle(supportbot.Buttons.General.DeleteStyle);
|
||||||
|
|
||||||
|
const VCDeleteRow = new Discord.ActionRowBuilder().addComponents(VCDeleteButton);
|
||||||
|
|
||||||
|
const vcmadeembed = new Discord.EmbedBuilder()
|
||||||
|
.setDescription(`> **Support VC Created:** <#${SupportVoice.id}>`)
|
||||||
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
|
|
||||||
|
await interaction.reply({
|
||||||
|
embeds: [vcmadeembed],
|
||||||
|
components: [VCDeleteRow],
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
const SupportVoice = await interaction.guild.channels.create({
|
|
||||||
name: supportbot.VoiceTickets.Name.replace(/%username%/g, username),
|
|
||||||
type: Discord.ChannelType.GuildVoice,
|
|
||||||
parent: VCcategory,
|
|
||||||
permissionOverwrites: [
|
|
||||||
{
|
|
||||||
id: interaction.guild.id,
|
|
||||||
deny: [Discord.PermissionsBitField.Flags.Connect]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: user.id || user, // works if user is a Member or just ID
|
|
||||||
allow: [
|
|
||||||
Discord.PermissionsBitField.Flags.Connect,
|
|
||||||
Discord.PermissionsBitField.Flags.Speak,
|
|
||||||
Discord.PermissionsBitField.Flags.ViewChannel,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
db.updateTicketVoice(ticketInfo.ticket_id, SupportVoice.id);
|
|
||||||
|
|
||||||
const vcmadeembed = new Discord.EmbedBuilder()
|
|
||||||
.setDescription(`> **Support VC Created:** <#${SupportVoice.id}>`)
|
|
||||||
.setColor(supportbot.Embed.Colours.Success);
|
|
||||||
|
|
||||||
const VCDeleteButton = new Discord.ButtonBuilder()
|
|
||||||
.setCustomId("deleteSupportVC")
|
|
||||||
.setLabel(supportbot.Buttons.Voice.TicketDeleteText)
|
|
||||||
.setEmoji(supportbot.Buttons.General.Delete)
|
|
||||||
.setStyle(supportbot.Buttons.General.DeleteStyle);
|
|
||||||
|
|
||||||
const VCDeleteRow = new Discord.ActionRowBuilder().addComponents(VCDeleteButton);
|
|
||||||
|
|
||||||
await interaction.reply({
|
|
||||||
embeds: [vcmadeembed],
|
|
||||||
components: [VCDeleteRow],
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "archiveticket":
|
case "archiveticket":
|
||||||
const arcembed = new Discord.EmbedBuilder()
|
const arcembed = new Discord.EmbedBuilder()
|
||||||
.setDescription(msgconfig.Ticket.TicketArchived)
|
.setDescription(msgconfig.Ticket.TicketArchived)
|
||||||
.setColor(supportbot.Embed.Colours.Success);
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
|
|
||||||
const CloseButton = new Discord.ButtonBuilder()
|
const CloseButton = new Discord.ButtonBuilder()
|
||||||
.setCustomId("confirmCloseTicket")
|
.setCustomId("confirmCloseTicket")
|
||||||
.setLabel(supportbot.Ticket.Close.Confirmation_Button)
|
.setLabel(supportbot.Ticket.Close.Confirmation_Button)
|
||||||
.setEmoji(supportbot.Ticket.Close.Confirmation_Emoji)
|
.setEmoji(supportbot.Ticket.Close.Confirmation_Emoji)
|
||||||
.setStyle(supportbot.Ticket.Close.Confirmation_Style);
|
.setStyle(supportbot.Ticket.Close.Confirmation_Style);
|
||||||
|
|
||||||
const unarchiveButton = new Discord.ButtonBuilder()
|
const unarchiveButton = new Discord.ButtonBuilder()
|
||||||
.setCustomId("unarchiveTicket")
|
.setCustomId("unarchiveTicket")
|
||||||
.setLabel(supportbot.Buttons.Tickets.Unarchive)
|
.setLabel(supportbot.Buttons.Tickets.Unarchive)
|
||||||
.setEmoji(supportbot.Buttons.Tickets.Unarchive_Emoji)
|
.setEmoji(supportbot.Buttons.Tickets.Unarchive_Emoji)
|
||||||
.setStyle(supportbot.Buttons.Tickets.Unarchive_Style);
|
.setStyle(supportbot.Buttons.Tickets.Unarchive_Style);
|
||||||
|
|
||||||
const ArchivedOptions = new Discord.ActionRowBuilder()
|
const ArchivedOptions = new Discord.ActionRowBuilder()
|
||||||
.addComponents(CloseButton, unarchiveButton);
|
.addComponents(CloseButton, unarchiveButton);
|
||||||
|
|
||||||
await interaction.channel.send({
|
await interaction.channel.send({
|
||||||
embeds: [arcembed],
|
embeds: [arcembed],
|
||||||
components: [ArchivedOptions],
|
components: [ArchivedOptions],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (supportbot.Ticket.TicketType === "threads") {
|
if (supportbot.Ticket.TicketType === "threads") {
|
||||||
await interaction.channel.setArchived(true);
|
await interaction.channel.setArchived(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supportbot.Ticket.TicketType === "channels") {
|
if (supportbot.Ticket.TicketType === "channels") {
|
||||||
const { getRole, getChannel } = interaction.client;
|
const { getRole, getChannel } = interaction.client;
|
||||||
await interaction.channel.setParent(supportbot.Ticket.TicketArchiveCategory);
|
await interaction.channel.setParent(supportbot.Ticket.TicketArchiveCategory);
|
||||||
const tickets = db.getAllTickets();
|
|
||||||
const ticketInfo = tickets.find(t => t.ticket_id === interaction.channel.id);
|
const ticketData = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
||||||
|
const ticketInfo = ticketData.tickets.find(t => t.id === interaction.channel.id);
|
||||||
|
|
||||||
if (ticketInfo) {
|
if (ticketInfo) {
|
||||||
const user = interaction.guild.members.cache.get(ticketInfo.user_id) || ticketInfo.user_id;
|
const user = interaction.guild.members.cache.get(ticketInfo.user) || ticketInfo.user;
|
||||||
const claimedBy = interaction.guild.members.cache.get(ticketInfo.claimed_by) || ticketInfo.claimed_by;
|
const claimedBy = interaction.guild.members.cache.get(ticketInfo.claimedBy) || ticketInfo.claimedBy;
|
||||||
const Admin = await interaction.guild.roles.fetch(supportbot.Roles.StaffMember.Admin);
|
const Admin = await interaction.guild.roles.fetch(supportbot.Roles.StaffMember.Admin);
|
||||||
const Staff = await interaction.guild.roles.fetch(supportbot.Roles.StaffMember.Staff);
|
const Staff = await interaction.guild.roles.fetch(supportbot.Roles.StaffMember.Staff);
|
||||||
|
|
||||||
if (user && user.id) {
|
if (user && user.id) {
|
||||||
await interaction.channel.permissionOverwrites.edit(user.id, {
|
await interaction.channel.permissionOverwrites.edit(user.id, {
|
||||||
ViewChannel: false,
|
ViewChannel: false,
|
||||||
SendMessages: false,
|
SendMessages: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supportbot.ClaimTickets === true) {
|
if (supportbot.ClaimTickets === true) {
|
||||||
if (claimedBy && claimedBy.id) {
|
if (claimedBy && claimedBy.id) {
|
||||||
await interaction.channel.permissionOverwrites.edit(claimedBy.id, {
|
await interaction.channel.permissionOverwrites.edit(claimedBy.id, {
|
||||||
@@ -244,6 +286,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supportbot.ClaimTickets === false) {
|
if (supportbot.ClaimTickets === false) {
|
||||||
if (Staff && Staff.id) {
|
if (Staff && Staff.id) {
|
||||||
await interaction.channel.permissionOverwrites.edit(claimedBy.id, {
|
await interaction.channel.permissionOverwrites.edit(claimedBy.id, {
|
||||||
@@ -253,6 +296,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Admin && Admin.id) {
|
if (Admin && Admin.id) {
|
||||||
await interaction.channel.permissionOverwrites.edit(Admin.id, {
|
await interaction.channel.permissionOverwrites.edit(Admin.id, {
|
||||||
ViewChannel: true,
|
ViewChannel: true,
|
||||||
@@ -260,47 +304,59 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
ReadMessageHistory: true,
|
ReadMessageHistory: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await interaction.channel.permissionOverwrites.edit(interaction.guild.roles.everyone.id, {
|
await interaction.channel.permissionOverwrites.edit(interaction.guild.roles.everyone.id, {
|
||||||
ViewChannel: false,
|
ViewChannel: false,
|
||||||
SendMessages: false,
|
SendMessages: false,
|
||||||
ReadMessageHistory: false,
|
ReadMessageHistory: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "lockticket":
|
case "lockticket":
|
||||||
const lockembed = new Discord.EmbedBuilder()
|
const lockembed = new Discord.EmbedBuilder()
|
||||||
.setDescription(msgconfig.Ticket.TicketLocked)
|
.setDescription(msgconfig.Ticket.TicketLocked)
|
||||||
.setColor(supportbot.Embed.Colours.Success);
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
|
|
||||||
const unlockButton = new Discord.ButtonBuilder()
|
const unlockButton = new Discord.ButtonBuilder()
|
||||||
.setCustomId("unlockTicket")
|
.setCustomId("unlockTicket")
|
||||||
.setLabel(supportbot.Buttons.Tickets.Unlock)
|
.setLabel(supportbot.Buttons.Tickets.Unlock)
|
||||||
.setEmoji(supportbot.Buttons.Tickets.Unlock_Emoji)
|
.setEmoji(supportbot.Buttons.Tickets.Unlock_Emoji)
|
||||||
.setStyle(supportbot.Buttons.Tickets.Unlock_Style);
|
.setStyle(supportbot.Buttons.Tickets.Unlock_Style);
|
||||||
|
|
||||||
const LockedOptions = new Discord.ActionRowBuilder()
|
const LockedOptions = new Discord.ActionRowBuilder()
|
||||||
.addComponents(unlockButton);
|
.addComponents(unlockButton);
|
||||||
|
|
||||||
await interaction.channel.send({
|
await interaction.channel.send({
|
||||||
embeds: [lockembed],
|
embeds: [lockembed],
|
||||||
components: [LockedOptions],
|
components: [LockedOptions],
|
||||||
ephemeral: false,
|
ephemeral: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (supportbot.Ticket.TicketType === "threads") {
|
if (supportbot.Ticket.TicketType === "threads") {
|
||||||
await interaction.channel.setLocked(true);
|
await interaction.channel.setLocked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "unlockTicket":
|
case "unlockTicket":
|
||||||
const unlockEmbed = new Discord.EmbedBuilder()
|
const unlockEmbed = new Discord.EmbedBuilder()
|
||||||
.setDescription(msgconfig.Ticket.TicketUnlocked)
|
.setDescription(msgconfig.Ticket.TicketUnlocked)
|
||||||
.setColor(supportbot.Embed.Colours.Success);
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
|
|
||||||
await interaction.channel.send({
|
await interaction.channel.send({
|
||||||
embeds: [unlockEmbed],
|
embeds: [unlockEmbed],
|
||||||
ephemeral: false,
|
ephemeral: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (supportbot.Ticket.TicketType === "threads") {
|
if (supportbot.Ticket.TicketType === "threads") {
|
||||||
await interaction.channel.setLocked(false);
|
await interaction.channel.setLocked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "enableinvites":
|
case "enableinvites":
|
||||||
@@ -327,70 +383,89 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
);
|
);
|
||||||
await interaction.showModal(modal);
|
await interaction.showModal(modal);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interaction.customId === 'deleteSupportVC') {
|
if (interaction.customId === 'deleteSupportVC') {
|
||||||
const ticketData = db.getAllTickets();
|
const ticketData = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
||||||
const ticketInfo = ticketData.find(t => t.ticket_id === interaction.channel.id);
|
const ticketInfo = ticketData.tickets.find(t => t.id === interaction.channel.id);
|
||||||
|
|
||||||
if (ticketInfo && ticketInfo.voiceChannelId) {
|
if (ticketInfo && ticketInfo.voiceChannelId) {
|
||||||
try {
|
try {
|
||||||
const voiceChannel = await interaction.guild.channels.fetch(ticketInfo.voiceChannelId).catch(() => null);
|
const voiceChannel = await interaction.guild.channels.fetch(ticketInfo.voiceChannelId).catch(() => null);
|
||||||
|
|
||||||
if (voiceChannel) {
|
if (voiceChannel) {
|
||||||
await voiceChannel.delete();
|
await voiceChannel.delete();
|
||||||
|
|
||||||
const successEmbed = new Discord.EmbedBuilder()
|
const successEmbed = new Discord.EmbedBuilder()
|
||||||
.setDescription('✅ Support voice channel has been successfully deleted!')
|
.setDescription('✅ Support voice channel has been successfully deleted!')
|
||||||
.setColor(supportbot.Embed.Colours.Success);
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
|
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [successEmbed],
|
embeds: [successEmbed],
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ticketInfo.voiceChannelId = null;
|
||||||
|
fs.writeFileSync("./Data/TicketData.json", JSON.stringify(ticketData, null, 2));
|
||||||
} else {
|
} else {
|
||||||
const errorEmbed = new Discord.EmbedBuilder()
|
const errorEmbed = new Discord.EmbedBuilder()
|
||||||
.setDescription('❌ The associated voice channel could not be found.')
|
.setDescription('❌ The associated voice channel could not be found.')
|
||||||
.setColor(supportbot.Embed.Colours.Error);
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [errorEmbed],
|
embeds: [errorEmbed],
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting the Voice Channel:', error);
|
console.error('Error deleting the Voice Channel:', error);
|
||||||
|
|
||||||
const errorEmbed = new Discord.EmbedBuilder()
|
const errorEmbed = new Discord.EmbedBuilder()
|
||||||
.setDescription('❌ **There was an error trying to delete this voice channel. Please try again later.**')
|
.setDescription('❌ **There was an error trying to delete this voice channel. Please try again later.**')
|
||||||
.setColor(supportbot.Embed.Colours.Error);
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [errorEmbed],
|
embeds: [errorEmbed],
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const errorEmbed = new Discord.EmbedBuilder()
|
const errorEmbed = new Discord.EmbedBuilder()
|
||||||
.setDescription('⚠️ This button is not linked to a valid voice channel.')
|
.setDescription('⚠️ This button is not linked to a valid voice channel.')
|
||||||
.setColor(supportbot.Embed.Colours.Warn);
|
.setColor(supportbot.Embed.Colours.Warn);
|
||||||
|
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [errorEmbed],
|
embeds: [errorEmbed],
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (interaction.isButton()) {
|
if (interaction.isButton()) {
|
||||||
if (interaction.customId === "unarchiveTicket") {
|
if (interaction.customId === "unarchiveTicket") {
|
||||||
|
|
||||||
if (supportbot.Ticket.TicketType === "threads") {
|
if (supportbot.Ticket.TicketType === "threads") {
|
||||||
await interaction.channel.setArchived(false);
|
await interaction.channel.setArchived(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supportbot.Ticket.TicketType === "channels") {
|
if (supportbot.Ticket.TicketType === "channels") {
|
||||||
const { getRole, getChannel } = interaction.client;
|
const { getRole, getChannel } = interaction.client;
|
||||||
await interaction.channel.setParent(supportbot.Ticket.TicketChannelsCategory);
|
await interaction.channel.setParent(supportbot.Ticket.TicketChannelsCategory);
|
||||||
const ticketData = db.getAllTickets();
|
|
||||||
const ticketInfo = ticketData.find(t => t.ticket_id === interaction.channel.id);
|
const ticketData = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
||||||
|
const ticketInfo = ticketData.tickets.find(t => t.id === interaction.channel.id);
|
||||||
|
|
||||||
if (ticketInfo) {
|
if (ticketInfo) {
|
||||||
const user = interaction.guild.members.cache.get(ticketInfo.user_id) || ticketInfo.user_id;
|
const user = interaction.guild.members.cache.get(ticketInfo.user) || ticketInfo.user;
|
||||||
const claimedBy = interaction.guild.members.cache.get(ticketInfo.claimed_by) || ticketInfo.claimed_by;
|
const claimedBy = interaction.guild.members.cache.get(ticketInfo.claimedBy) || ticketInfo.claimedBy;
|
||||||
const Admin = await interaction.guild.roles.fetch(supportbot.Roles.StaffMember.Admin);
|
const Admin = await interaction.guild.roles.fetch(supportbot.Roles.StaffMember.Admin);
|
||||||
const Staff = await interaction.guild.roles.fetch(supportbot.Roles.StaffMember.Staff);
|
const Staff = await interaction.guild.roles.fetch(supportbot.Roles.StaffMember.Staff);
|
||||||
|
|
||||||
if (user && user.id) {
|
if (user && user.id) {
|
||||||
await interaction.channel.permissionOverwrites.edit(user.id, {
|
await interaction.channel.permissionOverwrites.edit(user.id, {
|
||||||
ViewChannel: true,
|
ViewChannel: true,
|
||||||
@@ -398,6 +473,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
ReadMessageHistory: true,
|
ReadMessageHistory: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supportbot.ClaimTickets === true) {
|
if (supportbot.ClaimTickets === true) {
|
||||||
if (claimedBy && claimedBy.id) {
|
if (claimedBy && claimedBy.id) {
|
||||||
await interaction.channel.permissionOverwrites.edit(claimedBy.id, {
|
await interaction.channel.permissionOverwrites.edit(claimedBy.id, {
|
||||||
@@ -407,6 +483,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supportbot.ClaimTickets === false) {
|
if (supportbot.ClaimTickets === false) {
|
||||||
if (Staff && Staff.id) {
|
if (Staff && Staff.id) {
|
||||||
await interaction.channel.permissionOverwrites.edit(claimedBy.id, {
|
await interaction.channel.permissionOverwrites.edit(claimedBy.id, {
|
||||||
@@ -416,6 +493,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Admin && Admin.id) {
|
if (Admin && Admin.id) {
|
||||||
await interaction.channel.permissionOverwrites.edit(Admin.id, {
|
await interaction.channel.permissionOverwrites.edit(Admin.id, {
|
||||||
ViewChannel: true,
|
ViewChannel: true,
|
||||||
@@ -423,6 +501,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
ReadMessageHistory: true,
|
ReadMessageHistory: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await interaction.channel.permissionOverwrites.edit(interaction.guild.roles.everyone.id, {
|
await interaction.channel.permissionOverwrites.edit(interaction.guild.roles.everyone.id, {
|
||||||
ViewChannel: false,
|
ViewChannel: false,
|
||||||
SendMessages: false,
|
SendMessages: false,
|
||||||
@@ -430,13 +509,16 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const unrcembed = new Discord.EmbedBuilder()
|
const unrcembed = new Discord.EmbedBuilder()
|
||||||
.setDescription(msgconfig.Ticket.TicketUnarchived)
|
.setDescription(msgconfig.Ticket.TicketUnarchived)
|
||||||
.setColor(supportbot.Embed.Colours.Success);
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
|
|
||||||
await interaction.update({
|
await interaction.update({
|
||||||
embeds: [unrcembed],
|
embeds: [unrcembed],
|
||||||
components: [],
|
components: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interaction.customId === "createticket") {
|
if (interaction.customId === "createticket") {
|
||||||
@@ -453,6 +535,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
await interaction.showModal(modal);
|
await interaction.showModal(modal);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@@ -463,7 +546,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
console.error("Error executing the ticket command:", error);
|
console.error("Error executing the ticket command:", error);
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content: "An error occurred while creating the ticket.",
|
content: "An error occurred while creating the ticket.",
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -483,6 +566,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
await interaction.showModal(modal);
|
await interaction.showModal(modal);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@@ -501,11 +585,11 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
if (!ticketChannel) {
|
if (!ticketChannel) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "Ticket channel not found.",
|
content: "Ticket channel not found.",
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const { getRole } = interaction.client;
|
const { getRole, getChannel } = interaction.client;
|
||||||
const Staff = await getRole(supportbot.Roles.StaffMember.Staff, interaction.guild);
|
const Staff = await getRole(supportbot.Roles.StaffMember.Staff, interaction.guild);
|
||||||
const Admin = await getRole(supportbot.Roles.StaffMember.Admin, interaction.guild);
|
const Admin = await getRole(supportbot.Roles.StaffMember.Admin, interaction.guild);
|
||||||
|
|
||||||
@@ -517,7 +601,10 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
.setColor(supportbot.Embed.Colours.Warn);
|
.setColor(supportbot.Embed.Colours.Warn);
|
||||||
|
|
||||||
if (!Staff || !Admin) {
|
if (!Staff || !Admin) {
|
||||||
return interaction.reply({ embeds: [RolePerms], ephemeral: true });
|
return interaction.reply({
|
||||||
|
embeds: [RolePerms],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const NoPermsClaim = new Discord.EmbedBuilder()
|
const NoPermsClaim = new Discord.EmbedBuilder()
|
||||||
@@ -528,55 +615,65 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
.setColor(supportbot.Embed.Colours.Error);
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
if (!interaction.member.roles.cache.has(Staff.id) && !interaction.member.roles.cache.has(Admin.id)) {
|
if (!interaction.member.roles.cache.has(Staff.id) && !interaction.member.roles.cache.has(Admin.id)) {
|
||||||
return interaction.reply({ embeds: [NoPermsClaim], ephemeral: true });
|
return interaction.reply({
|
||||||
|
embeds: [NoPermsClaim],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supportbot.Ticket.TicketType === "threads") {
|
if (supportbot.Ticket.TicketType === "threads") {
|
||||||
await ticketChannel.members.add(interaction.user.id);
|
await ticketChannel.members.add(interaction.user.id);
|
||||||
} else {
|
|
||||||
|
} else if (supportbot.Ticket.TicketType === "channels") {
|
||||||
await ticketChannel.permissionOverwrites.create(interaction.user.id, {
|
await ticketChannel.permissionOverwrites.create(interaction.user.id, {
|
||||||
ViewChannel: true,
|
ViewChannel: true,
|
||||||
SendMessages: true,
|
SendMessages: true,
|
||||||
ReadMessageHistory: true,
|
ReadMessageHistory: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
await ticketChannel.permissionOverwrites.create(Admin, {
|
await ticketChannel.permissionOverwrites.create(Admin, {
|
||||||
ViewChannel: true,
|
ViewChannel: true,
|
||||||
SendMessages: true,
|
SendMessages: true,
|
||||||
ReadMessageHistory: true,
|
ReadMessageHistory: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
await ticketChannel.permissionOverwrites.create(interaction.guild.roles.everyone, {
|
await ticketChannel.permissionOverwrites.create(interaction.guild.roles.everyone, {
|
||||||
ViewChannel: false,
|
ViewChannel: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const pingclaimedstaff = await ticketChannel.send(`<@${interaction.user.id}>`);
|
const pingclaimedstaff = await ticketChannel.send(`<@${interaction.user.id}>`);
|
||||||
setTimeout(() => pingclaimedstaff.delete(), 2000);
|
|
||||||
|
|
||||||
const ticketInfo = db.getTicket(ticketChannelId);
|
setTimeout(() => {
|
||||||
if (ticketInfo) {
|
pingclaimedstaff.delete();
|
||||||
db.updateTicketStatus(ticketChannelId, ticketInfo.status);
|
}, 2000);
|
||||||
ticketInfo.claimed_by = interaction.user.id;
|
|
||||||
|
const TicketData = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
||||||
|
const ticketIndex = TicketData.tickets.findIndex((t) => t.id === ticketChannelId);
|
||||||
|
if (ticketIndex !== -1) {
|
||||||
|
TicketData.tickets[ticketIndex].claimedBy = interaction.user.id;
|
||||||
|
TicketData.tickets[ticketIndex].claimedAt = new Date().toISOString();
|
||||||
|
fs.writeFileSync("./Data/TicketData.json", JSON.stringify(TicketData, null, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
const claimMessage = await interaction.message.fetch();
|
const claimMessage = await interaction.message.fetch();
|
||||||
const claimedEmbed = new Discord.EmbedBuilder(claimMessage.embeds[0].data)
|
const claimedEmbed = new Discord.EmbedBuilder(claimMessage.embeds[0].data)
|
||||||
.setTitle(msgconfig.Ticket.ClaimTickets.ClaimedTitle)
|
.setTitle(msgconfig.Ticket.ClaimTickets.ClaimedTitle)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
msgconfig.Ticket.ClaimTickets.ClaimMessage_Edit
|
msgconfig.Ticket.ClaimTickets.ClaimMessage_Edit.replace("%user%", interaction.user.id).replace("%channel%", ticketChannel.id)
|
||||||
.replace("%user%", `${interaction.user.id}`)
|
|
||||||
.replace("%channel%", `${ticketChannel.id}`)
|
|
||||||
)
|
)
|
||||||
.setColor(supportbot.Embed.Colours.Success);
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
|
|
||||||
const successfullyClaimed = new Discord.EmbedBuilder()
|
const successfullyClaimed = new Discord.EmbedBuilder()
|
||||||
.setTitle(msgconfig.Ticket.ClaimTickets.ClaimedTitle)
|
.setTitle(msgconfig.Ticket.ClaimTickets.ClaimedTitle)
|
||||||
.setDescription(msgconfig.Ticket.ClaimTickets.Claimed
|
.setDescription(msgconfig.Ticket.ClaimTickets.Claimed.replace("%channel%", ticketChannel.id))
|
||||||
.replace("%channel%", `${ticketChannel.id}`)
|
|
||||||
)
|
|
||||||
.setColor(supportbot.Embed.Colours.Success);
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
|
|
||||||
await claimMessage.edit({ embeds: [claimedEmbed], components: [] });
|
await claimMessage.edit({ embeds: [claimedEmbed], components: [] });
|
||||||
await interaction.reply({ embeds: [successfullyClaimed], ephemeral: true });
|
await interaction.reply({
|
||||||
|
embeds: [successfullyClaimed],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// SUGGESTION INTERACTIONS [START]
|
// SUGGESTION INTERACTIONS [START]
|
||||||
@@ -676,10 +773,11 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
|
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Modal submission handler for editing profile
|
||||||
if (interaction.type === Discord.InteractionType.ModalSubmit && interaction.customId === "editProfileModal") {
|
if (interaction.type === Discord.InteractionType.ModalSubmit && interaction.customId === "editProfileModal") {
|
||||||
const userId = interaction.user.id;
|
const userId = interaction.user.id;
|
||||||
const profilePath = `./Data/Profiles/${userId}.json`;
|
const profilePath = `./Data/Profiles/${userId}.json`;
|
||||||
@@ -726,7 +824,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
console.error("Failed to update profile data: ", error);
|
console.error("Failed to update profile data: ", error);
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content: "There was an error while updating your profile. Please try again later.",
|
content: "There was an error while updating your profile. Please try again later.",
|
||||||
flags: Discord.MessageFlags.Ephemeral,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-11
@@ -3,34 +3,41 @@ const fs = require("fs");
|
|||||||
const yaml = require("js-yaml");
|
const yaml = require("js-yaml");
|
||||||
const Event = require("../Structures/Event.js");
|
const Event = require("../Structures/Event.js");
|
||||||
|
|
||||||
|
// Load the configuration files
|
||||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||||
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
||||||
|
|
||||||
module.exports = new Event("messageDelete", async (client, message) => {
|
module.exports = new Event("messageDelete", async (client, message) => {
|
||||||
if (!message.guild) return;
|
|
||||||
|
|
||||||
const author = message.author || (message.partial ? await message.fetch().then(m => m.author).catch(() => null) : null);
|
// Check if the message is from a guild and not from a bot
|
||||||
if (!author || author.bot) return;
|
if (!message.guild || message.author.bot) return;
|
||||||
|
|
||||||
const content = message.content || (message.attachments.size > 0 ? "Contains attachment(s)" : "*No content*");
|
|
||||||
|
|
||||||
|
// Get the delete log channel either by ID or by name
|
||||||
const deleteLogChannel = message.guild.channels.cache.get(supportbot.MessageDelete.Channel) ||
|
const deleteLogChannel = message.guild.channels.cache.get(supportbot.MessageDelete.Channel) ||
|
||||||
message.guild.channels.cache.find(c => c.name === supportbot.MessageDelete.Channel);
|
message.guild.channels.cache.find(channel => channel.name === supportbot.MessageDelete.Channel);
|
||||||
|
|
||||||
|
// Create the embed for the deleted message
|
||||||
const deletedMessageEmbed = new EmbedBuilder()
|
const deletedMessageEmbed = new EmbedBuilder()
|
||||||
.setColor(supportbot.MessageDelete.Colour)
|
.setColor(supportbot.MessageDelete.Colour)
|
||||||
.setTitle("Message Deleted")
|
.setTitle("Message Deleted")
|
||||||
.setDescription(`> **Channel:** <#${message.channel.id}>\n> **Message ID:** ${message.id}\n> **Message author:** ${author.tag} (${author.id})\n> **Message Created:** <t:${Math.floor(message.createdTimestamp / 1000)}:F>`)
|
.setDescription(`> **Channel:** <#${message.channel.id}>\n> **Message ID** [${message.id}](https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.id})\n> **Message author:** ${message.author.tag} (${message.author.id})\n> **Message Crated:** <t:${Math.floor(message.createdTimestamp / 1000)}:F>`)
|
||||||
.addFields({ name: "Deleted Content", value: content, inline: false })
|
.addFields(
|
||||||
.setThumbnail(author.displayAvatarURL())
|
{ name: 'Message', value: message.content || '*No content*', inline: false }
|
||||||
|
)
|
||||||
|
.setThumbnail(message.author.displayAvatarURL())
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
|
// If the message contains an attachment, add it to the embed
|
||||||
if (message.attachments.size > 0) {
|
if (message.attachments.size > 0) {
|
||||||
const attachment = message.attachments.first();
|
const attachment = message.attachments.first();
|
||||||
deletedMessageEmbed.addFields({ name: "Attachment", value: `[${attachment.name}](${attachment.proxyURL})` });
|
deletedMessageEmbed.addFields({ name: 'Attachment', value: `[${attachment.name}](${attachment.proxyURL})` });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send the embed to the delete log channel if the channel is found
|
||||||
if (deleteLogChannel) {
|
if (deleteLogChannel) {
|
||||||
deleteLogChannel.send({ embeds: [deletedMessageEmbed] });
|
deleteLogChannel.send({
|
||||||
|
embeds: [deletedMessageEmbed]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
+118
-103
@@ -1,128 +1,143 @@
|
|||||||
|
// SupportBot | Emerald Services
|
||||||
|
// Ready Event
|
||||||
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
|
||||||
const Discord = require("discord.js");
|
const Discord = require("discord.js");
|
||||||
|
const { Client, GatewayIntentBits, ActivityType } = require('discord.js');
|
||||||
|
const client = new Discord.Client({intents: 32767})
|
||||||
|
|
||||||
const yaml = require("js-yaml");
|
const yaml = require("js-yaml");
|
||||||
|
|
||||||
|
const supportbot = yaml.load(
|
||||||
|
fs.readFileSync("./Configs/supportbot.yml", "utf8")
|
||||||
|
);
|
||||||
|
const panelconfig = yaml.load(
|
||||||
|
fs.readFileSync("./Configs/ticket-panel.yml", "utf8")
|
||||||
|
);
|
||||||
|
|
||||||
|
const cmdconfig = yaml.load(
|
||||||
|
fs.readFileSync("./Configs/commands.yml", "utf8")
|
||||||
|
);
|
||||||
|
|
||||||
|
const msgconfig = yaml.load(
|
||||||
|
fs.readFileSync("./Configs/messages.yml", "utf8")
|
||||||
|
);
|
||||||
|
|
||||||
const Event = require("../Structures/Event.js");
|
const Event = require("../Structures/Event.js");
|
||||||
const gradient = require("gradient-string");
|
|
||||||
const figlet = require("figlet");
|
|
||||||
|
|
||||||
// Load configs
|
let chan1 = client.channels.cache.get(supportbot.Ticket.TicketHome);
|
||||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
|
||||||
const panel = yaml.load(fs.readFileSync("./Configs/ticket-panel.yml", "utf8"));
|
|
||||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
|
||||||
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
|
||||||
|
|
||||||
const ACTIVITY_TYPES = {
|
module.exports = new Event("ready", async (client, interaction) => {
|
||||||
PLAYING: Discord.ActivityType.Playing,
|
const { getRole, getChannel, getCategory } = client;
|
||||||
WATCHING: Discord.ActivityType.Watching,
|
|
||||||
LISTENING: Discord.ActivityType.Listening,
|
|
||||||
COMPETING: Discord.ActivityType.Competing
|
|
||||||
};
|
|
||||||
|
|
||||||
const setActivity = (client, type, status) => {
|
if (supportbot.Activity.Type === "Playing", "playing") {
|
||||||
const activityType = ACTIVITY_TYPES[type?.toUpperCase()];
|
|
||||||
if (activityType) {
|
|
||||||
client.user.setPresence({
|
client.user.setPresence({
|
||||||
activities: [{ name: status || "Online", type: activityType }],
|
activities: [{ name: supportbot.Activity.Status, type: Discord.ActivityType.Playing }],
|
||||||
status: type?.toLowerCase() || "online"
|
status: supportbot.Activity.Type,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
if (supportbot.Activity.Type === "Watching", "watching") {
|
||||||
|
client.user.setPresence({
|
||||||
const logStartup = async (client) => {
|
activities: [{ name: supportbot.Activity.Status, type: Discord.ActivityType.Watching }],
|
||||||
console.clear();
|
status: supportbot.Activity.Type,
|
||||||
|
});
|
||||||
// Animated loading
|
|
||||||
const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
||||||
for (let i = 0; i < frames.length * 2; i++) {
|
|
||||||
process.stdout.write(`\r${frames[i % frames.length]} Initializing SupportBot...`);
|
|
||||||
await sleep(100);
|
|
||||||
}
|
}
|
||||||
console.clear();
|
|
||||||
|
|
||||||
// Main title
|
if (supportbot.Activity.Type === "Listening", "listening") {
|
||||||
console.log("\n" + gradient.pastel.multiline(figlet.textSync("SupportBot", { font: "ANSI Shadow", horizontalLayout: "fitted" })));
|
client.user.setPresence({
|
||||||
|
activities: [{ name: supportbot.Activity.Status, type: Discord.ActivityType.Listening }],
|
||||||
|
status: supportbot.Activity.Type,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Extract bot details safely
|
if (supportbot.Activity.Type === "Competing", "competing") {
|
||||||
const botName = supportbot?.General?.Name || "SupportBot";
|
client.user.setPresence({
|
||||||
const botVersion = supportbot.SupportBot_Version;
|
activities: [{ name: supportbot.Activity.Status, type: Discord.ActivityType.Competing }],
|
||||||
|
status: supportbot.Activity.Type,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
console.log("\n╔═══════════════════════════════════════════════════════════════╗");
|
console.log(`\u001b[33m`, `――――――――――――――――――――――――――――――――――――――――――――`);
|
||||||
console.log("║ System Information ║");
|
console.log(` `);
|
||||||
console.log("╠═══════════════════════════════════════════════════════════════╣");
|
console.log(`\u001b[31m`, `┏━━━┓╋╋╋╋╋╋╋╋╋╋╋╋╋┏┓┏━━┓╋╋╋┏┓`);
|
||||||
console.log(`║ Bot Name : ${botName.padEnd(45)} ║`);
|
console.log(`\u001b[31m`, `┃┏━┓┃╋╋╋╋╋╋╋╋╋╋╋╋┏┛┗┫┏┓┃╋╋┏┛┗┓`);
|
||||||
console.log(`║ Version : ${botVersion.padEnd(45)} ║`);
|
console.log(`\u001b[31m`, `┃┗━━┳┓┏┳━━┳━━┳━━┳┻┓┏┫┗┛┗┳━┻┓┏┛`);
|
||||||
console.log(`║ Node.js : ${process.version.padEnd(45)} ║`);
|
console.log(`\u001b[31m`, `┗━━┓┃┃┃┃┏┓┃┏┓┃┏┓┃┏┫┃┃┏━┓┃┏┓┃┃`);
|
||||||
console.log(`║ Discord.js : v${Discord.version.padEnd(44)} ║`);
|
console.log(`\u001b[31m`, `┃┗━┛┃┗┛┃┗┛┃┗┛┃┗┛┃┃┃┗┫┗━┛┃┗┛┃┗┓`);
|
||||||
console.log("╚═══════════════════════════════════════════════════════════════╝\n");
|
console.log(`\u001b[31m`, `┗━━━┻━━┫┏━┫┏━┻━━┻┛┗━┻━━━┻━━┻━┛`);
|
||||||
|
console.log(`\u001b[31m`, `┗╋╋╋╋╋╋╋┃┃╋┃┃`);
|
||||||
// Links section
|
console.log(`\u001b[31m`, `╋╋╋╋╋╋╋┗┛╋┗┛`);
|
||||||
console.log(gradient.summer("┏━━━━━━━━━━━━━━━━━━━ Important Links ━━━━━━━━━━━━━━━━━━━┓"));
|
console.log(` `);
|
||||||
console.log(gradient.summer("┃ ┃"));
|
console.log(`\u001b[33m`, `――――――――――――――――――――――――――――――――――――――――――――`);
|
||||||
console.log(gradient.summer("┃ ") + "📚 Docs : " + gradient.cristal("https://emerald-services.gitbook.io/ ┃"));
|
console.log(` `);
|
||||||
console.log(gradient.summer("┃ ") + "🤝 Discord : " + gradient.cristal("https://dsc.gg/emerald-dev ┃"));
|
console.log(`\u001b[33m`, `${supportbot.General.Name} | [${supportbot.SupportBot_Version}]`, `\u001b[32m`, `Connected to Discord`,);
|
||||||
console.log(gradient.summer("┃ ┃"));
|
console.log("\u001b[32m", "SupportBot created by Emerald Development ");
|
||||||
console.log(gradient.summer("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n"));
|
console.log(` `);
|
||||||
|
console.log(`\u001b[33m`, `――――――――――――――――― [Links] ――――――――――――――――――`);
|
||||||
// Bot Invite
|
console.log("\u001b[32m", "Discord: https://dsc.gg/emerald-dev");
|
||||||
const inviteUrl = `https://discord.com/api/oauth2/authorize?client_id=${client.user.id}&permissions=8&scope=bot%20applications.commands`;
|
console.log("\u001b[32m", "Website: https://emeraldsrv.com");
|
||||||
console.log(gradient.teen("╔════════════════════════ Bot Invite ════════════════════════╗"));
|
console.log("\u001b[32m", "Community: https://community.emeraldsrv.com");
|
||||||
console.log(gradient.teen("║ ║"));
|
console.log("\u001b[32m", "Documentation: https://docs.emeraldsrv.com");
|
||||||
console.log(gradient.teen("║ ") + gradient.pastel(inviteUrl.padEnd(56)) + gradient.teen("║"));
|
console.log(` `);
|
||||||
console.log(gradient.teen("║ ║"));
|
console.log(`\u001b[33m`, `――――――――――――――――― [Invite] ――――――――――――――――――`);
|
||||||
console.log(gradient.teen("╚════════════════════════════════════════════════════════════╝\n"));
|
console.log("\u001b[32m", `Invite URL: https://discord.com/api/oauth2/authorize?client_id=${client.user.id}&permissions=8&scope=bot%20applications.commands`);
|
||||||
};
|
console.log(` `);
|
||||||
|
console.log(`\u001b[33m`, `――――――――――――――――― [Config Check] ――――――――――――――――――`);
|
||||||
const checkConfigs = async (client) => {
|
console.log("\u001b[32m", "Config initialization...");
|
||||||
const guild = client.guilds.cache.first();
|
|
||||||
if (!guild) return;
|
|
||||||
|
|
||||||
console.log(gradient.morning("┏━━━━━━━━━━━━━━━━━━━━ Config Check ━━━━━━━━━━━━━━━━━━━━━┓"));
|
|
||||||
|
|
||||||
const roles = [
|
const roles = [
|
||||||
supportbot?.Roles?.StaffMember?.Admin,
|
supportbot.Roles.StaffMember.Admin,
|
||||||
supportbot?.Roles?.StaffMember?.Staff,
|
supportbot.Roles.StaffMember.Staff
|
||||||
supportbot?.Roles?.AutoRole?.Role
|
];
|
||||||
].filter(Boolean);
|
|
||||||
|
|
||||||
const channels = [
|
if (supportbot.Roles.AutoRole.Role) roles.push(supportbot.Roles.AutoRole.Role);
|
||||||
supportbot?.Suggestions?.Channel,
|
|
||||||
supportbot?.Ticket?.Log?.TicketLog,
|
|
||||||
supportbot?.Ticket?.Log?.TranscriptLog,
|
|
||||||
supportbot?.Ticket?.TicketHome,
|
|
||||||
supportbot?.Welcome?.Channel,
|
|
||||||
supportbot?.Leave?.Channel,
|
|
||||||
supportbot?.Translate?.Log
|
|
||||||
].filter(Boolean);
|
|
||||||
|
|
||||||
const [missingRoles, missingChannels] = await Promise.all([
|
const channels = [
|
||||||
Promise.all(roles.map((role) => client.getRole(role, guild))),
|
supportbot.Suggestions.Channel,
|
||||||
Promise.all(channels.map((channel) => client.getChannel(channel, guild)))
|
supportbot.Ticket.Log.TicketLog,
|
||||||
]);
|
supportbot.Ticket.Log.TranscriptLog,
|
||||||
|
supportbot.Ticket.TicketHome,
|
||||||
|
supportbot.Welcome.Channel,
|
||||||
|
supportbot.Leave.Channel,
|
||||||
|
supportbot.Translate.Log
|
||||||
|
];
|
||||||
|
//const categories = [supportbot.TicketCategory];
|
||||||
|
|
||||||
const missing = {
|
if (!channels) {
|
||||||
roles: roles.filter((_, i) => !missingRoles[i]),
|
console.log("\u001b[31m", `[MISSING CHANNEL]`, `\u001b[37;1m`, `${channels}`, "\u001b[31m", `channel not found. Please check your config file.`);
|
||||||
channels: channels.filter((_, i) => !missingChannels[i])
|
return;
|
||||||
};
|
}
|
||||||
|
// else {
|
||||||
|
// console.log(`\u001b[32m`, `[CHANNEL LOCATED]`, `\u001b[37;1m`, `${channels}`, `\u001b[32;1m`, `channel has been found.`);
|
||||||
|
// }
|
||||||
|
|
||||||
if (missing.roles.length || missing.channels.length) {
|
const missingC = [];
|
||||||
console.log(gradient.morning("┃ ⚠️ - Configuration Issues Found: ┃"));
|
const missingR = [];
|
||||||
if (missing.roles.length) {
|
const missingCat = [];
|
||||||
console.log(gradient.morning("┃ • Missing Roles: ") + gradient.fruit(missing.roles.join(", ")));
|
|
||||||
}
|
for (let r of roles) {
|
||||||
if (missing.channels.length) {
|
const find = await getRole(r, client.guilds.cache.first());
|
||||||
console.log(gradient.morning("┃ • Missing Channels: ") + gradient.fruit(missing.channels.join(", ")));
|
if (!find) missingR.push(r);
|
||||||
}
|
}
|
||||||
} else {
|
// for (let cat of categories) {
|
||||||
console.log(gradient.morning("┃ ✅ - All configurations validated successfully ┃"));
|
// const find = await getCategory(cat, client.guilds.cache.first());
|
||||||
|
// if (!find) missingCat.push(cat);
|
||||||
|
// }
|
||||||
|
|
||||||
|
const missingRoles = await Promise.all(roles.map(role => getRole(role, client.guilds.cache.first())));
|
||||||
|
const missingChannels = await Promise.all(channels.map(channel => getChannel(channel, client.guilds.cache.first())));
|
||||||
|
|
||||||
|
if (missingRoles.some(role => !role)) {
|
||||||
|
console.log("\u001b[31m", `Missing roles in your server configuration: ${missingRoles.filter(role => !role).join(', ')}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(gradient.morning("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n"));
|
if (missingChannels.some(channel => !channel)) {
|
||||||
};
|
console.log("\u001b[31m", `Missing channels in your server configuration: ${missingChannels.filter(channel => !channel).join(', ')}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("\u001b[32m", "Configs initialized, No problems were detected.");
|
||||||
|
console.log(` `);
|
||||||
|
|
||||||
module.exports = new Event("clientReady", async (client) => {
|
|
||||||
setActivity(client, supportbot?.Activity?.Type, supportbot?.Activity?.Status);
|
|
||||||
await logStartup(client);
|
|
||||||
await checkConfigs(client);
|
|
||||||
});
|
});
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2025 Emerald Services
|
Copyright (c) 2024 Emerald Services
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
+27
-42
@@ -1,28 +1,12 @@
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
|
||||||
const Discord = require("discord.js");
|
const Discord = require("discord.js");
|
||||||
const { GatewayIntentBits, Partials } = require('discord.js');
|
const { GatewayIntentBits, Partials } = require('discord.js');
|
||||||
const yaml = require("js-yaml");
|
const yaml = require("js-yaml");
|
||||||
const { Command, Event } = require('./Addon.js');
|
const { Command, Event } = require('./Addon.js'); // Adjust the path as needed
|
||||||
|
|
||||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
||||||
|
|
||||||
|
|
||||||
function walk(dir, ext = ".js", fileList = []) {
|
|
||||||
const files = fs.readdirSync(dir);
|
|
||||||
for (const file of files) {
|
|
||||||
const full = `${dir}/${file}`;
|
|
||||||
const stat = fs.statSync(full);
|
|
||||||
if (stat.isDirectory()) {
|
|
||||||
walk(full, ext, fileList);
|
|
||||||
} else if (file.endsWith(ext)) {
|
|
||||||
fileList.push(full);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fileList;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Client extends Discord.Client {
|
class Client extends Discord.Client {
|
||||||
constructor() {
|
constructor() {
|
||||||
super({
|
super({
|
||||||
@@ -39,7 +23,7 @@ class Client extends Discord.Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getChannel(channel, guild) {
|
async getChannel(channel, guild) {
|
||||||
if (!channel) return null;
|
if (!channel) return null; // Add check for undefined channel
|
||||||
return guild.channels.cache.find(
|
return guild.channels.cache.find(
|
||||||
(c) =>
|
(c) =>
|
||||||
(c.type === Discord.ChannelType.GuildText || c.type === Discord.ChannelType.GuildNews) &&
|
(c.type === Discord.ChannelType.GuildText || c.type === Discord.ChannelType.GuildNews) &&
|
||||||
@@ -48,14 +32,14 @@ class Client extends Discord.Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getRole(role, guild) {
|
async getRole(role, guild) {
|
||||||
if (!role) return null;
|
if (!role) return null; // Add check for undefined role
|
||||||
return guild.roles.cache.find(
|
return guild.roles.cache.find(
|
||||||
(r) => r.id === role || (r.name && r.name.toLowerCase() === role.toLowerCase())
|
(r) => r.id === role || (r.name && r.name.toLowerCase() === role.toLowerCase())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getCategory(category, guild) {
|
async getCategory(category, guild) {
|
||||||
if (!category) return null;
|
if (!category) return null; // Add check for undefined category
|
||||||
return guild.channels.cache.find(
|
return guild.channels.cache.find(
|
||||||
(c) =>
|
(c) =>
|
||||||
c.type === Discord.ChannelType.GuildCategory &&
|
c.type === Discord.ChannelType.GuildCategory &&
|
||||||
@@ -64,75 +48,72 @@ class Client extends Discord.Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async start(token) {
|
async start(token) {
|
||||||
let tempCommandFiles = walk("./Commands");
|
let tempCommandFiles = fs.readdirSync("./Commands").filter((file) => file.endsWith(".js"));
|
||||||
|
|
||||||
if (cmdconfig.Suggestion.Enabled === false) {
|
if (cmdconfig.Suggestion.Enabled === false) {
|
||||||
tempCommandFiles = tempCommandFiles.filter(item => path.basename(item) !== "suggest.js");
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "suggest.js");
|
||||||
}
|
|
||||||
|
|
||||||
if (cmdconfig.Suggestion.Enabled === false) {
|
|
||||||
tempCommandFiles = tempCommandFiles.filter(item => path.basename(item) !== "suggestadmin.js");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdconfig.Help.Enabled === false) {
|
if (cmdconfig.Help.Enabled === false) {
|
||||||
tempCommandFiles = tempCommandFiles.filter(item => path.basename(item) !== "help.js");
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "help.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdconfig.Info.Enabled === false) {
|
if (cmdconfig.Info.Enabled === false) {
|
||||||
tempCommandFiles = tempCommandFiles.filter(item => path.basename(item) !== "info.js");
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "info.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdconfig.OpenTicket.Enabled === false) {
|
if (cmdconfig.OpenTicket.Enabled === false) {
|
||||||
tempCommandFiles = tempCommandFiles.filter(item => path.basename(item) !== "ticket.js");
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "ticket.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdconfig.CloseTicket.Enabled === false) {
|
if (cmdconfig.CloseTicket.Enabled === false) {
|
||||||
tempCommandFiles = tempCommandFiles.filter(item => path.basename(item) !== "close.js");
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "close.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdconfig.Embed.Enabled === false) {
|
if (cmdconfig.Embed.Enabled === false) {
|
||||||
tempCommandFiles = tempCommandFiles.filter(item => path.basename(item) !== "embed.js");
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "embed.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdconfig.Translate.Enabled === false) {
|
if (cmdconfig.Translate.Enabled === false) {
|
||||||
tempCommandFiles = tempCommandFiles.filter(item => path.basename(item) !== "translate.js");
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "translate.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdconfig.UserInfo.Enabled === false) {
|
if (cmdconfig.UserInfo.Enabled === false) {
|
||||||
tempCommandFiles = tempCommandFiles.filter(item => path.basename(item) !== "userinfo.js");
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "userinfo.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdconfig.Ping.Enabled === false) {
|
if (cmdconfig.Ping.Enabled === false) {
|
||||||
tempCommandFiles = tempCommandFiles.filter(item => path.basename(item) !== "Ping.js");
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "Ping.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdconfig.AddUser.Enabled === false) {
|
if (cmdconfig.AddUser.Enabled === false) {
|
||||||
tempCommandFiles = tempCommandFiles.filter(item => path.basename(item) !== "addUser.js");
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "addUser.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdconfig.RemoveUser.Enabled === false) {
|
if (cmdconfig.RemoveUser.Enabled === false) {
|
||||||
tempCommandFiles = tempCommandFiles.filter(item => path.basename(item) !== "removeUser.js");
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "removeUser.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdconfig.ForceAddUser.Enabled === false) {
|
if (cmdconfig.ForceAddUser.Enabled === false) {
|
||||||
tempCommandFiles = tempCommandFiles.filter(item => path.basename(item) !== "forceaddUser.js");
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "forceaddUser.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdconfig.Profile.Enabled === false) {
|
if (cmdconfig.Profile.Enabled === false) {
|
||||||
tempCommandFiles = tempCommandFiles.filter(item => path.basename(item) !== "profile.js");
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "profile.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdconfig.Settings.Enabled === false) {
|
if (cmdconfig.Settings.Enabled === false) {
|
||||||
tempCommandFiles = tempCommandFiles.filter(item => path.basename(item) !== "settings.js");
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "settings.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdconfig.Mod.Enabled === false) {
|
if (cmdconfig.Mod.Enabled === false) {
|
||||||
tempCommandFiles = tempCommandFiles.filter(item => path.basename(item) !== "mod.js");
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "mod.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
const commandFiles = tempCommandFiles;
|
const commandFiles = tempCommandFiles;
|
||||||
const commands = commandFiles.map((file) => require(`../${file}`));
|
const commands = commandFiles.map((file) => require(`../Commands/${file}`));
|
||||||
|
|
||||||
|
// Load main commands
|
||||||
console.log(`\u001b[33m`, "――――――――――――――――――――――――――――――――――――――――――――");
|
console.log(`\u001b[33m`, "――――――――――――――――――――――――――――――――――――――――――――");
|
||||||
|
|
||||||
commands.forEach((cmd) => {
|
commands.forEach((cmd) => {
|
||||||
@@ -140,6 +121,7 @@ class Client extends Discord.Client {
|
|||||||
this.commands.set(cmd.name, cmd);
|
this.commands.set(cmd.name, cmd);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Load addon commands and events
|
||||||
console.log(`\u001b[33m`, "▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬");
|
console.log(`\u001b[33m`, "▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬");
|
||||||
|
|
||||||
if (supportbot.General.Addons.Enabled) {
|
if (supportbot.General.Addons.Enabled) {
|
||||||
@@ -151,6 +133,7 @@ class Client extends Discord.Client {
|
|||||||
return addon;
|
return addon;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Addons
|
||||||
console.log(" ");
|
console.log(" ");
|
||||||
console.log(`\u001b[33m`, "▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬");
|
console.log(`\u001b[33m`, "▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬");
|
||||||
|
|
||||||
@@ -180,7 +163,9 @@ class Client extends Discord.Client {
|
|||||||
console.log(`\u001b[33m`, "▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬");
|
console.log(`\u001b[33m`, "▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.once("clientReady", async () => {
|
// Register Slash Commands
|
||||||
|
|
||||||
|
this.once("ready", async () => {
|
||||||
await this.guilds.cache.first()?.commands.set(this.commands);
|
await this.guilds.cache.first()?.commands.set(this.commands);
|
||||||
console.log(
|
console.log(
|
||||||
"\u001b[32m",
|
"\u001b[32m",
|
||||||
|
|||||||
@@ -1,221 +0,0 @@
|
|||||||
// SupportBot | Emerald Services
|
|
||||||
// Database Structure
|
|
||||||
|
|
||||||
const Database = require("better-sqlite3");
|
|
||||||
const path = require("path");
|
|
||||||
|
|
||||||
const db = new Database(path.join(__dirname, "../Data/supportbot.db"));
|
|
||||||
|
|
||||||
db.prepare(`
|
|
||||||
CREATE TABLE IF NOT EXISTS suggestions (
|
|
||||||
thread_id TEXT PRIMARY KEY,
|
|
||||||
author_id TEXT,
|
|
||||||
text TEXT,
|
|
||||||
status TEXT DEFAULT 'Created'
|
|
||||||
)
|
|
||||||
`).run();
|
|
||||||
|
|
||||||
db.prepare(`
|
|
||||||
CREATE TABLE IF NOT EXISTS profiles (
|
|
||||||
user_id TEXT PRIMARY KEY,
|
|
||||||
bio TEXT,
|
|
||||||
timezone TEXT,
|
|
||||||
clockedIn INTEGER DEFAULT 0
|
|
||||||
)
|
|
||||||
`).run();
|
|
||||||
|
|
||||||
db.prepare(`
|
|
||||||
CREATE TABLE IF NOT EXISTS tickets (
|
|
||||||
ticket_id TEXT PRIMARY KEY,
|
|
||||||
user_id TEXT,
|
|
||||||
status TEXT DEFAULT 'open',
|
|
||||||
created_at INTEGER,
|
|
||||||
updated_at INTEGER,
|
|
||||||
subject TEXT,
|
|
||||||
description TEXT
|
|
||||||
)
|
|
||||||
`).run();
|
|
||||||
|
|
||||||
try {
|
|
||||||
db.prepare("ALTER TABLE tickets ADD COLUMN voiceChannelId TEXT").run();
|
|
||||||
} catch (e) {
|
|
||||||
if (!String(e).includes("duplicate column name")) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
db.prepare(`
|
|
||||||
CREATE TABLE IF NOT EXISTS ticket_panel (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
message_id TEXT,
|
|
||||||
channel_id TEXT,
|
|
||||||
created_at INTEGER
|
|
||||||
)
|
|
||||||
`).run();
|
|
||||||
|
|
||||||
db.prepare(`
|
|
||||||
CREATE TABLE IF NOT EXISTS ticket_users (
|
|
||||||
ticket_id TEXT,
|
|
||||||
user_id TEXT,
|
|
||||||
PRIMARY KEY(ticket_id, user_id)
|
|
||||||
)
|
|
||||||
`).run();
|
|
||||||
|
|
||||||
db.prepare(`
|
|
||||||
CREATE TABLE IF NOT EXISTS settings (
|
|
||||||
id INTEGER PRIMARY KEY,
|
|
||||||
data TEXT
|
|
||||||
)
|
|
||||||
`).run();
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
addSuggestion(threadId, authorId, text) {
|
|
||||||
db.prepare(`
|
|
||||||
INSERT INTO suggestions (thread_id, author_id, text)
|
|
||||||
VALUES (@threadId, @authorId, @text)
|
|
||||||
ON CONFLICT(thread_id) DO NOTHING
|
|
||||||
`).run({ threadId, authorId, text });
|
|
||||||
},
|
|
||||||
|
|
||||||
setSuggestionStatus(threadId, status) {
|
|
||||||
db.prepare(`
|
|
||||||
UPDATE suggestions SET status=@status WHERE thread_id=@threadId
|
|
||||||
`).run({ threadId, status });
|
|
||||||
},
|
|
||||||
|
|
||||||
getSuggestion(threadId) {
|
|
||||||
return db.prepare(`
|
|
||||||
SELECT * FROM suggestions WHERE thread_id=@threadId
|
|
||||||
`).get({ threadId });
|
|
||||||
},
|
|
||||||
|
|
||||||
// ----- Profiles -----
|
|
||||||
getProfile(userId) {
|
|
||||||
const row = db.prepare(`SELECT * FROM profiles WHERE user_id=?`).get(userId);
|
|
||||||
if (!row) {
|
|
||||||
db.prepare(`
|
|
||||||
INSERT INTO profiles (user_id, bio, timezone, clockedIn)
|
|
||||||
VALUES (?, '', '', 0)
|
|
||||||
`).run(userId);
|
|
||||||
return { user_id: userId, bio: "", timezone: "", clockedIn: 0 };
|
|
||||||
}
|
|
||||||
return row;
|
|
||||||
},
|
|
||||||
|
|
||||||
updateProfile(userId, data) {
|
|
||||||
const { bio = "", timezone = "", clockedIn = 0 } = data;
|
|
||||||
db.prepare(`
|
|
||||||
INSERT INTO profiles (user_id, bio, timezone, clockedIn)
|
|
||||||
VALUES (@userId, @bio, @timezone, @clockedIn)
|
|
||||||
ON CONFLICT(user_id) DO UPDATE SET
|
|
||||||
bio = excluded.bio,
|
|
||||||
timezone = excluded.timezone,
|
|
||||||
clockedIn = excluded.clockedIn
|
|
||||||
`).run({ userId, bio, timezone, clockedIn });
|
|
||||||
},
|
|
||||||
|
|
||||||
setClockedIn(userId, value) {
|
|
||||||
db.prepare(`UPDATE profiles SET clockedIn=? WHERE user_id=?`)
|
|
||||||
.run(value ? 1 : 0, userId);
|
|
||||||
},
|
|
||||||
|
|
||||||
addTicket(ticket) {
|
|
||||||
const now = Date.now();
|
|
||||||
db.prepare(`
|
|
||||||
INSERT INTO tickets (ticket_id, user_id, subject, description, created_at, updated_at)
|
|
||||||
VALUES (@ticket_id, @user_id, @subject, @description, @created_at, @updated_at)
|
|
||||||
ON CONFLICT(ticket_id) DO NOTHING
|
|
||||||
`).run({
|
|
||||||
ticket_id: ticket.id,
|
|
||||||
user_id: ticket.user,
|
|
||||||
subject: ticket.reason || "",
|
|
||||||
description: ticket.description || "",
|
|
||||||
created_at: now,
|
|
||||||
updated_at: now
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
updateTicketVoice(ticketId, voiceChannelId) {
|
|
||||||
db.prepare(`
|
|
||||||
UPDATE tickets SET voiceChannelId=@voiceChannelId, updated_at=@updatedAt WHERE ticket_id=@ticketId
|
|
||||||
`).run({ ticketId, voiceChannelId, updatedAt: Date.now() });
|
|
||||||
},
|
|
||||||
|
|
||||||
getTicketVoice(ticketId) {
|
|
||||||
return db.prepare(`SELECT voiceChannelId FROM tickets WHERE ticket_id=?`).get(ticketId);
|
|
||||||
},
|
|
||||||
|
|
||||||
deleteTicketVoice(ticketId) {
|
|
||||||
db.prepare(`
|
|
||||||
UPDATE tickets SET voiceChannelId=NULL, updated_at=@updatedAt WHERE ticket_id=@ticketId
|
|
||||||
`).run({ ticketId, updatedAt: Date.now() });
|
|
||||||
},
|
|
||||||
|
|
||||||
updateTicketStatus(ticketId, status) {
|
|
||||||
db.prepare(`
|
|
||||||
UPDATE tickets SET status=@status, updated_at=@updatedAt WHERE ticket_id=@ticketId
|
|
||||||
`).run({ status, updatedAt: Date.now(), ticketId });
|
|
||||||
},
|
|
||||||
|
|
||||||
getTicket(ticketId) {
|
|
||||||
return db.prepare(`
|
|
||||||
SELECT * FROM tickets WHERE ticket_id=@ticketId
|
|
||||||
`).get({ ticketId });
|
|
||||||
},
|
|
||||||
|
|
||||||
getAllTickets() {
|
|
||||||
return db.prepare(`SELECT * FROM tickets`).all();
|
|
||||||
},
|
|
||||||
|
|
||||||
saveTicketPanel(messageId, channelId) {
|
|
||||||
db.prepare(`
|
|
||||||
INSERT INTO ticket_panel (message_id, channel_id, created_at)
|
|
||||||
VALUES (@messageId, @channelId, @createdAt)
|
|
||||||
`).run({ messageId, channelId, createdAt: Date.now() });
|
|
||||||
},
|
|
||||||
|
|
||||||
getTicketPanel() {
|
|
||||||
return db.prepare(`
|
|
||||||
SELECT * FROM ticket_panel ORDER BY id DESC LIMIT 1
|
|
||||||
`).get();
|
|
||||||
},
|
|
||||||
|
|
||||||
addUserToTicket(ticketId, userId) {
|
|
||||||
db.prepare(`
|
|
||||||
INSERT INTO ticket_users (ticket_id, user_id)
|
|
||||||
VALUES (?, ?)
|
|
||||||
ON CONFLICT(ticket_id, user_id) DO NOTHING
|
|
||||||
`).run(ticketId, userId);
|
|
||||||
},
|
|
||||||
|
|
||||||
removeUserFromTicket(ticketId, userId) {
|
|
||||||
db.prepare(`
|
|
||||||
DELETE FROM ticket_users WHERE ticket_id=? AND user_id=?
|
|
||||||
`).run(ticketId, userId);
|
|
||||||
},
|
|
||||||
|
|
||||||
getTicketUsers(ticketId) {
|
|
||||||
return db.prepare(`
|
|
||||||
SELECT user_id FROM ticket_users WHERE ticket_id=?
|
|
||||||
`).all(ticketId).map(r => r.user_id);
|
|
||||||
},
|
|
||||||
|
|
||||||
getSettings() {
|
|
||||||
const row = db.prepare(`SELECT data FROM settings WHERE id=1`).get();
|
|
||||||
if (!row) return {};
|
|
||||||
try {
|
|
||||||
return JSON.parse(row.data);
|
|
||||||
} catch {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
saveSettings(obj) {
|
|
||||||
const data = JSON.stringify(obj);
|
|
||||||
db.prepare(`
|
|
||||||
INSERT INTO settings (id, data)
|
|
||||||
VALUES (1, @data)
|
|
||||||
ON CONFLICT(id) DO UPDATE SET data = excluded.data
|
|
||||||
`).run({ data });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
// SupportBot | Emerald Services
|
// SupportBot | Emerald Services
|
||||||
// Event Structure
|
// Event Structure
|
||||||
|
|
||||||
class Event {
|
class Event {
|
||||||
constructor(event, run) {
|
constructor(event, run) {
|
||||||
this.event = event;
|
this.event = event;
|
||||||
|
|||||||
+29
-12
@@ -1,30 +1,47 @@
|
|||||||
// SupportBot | Emerald Services
|
// SupportBot | Emerald Services
|
||||||
// Ticket ID Structure
|
// Ticket ID Structure
|
||||||
|
|
||||||
const db = require("./Database")
|
const fs = require("fs");
|
||||||
|
|
||||||
class TicketNumberID {
|
class TicketNumberID {
|
||||||
static async pad() {
|
static async pad() {
|
||||||
let num = await this.get()
|
let num = await this.get();
|
||||||
let n = num + ""
|
let n = num + "";
|
||||||
await this.set(num + 1)
|
await this.set(num + 1);
|
||||||
return n.length >= 4 ? n : new Array(4 - n.length + 1).join("0") + n
|
return n.length >= 4 ? n : new Array(4 - n.length + 1).join("0") + n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async get() {
|
static async get() {
|
||||||
const row = db.getTicketPanel()
|
let ticketnumberID = await JSON.parse(
|
||||||
if (!row) return await this.set(0)
|
fs.readFileSync("./Data/ticket-panel-id.json", "utf8")
|
||||||
return row.id
|
);
|
||||||
|
if (!ticketnumberID.id) {
|
||||||
|
return this.set(0);
|
||||||
|
} else {
|
||||||
|
return ticketnumberID.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async set(value) {
|
static async set(value) {
|
||||||
db.saveTicketPanel(`panel-${value}`, "none")
|
let ticketnumberID = await JSON.parse(
|
||||||
return value
|
fs.readFileSync("./Data/ticket-panel-id.json", "utf8")
|
||||||
|
);
|
||||||
|
|
||||||
|
ticketnumberID.id = value;
|
||||||
|
fs.writeFileSync(
|
||||||
|
"./Data/ticket-panel-id.json",
|
||||||
|
JSON.stringify(ticketnumberID, null, 4),
|
||||||
|
(err) => {
|
||||||
|
if (err) console.error(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async reset() {
|
static async reset() {
|
||||||
return await this.set(0)
|
return await this.set(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = TicketNumberID
|
module.exports = TicketNumberID;
|
||||||
@@ -8,10 +8,9 @@
|
|||||||
// Installed with MIT License
|
// Installed with MIT License
|
||||||
//
|
//
|
||||||
// Discord Support: https://emeraldsrv.dev/discord
|
// Discord Support: https://emeraldsrv.dev/discord
|
||||||
// Community Resources: https://community.emeraldsrv.dev
|
// Community Resources: https://emeraldsrv.dev/resources
|
||||||
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
|
||||||
|
|
||||||
const yaml = require("js-yaml");
|
const yaml = require("js-yaml");
|
||||||
const supportbot = yaml.load(
|
const supportbot = yaml.load(
|
||||||
@@ -25,51 +24,13 @@ const client = new Client({
|
|||||||
|
|
||||||
client.start(supportbot.General.Token);
|
client.start(supportbot.General.Token);
|
||||||
|
|
||||||
// SupportBot - New Logging System
|
|
||||||
|
|
||||||
const logTypes = ["Output", "Warn", "Error"];
|
|
||||||
|
|
||||||
if (!fs.existsSync("./Logs")) {
|
|
||||||
fs.mkdirSync("./Logs");
|
|
||||||
}
|
|
||||||
logTypes.forEach((type) => {
|
|
||||||
const dir = `./Logs/${type}`;
|
|
||||||
if (!fs.existsSync(dir)) {
|
|
||||||
fs.mkdirSync(dir);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function logToFile(type, data) {
|
|
||||||
const date = new Date().toISOString().split("T")[0];
|
|
||||||
const file = path.join(`./logs/${type}`, `${type}-${date}.log`);
|
|
||||||
fs.appendFileSync(file, `[${new Date().toISOString()}] ${data}\n`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const origLog = console.log;
|
|
||||||
console.log = (...args) => {
|
|
||||||
origLog(...args);
|
|
||||||
logToFile("output", args.join(" "));
|
|
||||||
};
|
|
||||||
|
|
||||||
const origWarn = console.warn;
|
|
||||||
console.warn = (...args) => {
|
|
||||||
origWarn(...args);
|
|
||||||
logToFile("warn", args.join(" "));
|
|
||||||
};
|
|
||||||
|
|
||||||
const origError = console.error;
|
|
||||||
console.error = (...args) => {
|
|
||||||
origError(...args);
|
|
||||||
logToFile("error", args.join(" "));
|
|
||||||
};
|
|
||||||
|
|
||||||
process.on("unhandledRejection", (reason) => {
|
|
||||||
console.error("Unhandled Rejection:", reason);
|
|
||||||
});
|
|
||||||
|
|
||||||
process.on("uncaughtException", (err) => {
|
|
||||||
console.error("Uncaught Exception:", err);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "supportbot",
|
"name": "supportbot",
|
||||||
"version": "8.4",
|
"version": "8.3",
|
||||||
"description": "SupportBot is an open-sourced support system for discord. It's completely free to use with high amounts of customization to match your own brand.",
|
"description": "SupportBot is an open-sourced support system for discord. It's completely free to use with high amounts of customization to match your own brand.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -18,11 +18,10 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://community.emeraldsrv.dev",
|
"homepage": "https://community.emeraldsrv.dev",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@paypal/checkout-server-sdk": "^1.0.3",
|
||||||
|
"@vitalets/google-translate-api": "^8.0.0",
|
||||||
"axios": "^1.7.2",
|
"axios": "^1.7.2",
|
||||||
"better-sqlite3": "^12.2.0",
|
|
||||||
"discord.js": "^14.13.0",
|
"discord.js": "^14.13.0",
|
||||||
"figlet": "^1.9.3",
|
|
||||||
"gradient-string": "^3.0.0",
|
|
||||||
"js": "^0.1.0",
|
"js": "^0.1.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"moment": "^2.29.3",
|
"moment": "^2.29.3",
|
||||||
|
|||||||
Reference in new issue
Block a user