Compare commits

..
15 Commits
Author SHA1 Message Date
Xiled Emerald 213f532a3c Merge pull request #114 from Emerald-Services/dev
7.5 push
2022-02-27 04:37:24 +00:00
ItzEmerald 45bd88e4d2 7.5 commit 2022-02-27 04:30:15 +00:00
Xiled Emerald 4eb8658459 Update supportbot.yml 2022-02-27 00:39:36 +00:00
Noah b37118fee2 Fix addon handler 2022-02-25 21:57:54 -06:00
Noah 026caba68a Fix setFooters 2022-02-25 21:55:33 -06:00
Noah 2003f8801a Fixed ticket perms 2022-02-25 21:51:22 -06:00
Noah 473bacf13a Removed Guild 2022-02-17 19:57:37 -06:00
Noah 8b3f2bc61a Fix missing user or subuser 2022-02-17 19:57:11 -06:00
Noah 3aa373c33c fix bad code 2022-02-11 23:47:06 -06:00
Noah 9b6263e583 Fix DM help menu 2022-02-11 23:41:02 -06:00
Noah 3e066d08ce New Departments 2022-02-11 23:34:38 -06:00
Noah aa48e28162 Fix Typos 2022-02-04 20:00:31 -06:00
Noah dc660ed94a Bug Fixes 2022-02-04 17:56:11 -06:00
Noah e02ecf9553 Bug fixes 2022-02-04 17:55:02 -06:00
Noah 23acc0926f Fix BitField Error 2022-02-04 17:49:02 -06:00
15 changed files with 298 additions and 189 deletions

No files matched your search

+1 -1
View File
@@ -56,7 +56,7 @@ module.exports = new Command({
if (ticket === -1) {
const Exists = new Discord.MessageEmbed()
.setTitle("No Ticket Found!")
.setDescription(`${supportbot.NoValidTicket}`)
.setDescription(supportbot.NoValidTicket)
.setColor(supportbot.WarningColour);
return interaction.reply({ embeds: [Exists] });
}
+36 -17
View File
@@ -57,7 +57,7 @@ module.exports = new Command({
if (TicketData === -1) {
const Exists = new Discord.MessageEmbed()
.setTitle("No Ticket Found!")
.setDescription(`${supportbot.NoValidTicket}`)
.setDescription(supportbot.NoValidTicket)
.setColor(supportbot.WarningColour);
return interaction.followUp({ embeds: [Exists] });
}
@@ -103,25 +103,38 @@ module.exports = new Command({
const transcriptEmbed = new Discord.MessageEmbed()
.setTitle(supportbot.TranscriptTitle)
.setColor(supportbot.EmbedColour)
.setFooter(supportbot.EmbedFooter)
.addField(
"Ticket",
`${interaction.channel.name} (${interaction.channel.id})`
)
.addField("User", `${tUser}#${tUser.discriminator} (${tUser.id})`)
.addField("Closed By", interaction.user.tag)
.addField("Reason", reason);
const logEmbed = new Discord.MessageEmbed()
.setTitle(supportbot.TicketLog_Title)
.setColor(supportbot.EmbedColour)
.setFooter(supportbot.EmbedFooter)
.setFooter({
text: supportbot.EmbedFooter,
iconURL: interaction.user.displayAvatarURL(),
})
.addField(
"Ticket",
`${interaction.channel.name} (${interaction.channel.id})`
)
.addField(
"User",
`${tUser.username}#${tUser.discriminator} (${tUser.id})`
`${tUser?.username || "N/A"}#${tUser?.discriminator || "N/A"} (${
tUser?.id || ticket.user
})`
)
.addField("Closed By", interaction.user.tag)
.addField("Reason", reason);
const logEmbed = new Discord.MessageEmbed()
.setTitle(supportbot.TicketLog_Title)
.setColor(supportbot.EmbedColour)
.setFooter({
text: supportbot.EmbedFooter,
iconURL: interaction.user.displayAvatarURL(),
})
.addField(
"Ticket",
`${interaction.channel.name} (${interaction.channel.id})`
)
.addField(
"User",
`${tUser?.username || "N/A"}#${tUser?.discriminator || "N/A"} (${
tUser?.id || ticket.user
})`
)
.addField("Closed By", interaction.user.tag)
.addField("Reason", reason);
@@ -155,8 +168,11 @@ module.exports = new Command({
.catch(async (err) => {
console.error(err);
});
await tUser
.send({ embeds: [transcriptEmbed], files: [file] })
if (supportbot.DMTranscripts) {
await tUser
?.send({ embeds: [transcriptEmbed], files: [file] })
.catch(async (err) => {
console.error(err);
});
@@ -164,9 +180,12 @@ module.exports = new Command({
ticket.subUsers.forEach(async (subUser) => {
await interaction.client.users.cache
.get(subUser)
.send({ embeds: [transcriptEmbed], files: [file] });
?.send({ embeds: [transcriptEmbed], files: [file] });
});
}
}
await interaction.channel.delete().catch(async (error) => {
console.error(error);
if (error.code !== Discord.Constants.APIErrors.UNKNOWN_CHANNEL) {
+45 -1
View File
@@ -29,6 +29,41 @@ module.exports = new Command({
type: "STRING",
required: true,
},
{
name: "color",
description: "Embed HEX Color",
type: "STRING",
required: false,
},
{
name: "fieldtitle",
description: "Add an additional Embed Field",
type: "STRING",
required: false,
},
{
name: "fieldcontent",
description: "Add an additional Embed Field",
type: "STRING",
required: false,
},
{
name: "thumbnail",
description: "Embed Thumbnail URL",
type: "STRING",
required: false,
},
{
name: "image",
description: "Embed Image URL",
type: "STRING",
required: false,
},
],
permissions: ["SEND_MESSAGES"],
@@ -54,10 +89,19 @@ module.exports = new Command({
) {
const EmbedTitle = interaction.options.getString("title");
const EmbedSubject = interaction.options.getString("message");
const EmbedColour = interaction.options.getString("color");
const EmbedThumbnail = interaction.options.getString("thumbnail");
const EmbedImage = interaction.options.getString("image");
const EmbedFieldContent = interaction.options.getString("fieldcontent");
const EmbedFieldTitle = interaction.options.getString("fieldtitle");
const EmbedMsg = new Discord.MessageEmbed()
.setTitle(EmbedTitle)
.setDescription(EmbedSubject);
.setDescription(EmbedSubject)
.addField(EmbedFieldTitle, EmbedFieldContent)
.setColor(EmbedColour)
.setThumbnail(EmbedThumbnail)
.setImage(EmbedImage);
interaction.reply({
embeds: [EmbedMsg],
+5 -2
View File
@@ -58,7 +58,10 @@ module.exports = new Command({
)
.setColor(supportbot.EmbedColour)
.setFooter(supportbot.EmbedFooter, interaction.user.displayAvatarURL());
.setFooter({
text: supportbot.EmbedFooter,
iconURL: interaction.user.displayAvatarURL(),
});
if (
interaction.member.roles.cache.has(SupportStaff.id) ||
@@ -72,7 +75,7 @@ module.exports = new Command({
}
if (supportbot.SendHelpPage === "dm") {
interaction.user.reply({
interaction.user.send({
embeds: [HelpEmbed1],
});
}
+1 -1
View File
@@ -55,7 +55,7 @@ module.exports = new Command({
if (ticket === -1) {
const Exists = new Discord.MessageEmbed()
.setTitle("No Ticket Found!")
.setDescription(`${supportbot.NoValidTicket}`)
.setDescription(supportbot.NoValidTicket)
.setColor(supportbot.WarningColour);
return interaction.reply({ embeds: [Exists] });
}
+5 -2
View File
@@ -34,7 +34,7 @@ module.exports = new Command({
const NoChannel = new Discord.MessageEmbed()
.setTitle("Missing Channel!")
.setDescription(`${supportbot.InvalidChannel}`)
.setDescription(supportbot.InvalidChannel)
.setColor(supportbot.ErrorColour);
if (!suggestChannel) return interaction.reply({ embeds: [NoChannel] });
@@ -45,7 +45,10 @@ module.exports = new Command({
.addField("Suggestion", suggestion, true)
.addField("From", `<@${interaction.user.id}>`)
.setThumbnail(interaction.user.displayAvatarURL())
.setFooter(supportbot.EmbedFooter, interaction.user.displayAvatarURL())
.setFooter({
text: supportbot.EmbedFooter,
iconURL: interaction.user.displayAvatarURL(),
})
.setColor(supportbot.EmbedColour);
const suggestionMsg = await suggestChannel.send({ embeds: [SuggestEmbed] });
+76 -77
View File
@@ -31,15 +31,22 @@ module.exports = new Command({
permissions: ["SEND_MESSAGES"],
async run(interaction) {
let disableCommand = true;
if (interaction.isCommand() && disableCommand)
return interaction.reply({
content: "This command is disabled",
ephemeral: true,
});
let department = interaction.customId?.split("-")[1] || null;
let TicketData = await JSON.parse(
fs.readFileSync("./Data/TicketData.json", "utf8")
);
const { getRole, getChannel, getCategory } = interaction.client;
const { getRole, getCategory } = interaction.client;
let User = interaction.guild.members.cache.get(interaction.user.id);
if (
supportbot.MaxAllowedTickets &&
TicketData.tickets.filter((t) => t.user == interaction.user.id && t.open)
TicketData.tickets.filter((t) => t.user === interaction.user.id && t.open)
.length >= supportbot.MaxAllowedTickets
) {
return interaction.reply({
@@ -73,39 +80,29 @@ module.exports = new Command({
const TicketExists = new MessageEmbed()
.setTitle("Ticket Exists!")
.setDescription(`${supportbot.TicketExists}`)
.setColor(supportbot.WarningColour);
.setDescription(supportbot.TicketExists);
if (
await interaction.guild.channels.cache.find((ticketChannel) => {
ticketChannel.name === `${supportbot.TicketPrefix}${ticketNumberID}`;
})
await interaction.guild.channels.cache.find(
(ticketChannel) =>
ticketChannel.name === `${supportbot.TicketPrefix}${ticketNumberID}`
)
) {
return await interaction.reply({ embeds: [TicketExists] });
return await interaction.reply({
embeds: [TicketExists],
ephemeral: true,
});
}
const Staff = await getRole(supportbot.Staff, interaction.guild);
const Admin = await getRole(supportbot.Admin, interaction.guild);
const DeptRole1 = await getRole(
supportbot.DepartmentRole_1,
interaction.guild
);
const DeptRole2 = await getRole(
supportbot.DepartmentRole_2,
interaction.guild
);
const DeptRole3 = await getRole(
supportbot.DepartmentRole_3,
interaction.guild
);
if (!Staff || !Admin || !DeptRole1 || !DeptRole2 || !DeptRole3)
if (!Staff || !Admin)
return interaction.reply({
content:
"Some roles seem to be missing!\nPlease check for errors when starting the bot.",
ephemeral: true,
});
const Author = interaction.user;
let TicketCategory = await getCategory(
supportbot.TicketCategory,
supportbot.Departments[department].category || supportbot.TicketCategory,
interaction.guild
);
const ticketChannel = await interaction.guild.channels.create(
@@ -119,7 +116,7 @@ module.exports = new Command({
allow: [Permissions.FLAGS.VIEW_CHANNEL],
},
{
id: Author.id,
id: interaction.user.id,
allow: [Permissions.FLAGS.VIEW_CHANNEL],
},
{
@@ -129,20 +126,20 @@ module.exports = new Command({
],
}
);
if (supportbot.AllowStaff) {
ticketChannel.permissionOverwrites.edit(Staff.id, {
if (supportbot.AllowAllStaff) {
await ticketChannel.permissionOverwrites.edit(Staff.id, {
VIEW_CHANNEL: true,
});
}
if (supportbot.TicketDepartments) {
ticketChannel.permissionOverwrites.edit(interaction.user.id, {
if (supportbot.TicketDepartments && !department) {
await ticketChannel.permissionOverwrites.edit(interaction.user.id, {
SEND_MESSAGES: false,
});
}
await TicketData.tickets.push({
id: ticketChannel.id,
name: ticketChannel.name,
user: Author.id,
user: interaction.user.id,
number: ticketNumberID,
reason: TicketSubject,
open: true,
@@ -186,23 +183,23 @@ module.exports = new Command({
.setColor(supportbot.EmbedColour);
if (supportbot.TicketSubject === "embed") {
if (TicketSubject != "No Reason Provided.") {
if (TicketSubject !== "No Reason Provided.") {
TicketMessage.addFields({ name: "Reason", value: TicketSubject });
}
}
if (supportbot.TicketSubject === "description") {
if (TicketSubject != "No Reason Provided.") {
if (TicketSubject !== "No Reason Provided.") {
await ticketChannel.setTopic(
`Reason: ${TicketSubject} - User ID: ${interaction.user.id} - Ticket: ${ticketChannel.name}`
);
}
}
if (supportbot.TicketDepartments) {
if (supportbot.TicketDepartments && !department) {
TicketMessage.addFields({
name: "Departments",
value: ` **${supportbot.DepartmentTitle_1}**\n **${supportbot.DepartmentTitle_2}**\n **${supportbot.DepartmentTitle_3}**`,
value: ` **${supportbot.Departments.map((X) => X.title).join("\n")}**`,
});
}
const CloseButton = new MessageButton()
@@ -218,33 +215,16 @@ module.exports = new Command({
.setEmoji(supportbot.TicketLockEmoji);
const row2 = new MessageActionRow().addComponents(CloseButton, LockButton);
if (supportbot.TicketDepartments) {
if (supportbot.TicketDepartments && !department) {
try {
const Department1Button = new MessageButton()
.setCustomId("Department1")
.setLabel(supportbot.DepartmentTitle_1)
.setStyle(supportbot.TicketDept1Colour)
.setEmoji(supportbot.TicketDept1Emoji);
const Department2Button = new MessageButton()
.setCustomId("Department2")
.setLabel(supportbot.DepartmentTitle_2)
.setStyle(supportbot.TicketDept2Colour)
.setEmoji(supportbot.TicketDept2Emoji);
const Department3Button = new MessageButton()
.setCustomId("Department3")
.setLabel(supportbot.DepartmentTitle_3)
.setStyle(supportbot.TicketDept3Colour)
.setEmoji(supportbot.TicketDept3Emoji);
const row = new MessageActionRow().addComponents(
Department1Button,
Department2Button,
Department3Button
let buttons = await supportbot.Departments.map((x) =>
new MessageButton()
.setCustomId("Department" + supportbot.Departments.indexOf(x))
.setLabel(x.title)
.setStyle(x.color)
.setEmoji(x.emoji)
);
const row = new MessageActionRow().addComponents(buttons);
const m = await ticketChannel.send({
embeds: [TicketMessage],
components: [row],
@@ -260,13 +240,13 @@ module.exports = new Command({
time: supportbot.Timeout * 60000,
});
} catch (e) {
if (e.code == "INTERACTION_COLLECTOR_ERROR") {
if (e.code === "INTERACTION_COLLECTOR_ERROR") {
try {
TicketData = await JSON.parse(
fs.readFileSync("./Data/TicketData.json", "utf8")
);
let ticket = await TicketData.tickets.findIndex(
(t) => t.id == ticketChannel.id
(t) => t.id === ticketChannel.id
);
TicketData.tickets[ticket].open = false;
fs.writeFileSync(
@@ -283,25 +263,14 @@ module.exports = new Command({
return await ticketChannel.delete();
}
}
let role;
let title;
if (collector.customId === "Department1") {
role = DeptRole1;
title = supportbot.DepartmentTitle_1;
}
if (collector.customId === "Department2") {
role = DeptRole2;
title = supportbot.DepartmentTitle_2;
}
if (collector.customId === "Department3") {
role = DeptRole3;
title = supportbot.DepartmentTitle_3;
}
let num = collector.customId.split("Department")[1];
let role = getRole(supportbot.Departments[num].role, interaction.guild);
let title = supportbot.Departments[num].title;
ticketChannel.permissionOverwrites.edit(role.id, {
await ticketChannel.permissionOverwrites.edit(role.id, {
VIEW_CHANNEL: true,
});
ticketChannel.permissionOverwrites.edit(Author.id, {
await ticketChannel.permissionOverwrites.edit(interaction.user.id, {
SEND_MESSAGES: true,
});
@@ -323,7 +292,37 @@ module.exports = new Command({
});
} catch (error) {}
} else {
await ticketChannel.send({ embeds: [TicketMessage], components: [row2] });
await ticketChannel.send({
embeds: [TicketMessage],
components: [row2],
});
if (department) {
let role = await getRole(
supportbot.Departments[department].role,
interaction.guild
);
let title = supportbot.Departments[department].title;
await ticketChannel.permissionOverwrites.edit(role.id, {
VIEW_CHANNEL: true,
});
let TicketCat = await getCategory(
supportbot.Departments[department].category ||
supportbot.TicketCategory,
interaction.guild
);
await ticketChannel.setParent(TicketCat.id, { lockPermissions: false });
await ticketChannel.send({
embeds: [
{
description: `> Thank for reaching out to the **${title} Department**. Please provide us information regarding your query.`,
color: supportbot.EmbedColour,
},
],
});
}
if (supportbot.AllowTicketMentions) {
await ticketChannel.send("@here");
}
}
},
});
+26 -29
View File
@@ -10,7 +10,7 @@
# Discord Support: https://emeraldsrv.dev/discord
# Community Resources: https://emeraldsrv.dev/resources
SupportBot_Version: "7.4.2"
SupportBot_Version: "7.5"
# -------------------------
# General Configuration
@@ -18,8 +18,6 @@ SupportBot_Version: "7.4.2"
Name: "SupportBot"
Token: "BOT_TOKEN"
# Guild ID Ex: 123456789123456789
Guild: ""
# -------------------------
# Activity Configuration
@@ -84,12 +82,13 @@ SuggestionDownvote: "❌"
# Tickets Configuration
# -------------------------
TicketCategory: "Tickets"
TicketCategory: "Tickets" # Only for tickets without a category
TicketPrefix: "ticket-" # The prefix for ticket channel names
TicketLog: "logs"
TicketLog: "ticket-logs"
TranscriptLog: "transcripts"
DMTranscripts: true
TranscriptTitle: "Ticket Transcript"
TicketLog_Title: "Ticket Closed"
TicketBlackListMessage: "You are not allowed to open a ticket"
@@ -97,12 +96,12 @@ TicketBlackListMessage: "You are not allowed to open a ticket"
MaxAllowedTickets: 2
TicketSubject: "description"
# "description" will displays the ticket reason within the channel description
# "embed" will displays the ticket reason within the ticket embed
# "description" will display the ticket reason within the channel description
# "embed" will display the ticket reason within the ticket embed
AllowTicketMentions: true
# Set to true to allow the ticket to mention the author and the support team.
# Set to false to dis-allow mentions within tickets.
# Set false to dis-allow mentions within tickets.
# --- Creation Config ---
# --- Start ---
@@ -143,14 +142,6 @@ TicketCloseColour: "DANGER"
TicketDeleteColour: "DANGER"
TicketLockColour: "PRIMARY"
TicketDept1Colour: "PRIMARY"
TicketDept2Colour: "PRIMARY"
TicketDept3Colour: "PRIMARY"
TicketDept1Emoji: "1️⃣"
TicketDept2Emoji: "2️⃣"
TicketDept3Emoji: "3️⃣"
TranscriptSavedMessage: "📝 **Transcript Saved!**"
TicketLockMessage: "❌ **Ticket Locked!**"
TicketDeleteMessage: "⚠ **Ticket Deleting!**" # Tickets deleting after 5 seconds by default.
@@ -161,22 +152,28 @@ TicketDeleteMessage: "⚠ **Ticket Deleting!**" # Tickets deleting after 5 secon
TicketDepartments: true
# Delete the ticket if no department selected. TIME IN MINUTES
Timeout: 5
AllowStaff: true
# If set to false users with the "Staff" role will not be able to view tickets
# without a valid department role set below.
# Set to true to allow all staff to access the ticket
AllowAllStaff: false
# Set to false to allow "Staff" to see tickets whether its a department for them or not.
DepartmentTitle_1: "General Support"
DepartmentTitle_2: "Billing Support"
DepartmentTitle_3: "Admin Team"
# Ticket department title, This is the title for a ticket department to help users know what is available.
DepartmentRole_1: "Support"
DepartmentRole_2: "Support"
DepartmentRole_3: "Admin"
# Ticket roles are the roles that will be able to gain access to tickets depending on what department has been chosen.
Departments:
- title: "General Support"
role: "Support"
color: "PRIMARY"
emoji: "1️⃣"
category: "Tickets"
- title: "Billing Support"
role: "Support"
color: "PRIMARY"
emoji: "2️⃣"
category: "Billing"
- title: "Admin Team"
role: "Admin"
color: "PRIMARY"
emoji: "3️⃣"
category: "Tickets"
# --- Closing Config ---
# --- Start ---
+1 -4
View File
@@ -1,4 +1 @@
{
"id": 0,
"TicketPanelID": ""
}
{"id":0,"TicketPanelID":"947337678720999458"}
+32
View File
@@ -0,0 +1,32 @@
const Discord = require('discord.js');
const fs = require("fs");
const Event = require("../Structures/Event.js");
const yaml = require("js-yaml");
const supportbot = yaml.load(
fs.readFileSync("./Configs/supportbot.yml", "utf8")
);
module.exports = new Event("guildMemberAdd", async (client, member, interaction, guild) => {
const WelcomeChannel = interaction.guild.channels.get(supportbot.WelcomeChannel)
const WelcomeEmbed = new Discord.MessageEmbed()
.setColor(supportbot.WelcomeColour)
.setTitle(supportbot.WelcomeTitle)
.setDescription(supportbot.WelcomeMessage.replace(/%joined_user%/g, member.user))
.setThumbnail(member.user.displayAvatarURL())
.setTimestamp();
member.guild.channels.cache.get(
supportbot.WelcomeChannel).send({
embeds: [WelcomeEmbed]
})
const WelcomeMsg = await WelcomeChannel.send({
embeds: [WelcomeEmbed]
});
});
+18 -13
View File
@@ -15,7 +15,7 @@ const Event = require("../Structures/Event.js");
module.exports = new Event("interactionCreate", async (client, interaction) => {
if (interaction.isCommand()) {
const command = client.commands.find(
(cmd) => cmd.name.toLowerCase() == interaction.commandName
(cmd) => cmd.name.toLowerCase() === interaction.commandName
);
if (interaction.user.bot || !interaction.guild) return;
@@ -29,7 +29,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
embeds: [NotValid],
});
const permission = interaction.member.permissions.has(command.permission);
const permission = interaction.member.permissions.has(command.permissions);
const ValidPerms = new Discord.MessageEmbed()
.setDescription(
@@ -41,11 +41,13 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
return interaction.reply({
embeds: [ValidPerms],
});
interaction.user = interaction.user;
command.run(interaction);
}
if (interaction.isButton()) {
if (interaction.customId === "openticket") {
if (
interaction.customId === "openticket" ||
interaction.customId.includes("department-")
) {
try {
const cmd = client.commands.get(cmdconfig.OpenTicket);
if (!cmd) return;
@@ -65,7 +67,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
}
}
if (interaction.customId === "ticketlock") {
if (interaction.channel.name.startsWith(`${supportbot.TicketPrefix}`)) {
if (interaction.channel.name.startsWith(supportbot.TicketPrefix)) {
interaction.message.fetch();
let Admin =
interaction.guild.roles.cache.find(
@@ -84,25 +86,28 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
let parent =
interaction.guild.channels.cache.find(
(c) => c.name === `${supportbot.LockTicketCategory}`
(c) => c.name === supportbot.LockTicketCategory
) ||
interaction.guild.channels.cache.find(
(c) => c.id === `${supportbot.LockTicketCategory}`
(c) => c.id === supportbot.LockTicketCategory
);
if (parent) {
interaction.channel.setParent(parent.id);
await interaction.channel.setParent(parent.id);
}
all.forEach((perm) => {
interaction.channel.permissionOverwrites.delete(perm.id);
});
interaction.channel.permissionOverwrites.create(Admin.id, {
await interaction.channel.permissionOverwrites.create(Admin.id, {
VIEW_CHANNEL: true,
});
interaction.channel.permissionOverwrites.create(interaction.guild.id, {
VIEW_CHANNEL: false,
});
await interaction.channel.permissionOverwrites.create(
interaction.guild.id,
{
VIEW_CHANNEL: false,
}
);
const ticketDeleteButton = new Discord.MessageButton()
.setCustomId("ticketclose")
@@ -116,7 +121,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
const ArchiveEmbed = new Discord.MessageEmbed()
.setTitle("Archived")
.setDescription(`Archived ${interaction.channel.name}`)
.setColor(`${supportbot.SuccessColour}`);
.setColor(supportbot.SuccessColour);
interaction.reply({ embeds: [ArchiveEmbed] });
interaction.message.edit({ components: [row] });
+36 -26
View File
@@ -14,7 +14,7 @@ const panelconfig = yaml.load(
const Event = require("../Structures/Event.js");
module.exports = new Event("ready", async (client) => {
module.exports = new Event("ready", async (client, interaction) => {
const { getRole, getChannel, getCategory } = client;
client.user.setActivity(supportbot.BotActivity, {
type: supportbot.ActivityType,
@@ -39,10 +39,12 @@ module.exports = new Event("ready", async (client) => {
`Connected to Discord`
);
console.log(
`\u001b[33m`,
`Invite to your server:`,
`\u001b[36m`,
`https://discord.com/api/oauth2/authorize?client_id=` + client.user.id + `&permissions=8&scope=bot%20applications.commands`
`\u001b[33m`,
`Invite to your server:`,
`\u001b[36m`,
`https://discord.com/api/oauth2/authorize?client_id=` +
client.user.id +
`&permissions=8&scope=bot%20applications.commands`
);
console.log(
`\u001b[33m`,
@@ -72,14 +74,10 @@ module.exports = new Event("ready", async (client) => {
console.log(`\u001b[37m`, `SupportBot proudly created by Emerald Services`);
console.log(` `);
console.log(`\u001b[31m`, `――――――――――――――――――――――――――――――――――――――――――――`);
if (
!supportbot.Guild ||
(await client.guilds.cache.size) !== 1 ||
(await client.guilds.cache.first().id) !== supportbot.Guild
) {
if (client.guilds.cache.size !== 1) {
console.log(
`\u001b[31m`,
`${client.user.username} is not in the correct server set in your config. Please join the server and restart the bot.`
`${client.user.username} must be in only 1 server. Please join this server, leave any others, and restart the bot.`
);
console.log(`\u001b[31m`, `${client.user.username} will now exit.`);
return process.exit(1);
@@ -88,10 +86,10 @@ module.exports = new Event("ready", async (client) => {
supportbot.Admin,
supportbot.Staff,
supportbot.TicketBlackListRole,
supportbot.DepartmentRole_1,
supportbot.DepartmentRole_2,
supportbot.DepartmentRole_3,
];
if (supportbot.TicketDepartments) {
supportbot.Departments.forEach((department) => roles.push(department.role));
}
if (supportbot.AutoRole) roles.push(supportbot.AutoRole_Role);
const channels = [
supportbot.SuggestionChannel,
@@ -160,11 +158,14 @@ module.exports = new Event("ready", async (client) => {
fs.readFileSync("./Data/ticket-panel-id.json", "utf8")
);
chan1.messages.fetch(panelid.TicketPanelID).catch(async (r) => {
chan1.messages.fetch(panelid.TicketPanelID).catch(async () => {
let embed = new Discord.MessageEmbed()
.setTitle(`${panelconfig.PanelTitle}`)
.setTitle(panelconfig.PanelTitle)
.setColor(supportbot.SuccessColour)
.setFooter(supportbot.EmbedFooter);
.setFooter({
text: supportbot.EmbedFooter,
iconURL: interaction.user.displayAvatarURL(),
});
if (panelconfig.TicketPanel_Description) {
embed.setDescription(panelconfig.PanelMessage);
@@ -177,13 +178,22 @@ module.exports = new Event("ready", async (client) => {
if (panelconfig.TicketPanel_Image) {
embed.setImage(panelconfig.PanelImage);
}
let button = new Discord.MessageButton()
.setLabel(panelconfig.ButtonLabel)
.setCustomId("openticket")
.setStyle(panelconfig.ButtonColour)
.setEmoji(panelconfig.ButtonEmoji);
let button;
if (supportbot.TicketDepartments) {
button = supportbot.Departments.map((x) =>
new Discord.MessageButton()
.setCustomId("department-" + supportbot.Departments.indexOf(x))
.setLabel(x.title)
.setStyle(x.color)
.setEmoji(x.emoji)
);
} else {
button = new Discord.MessageButton()
.setLabel(panelconfig.ButtonLabel)
.setCustomId("openticket")
.setStyle(panelconfig.ButtonColour)
.setEmoji(panelconfig.ButtonEmoji);
}
let row = new Discord.MessageActionRow().addComponents(button);
await chan1
@@ -194,7 +204,7 @@ module.exports = new Event("ready", async (client) => {
.then((r) => {
let data = {
id: panelid.id,
TicketPanelID: `${r.id}`,
TicketPanelID: r.id,
};
fs.writeFileSync(
"./Data/ticket-panel-id.json",
@@ -203,7 +213,7 @@ module.exports = new Event("ready", async (client) => {
);
})
.catch((e) => {
console.log("Raw" + e);
console.log("Raw: " + e);
});
});
}
+3 -3
View File
@@ -76,10 +76,10 @@ class Client extends Discord.Client {
`\u001b[32;1m`,
"Loaded"
);
addon.commands.forEach((command) => {
addon.commands?.forEach((command) => {
this.commands.set(command.name, command);
});
addon.events.forEach((event) => {
addon.events?.forEach((event) => {
this.on(event.event, (...args) => event.run(this, ...args));
});
});
@@ -89,7 +89,7 @@ class Client extends Discord.Client {
// Slash Commands
this.once("ready", async () => {
await this.application?.commands.set(this.commands, supportbot.Guild);
await this.guilds.cache.first()?.commands.set(this.commands);
console.log(
`\u001b[32;1m`,
`Slash Commands Registered for ${this.guilds.cache.first().name}`
+1 -1
View File
@@ -5,7 +5,7 @@ class Command {
constructor(options) {
this.name = options.name;
this.description = options.description;
this.permissions = options.permissions;
this.permissions = options.permissions || [];
this.options = options.options || [];
this.run = options.run;
this.defaultPermission = true;
+12 -12
View File
@@ -59,9 +59,9 @@
}
},
"node_modules/@types/node": {
"version": "17.0.13",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.13.tgz",
"integrity": "sha512-Y86MAxASe25hNzlDbsviXl8jQHb0RDvKt4c40ZJQ1Don0AAL0STLZSs4N+6gLEO55pedy7r2cLwS+ZDxPm/2Bw=="
"version": "17.0.17",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.17.tgz",
"integrity": "sha512-e8PUNQy1HgJGV3iU/Bp2+D/DXh3PYeyli8LgIwsQcs1Ar1LoaWHSIT6Rw+H2rNJmiq6SNWiDytfx8+gYj7wDHw=="
},
"node_modules/@types/node-fetch": {
"version": "2.5.12",
@@ -242,9 +242,9 @@
}
},
"node_modules/ws": {
"version": "8.4.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.4.2.tgz",
"integrity": "sha512-Kbk4Nxyq7/ZWqr/tarI9yIt/+iNNFOjBXEWgTb4ydaNHBNGgvf2QHbS9fdfsndfjFlFwEd4Al+mw83YkaD10ZA==",
"version": "8.5.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz",
"integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==",
"engines": {
"node": ">=10.0.0"
},
@@ -299,9 +299,9 @@
"integrity": "sha512-QppPM/8l3Mawvh4rn9CNEYIU9bxpXUCRMaX9yUpvBk1nMKusLKpfXGDEKExKaPhLzcn3lzil7pR6rnJ11HgeRQ=="
},
"@types/node": {
"version": "17.0.13",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.13.tgz",
"integrity": "sha512-Y86MAxASe25hNzlDbsviXl8jQHb0RDvKt4c40ZJQ1Don0AAL0STLZSs4N+6gLEO55pedy7r2cLwS+ZDxPm/2Bw=="
"version": "17.0.17",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.17.tgz",
"integrity": "sha512-e8PUNQy1HgJGV3iU/Bp2+D/DXh3PYeyli8LgIwsQcs1Ar1LoaWHSIT6Rw+H2rNJmiq6SNWiDytfx8+gYj7wDHw=="
},
"@types/node-fetch": {
"version": "2.5.12",
@@ -445,9 +445,9 @@
}
},
"ws": {
"version": "8.4.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.4.2.tgz",
"integrity": "sha512-Kbk4Nxyq7/ZWqr/tarI9yIt/+iNNFOjBXEWgTb4ydaNHBNGgvf2QHbS9fdfsndfjFlFwEd4Al+mw83YkaD10ZA==",
"version": "8.5.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz",
"integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==",
"requires": {}
},
"zod": {