8.4-DEV-2

Added Buttons to WelcomeMessage
Added Components v2 Support for Welcome Message
Added improved logging system
This commit is contained in:
1tzEmerald committed 2025-09-22 18:36:04 +01:00
1 parent a05d65099b
commit 7383bd2c48
16 files changed
+459 -290

No files matched your search

-26
View File
@@ -1,26 +0,0 @@
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],
});
},
});
+148 -113
View File
@@ -288,119 +288,154 @@ function parseMarkdown(content) {
function createTranscriptHTML(ticket, reason) {
return `
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<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">
<style>
body {
background-color: #1a1a1a;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
color: white;
margin: 0;
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>
<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 class="content">
${parseMarkdown(msg.content)}
${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>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<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">
<style>
body {
background: url('file-EWLgzFEYsq16ANVg6ENJrP.png') no-repeat center center fixed;
background-size: cover;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
color: #ffffff;
margin: 0;
padding: 20px;
}
.container {
max-width: 1000px;
margin: 0 auto;
padding: 20px;
backdrop-filter: blur(10px);
background: rgba(0,0,0,0.4);
border-radius: 20px;
box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
h1 {
font-size: 2.5rem;
font-weight: bold;
text-align: center;
margin-bottom: 20px;
}
.ticket-info p {
margin: 5px 0;
}
.message {
backdrop-filter: blur(15px);
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>
</body>
</html>
<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 class="content">
${parseMarkdown(msg.content)}
${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>
</body>
</html>
`;
}
+56 -9
View File
@@ -22,27 +22,74 @@ 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."
Button: "Visit Site"
URL: "https://docs.emeraldsrv.com"
Colour: "#f74343"
Colour: "#45b463"
# ----------------------------
# Welcome/Leave Messages
# ----------------------------
Welcome:
Embed:
Colour: "#f74343"
Title: "Welcome to ServerName"
Message: ":smile: %joined_user% has just landed!"
Thumbnail: "BOT"
Enabled: true
LayoutStyle: "modern"
# Available Layout Styles
# "modern" - For the new Discord v2 components
# "classic" - Use the classic Discord look.
ImageEnabled: false
ImageURL: "https://animagelink.png/"
Embed:
Colour: "#45b463"
Title: "Welcome to ServerName"
Message: ":smile: %joined_user% has just landed!\n\n🔨 **Server Rules:** <#1202667199853232129>"
Icon:
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:
Colour: "#45b463"
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:
Embed:
Colour: "#f74343"
Title: "Goodbye!"
Message: ":slight_frown: %joined_user% has recently dropped out!"
Message: ":slight_frown: %left_user% has recently dropped out!"
Thumbnail: "BOT"
ImageEnabled: false
+5 -5
View File
@@ -8,12 +8,12 @@
# Installed with MIT License
#
# Discord Support: https://discord.gg/emeraldsrv
# Official Documentation: https://docs.emeraldsrv.com
# Addons Marketplace: https://community.emeraldsrv.com
# Official Documentation: https://docs.emeraldsrv.dev
# Addons Marketplace: https://community.emeraldsrv.dev
#
# SupportBot Configuration (supportbot.yml)
SupportBot_Version: "v8.4-DEV-1"
SupportBot_Version: "v8.4-DEV-2"
# -------------------------
# General
@@ -21,7 +21,7 @@ SupportBot_Version: "v8.4-DEV-1"
General:
Name: "SupportBot"
Token: "BOT_TOKEN"
Token: ""
Addons:
Enabled: true
@@ -144,7 +144,7 @@ VoiceTickets:
Category: "1419062819688550460"
Ticket:
TicketType: "channels"
TicketType: "threads"
# Available TicketTypes:
# channels - Tickets will be created as channels in the TicketChannelsCategory
+2
View File
@@ -19,6 +19,8 @@
Panel: true
LayoutStyle: modern
# ----------------------------------------
# Ticket Panel Message Configuration #2b2d31
# ----------------------------------------
Binary file not shown.
+137 -42
View File
@@ -1,56 +1,151 @@
const Discord = require('discord.js');
const {
EmbedBuilder,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
MessageFlags,
ContainerBuilder,
TextDisplayBuilder,
SectionBuilder,
ThumbnailBuilder,
AttachmentBuilder
} = require("discord.js");
const fs = require("fs");
const Event = require("../Structures/Event.js");
const yaml = require("js-yaml");
const Event = require("../Structures/Event.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")
);
module.exports = new Event("guildMemberAdd", async (client, member, interaction, guild) => {
function getWelcomeThumbnail(client, member, iconCfg) {
switch ((iconCfg?.Mode || "").toUpperCase()) {
case "USER":
return member.user.displayAvatarURL();
case "BOT":
return client.user.displayAvatarURL();
case "CUSTOM":
return iconCfg.CustomURL;
default:
return null;
}
}
if (supportbot.Welcome.Enabled) {
const WelcomeChannel = member.guild.channels.cache.get(supportbot.Welcome.Channel) ||
member.guild.channels.cache.find(channel => channel.name === supportbot.Welcome.Channel);
function buildModernComponents(client, member) {
const container = new ContainerBuilder().setAccentColor(
parseInt(msgconfig.Welcome.Modern.Colour.replace("#", ""), 16)
);
const WelcomeEmbed = new Discord.EmbedBuilder()
.setColor(msgconfig.Welcome.Embed.Colour)
.setTitle(msgconfig.Welcome.Embed.Title)
.setDescription(msgconfig.Welcome.Embed.Message.replace(/%joined_user%/g, member.user))
.setTimestamp();
if (msgconfig.Welcome.Embed.Thumbnail === "BOT") {
WelcomeEmbed.setThumbnail(client.user.displayAvatarURL())
} else if (msgconfig.Welcome.Embed.Thumbnail === "USER") {
WelcomeEmbed.setThumbnail(member.user.displayAvatarURL())
}
if (msgconfig.Welcome.Embed.ImageEnabled) {
WelcomeEmbed.setImage(msgconfig.Welcome.Embed.ImageURL)
}
if (WelcomeChannel) {
WelcomeChannel.send({ embeds: [WelcomeEmbed] });
}
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!`);
const section = new SectionBuilder().addTextDisplayComponents(
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(
`![image](${msgconfig.Welcome.Modern.Image.URL})`
)
);
}
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)
.setTitle(msgconfig.Welcome.Embed.Title || null)
.setDescription(
msgconfig.Welcome.Embed.Message.replace(/%joined_user%/g, member.user)
)
.setTimestamp();
const thumb = getWelcomeThumbnail(client, member, msgconfig.Welcome.Embed.Icon);
if (thumb) WelcomeEmbed.setThumbnail(thumb);
if (msgconfig.Welcome.Embed.Image?.Enabled && msgconfig.Welcome.Embed.Image.URL) {
WelcomeEmbed.setImage(msgconfig.Welcome.Embed.Image.URL);
}
const components = [];
if (
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 });
} else if (style === "modern") {
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(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!`);
});
+32 -42
View File
@@ -1,50 +1,40 @@
const Discord = require('discord.js');
const { EmbedBuilder } = require("discord.js");
const fs = require("fs");
const Event = require("../Structures/Event.js");
const yaml = require("js-yaml");
const Event = require("../Structures/Event.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 supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
module.exports = new Event("guildMemberRemove", async (client, member, interaction, guild) => {
module.exports = new Event("guildMemberRemove", async (client, member) => {
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);
if (!supportbot.Leave || !supportbot.Leave.Enabled) return;
const LeaveEmbed = new Discord.EmbedBuilder()
.setColor(msgconfig.Leave.Embed.Colour)
.setTitle(msgconfig.Leave.Embed.Title)
.setDescription(msgconfig.Leave.Embed.Message.replace(/%left_user%/g, member.user))
.setTimestamp();
if (msgconfig.Leave.Embed.Thumbnail === "BOT") {
LeaveEmbed.setThumbnail(client.user.displayAvatarURL());
} else if (msgconfig.Leave.Embed.Thumbnail === "USER") {
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!`);
const leaveChannel =
member.guild.channels.cache.get(supportbot.Leave.Channel) ||
member.guild.channels.cache.find(c => c.name === supportbot.Leave.Channel);
if (!leaveChannel) return;
const leaveEmbed = new EmbedBuilder()
.setColor(msgconfig.Leave.Embed.Colour)
.setTitle(msgconfig.Leave.Embed.Title)
.setDescription(
msgconfig.Leave.Embed.Message.replace(/%left_user%/g, member.user.toString())
)
.setTimestamp();
if (msgconfig.Leave.Embed.Thumbnail === "BOT") {
leaveEmbed.setThumbnail(client.user.displayAvatarURL());
} else if (msgconfig.Leave.Embed.Thumbnail === "USER") {
leaveEmbed.setThumbnail(member.user.displayAvatarURL());
}
});
if (msgconfig.Leave.Embed.ImageEnabled) {
leaveEmbed.setImage(msgconfig.Leave.Embed.ImageURL);
}
await leaveChannel.send({ embeds: [leaveEmbed] });
console.log(`[-] ${member.user.tag} left the server`);
});
+16 -15
View File
@@ -25,7 +25,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
if (!command)
return interaction.reply({
embeds: [NotValid],
ephemeral: true,
flags: Discord.MessageFlags.Ephemeral,
});
const permission = interaction.member.permissions.has(command.permissions);
@@ -39,7 +39,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
if (!permission)
return interaction.reply({
embeds: [ValidPerms],
ephemeral: true,
flags: Discord.MessageFlags.Ephemeral,
});
try {
@@ -66,7 +66,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
console.error("Error executing command:", error);
await interaction.reply({
content: "An error occurred while executing the command.",
ephemeral: true,
flags: Discord.MessageFlags.Ephemeral,
});
}
}
@@ -97,7 +97,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
if (!ticketChannel) {
return interaction.reply({
content: "Ticket channel not found.",
ephemeral: true,
flags: Discord.MessageFlags.Ephemeral,
});
}
try {
@@ -107,16 +107,17 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
.setColor(supportbot.Embed.Colours.Success);
return interaction.reply({
embeds: [renamedsuccess],
ephemeral: true,
flags: Discord.MessageFlags.Ephemeral,
});
} catch (error) {
console.error("Error renaming the ticket:", error);
return interaction.reply({
content: "There was an error renaming the ticket.",
ephemeral: true,
flags: Discord.MessageFlags.Ephemeral,
});
}
}
if (interaction.isStringSelectMenu()) {
if (interaction.customId === "ticketcontrolpanel") {
const selectedOption = interaction.values[0];
@@ -151,7 +152,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
if (!VCcategory) {
return interaction.reply({
content: "⚠️ The Support VC category does not exist!",
ephemeral: true,
flags: Discord.MessageFlags.Ephemeral,
});
}
@@ -343,7 +344,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
.setColor(supportbot.Embed.Colours.Success);
await interaction.reply({
embeds: [successEmbed],
ephemeral: true,
flags: Discord.MessageFlags.Ephemeral,
});
} else {
const errorEmbed = new Discord.EmbedBuilder()
@@ -351,7 +352,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
.setColor(supportbot.Embed.Colours.Error);
await interaction.reply({
embeds: [errorEmbed],
ephemeral: true,
flags: Discord.MessageFlags.Ephemeral,
});
}
} catch (error) {
@@ -361,7 +362,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
.setColor(supportbot.Embed.Colours.Error);
await interaction.reply({
embeds: [errorEmbed],
ephemeral: true,
flags: Discord.MessageFlags.Ephemeral,
});
}
} else {
@@ -370,7 +371,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
.setColor(supportbot.Embed.Colours.Warn);
await interaction.reply({
embeds: [errorEmbed],
ephemeral: true,
flags: Discord.MessageFlags.Ephemeral,
});
}
}
@@ -462,7 +463,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
console.error("Error executing the ticket command:", error);
await interaction.reply({
content: "An error occurred while creating the ticket.",
ephemeral: true,
flags: Discord.MessageFlags.Ephemeral,
});
}
}
@@ -500,7 +501,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
if (!ticketChannel) {
return interaction.reply({
content: "Ticket channel not found.",
ephemeral: true,
flags: Discord.MessageFlags.Ephemeral,
});
}
@@ -675,7 +676,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
await interaction.reply({
embeds: [embed],
ephemeral: true,
flags: Discord.MessageFlags.Ephemeral,
});
}
@@ -725,7 +726,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
console.error("Failed to update profile data: ", error);
await interaction.reply({
content: "There was an error while updating your profile. Please try again later.",
ephemeral: true,
flags: Discord.MessageFlags.Ephemeral,
});
}
}
+11 -18
View File
@@ -3,41 +3,34 @@ const fs = require("fs");
const yaml = require("js-yaml");
const Event = require("../Structures/Event.js");
// Load the configuration files
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
module.exports = new Event("messageDelete", async (client, message) => {
if (!message.guild) return;
// Check if the message is from a guild and not from a bot
if (!message.guild || message.author.bot) return;
const author = message.author || (message.partial ? await message.fetch().then(m => m.author).catch(() => null) : null);
if (!author || 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) ||
message.guild.channels.cache.find(channel => channel.name === supportbot.MessageDelete.Channel);
message.guild.channels.cache.find(c => c.name === supportbot.MessageDelete.Channel);
// Create the embed for the deleted message
const deletedMessageEmbed = new EmbedBuilder()
.setColor(supportbot.MessageDelete.Colour)
.setTitle("Message Deleted")
.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: 'Message', value: message.content || '*No content*', inline: false }
)
.setThumbnail(message.author.displayAvatarURL())
.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>`)
.addFields({ name: "Deleted Content", value: content, inline: false })
.setThumbnail(author.displayAvatarURL())
.setTimestamp();
// If the message contains an attachment, add it to the embed
if (message.attachments.size > 0) {
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) {
deleteLogChannel.send({
embeds: [deletedMessageEmbed]
});
deleteLogChannel.send({ embeds: [deletedMessageEmbed] });
}
});
+1 -1
View File
@@ -125,4 +125,4 @@ module.exports = new Event("clientReady", async (client) => {
setActivity(client, supportbot?.Activity?.Type, supportbot?.Activity?.Status);
await logStartup(client);
await checkConfigs(client);
});
});
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2024 Emerald Services
Copyright (c) 2025 Emerald Services
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+2 -1
View File
@@ -8,6 +8,7 @@ const { Command, Event } = require('./Addon.js');
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.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) {
@@ -179,7 +180,7 @@ class Client extends Discord.Client {
console.log(`\u001b[33m`, "▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬");
}
this.once("ready", async () => {
this.once("clientReady", async () => {
await this.guilds.cache.first()?.commands.set(this.commands);
console.log(
"\u001b[32m",
-6
View File
@@ -6,7 +6,6 @@ const path = require("path");
const db = new Database(path.join(__dirname, "../Data/supportbot.db"));
// ----- Core tables -----
db.prepare(`
CREATE TABLE IF NOT EXISTS suggestions (
thread_id TEXT PRIMARY KEY,
@@ -62,7 +61,6 @@ db.prepare(`
)
`).run();
/* ---- NEW table for global bot settings ---- */
db.prepare(`
CREATE TABLE IF NOT EXISTS settings (
id INTEGER PRIMARY KEY,
@@ -71,7 +69,6 @@ db.prepare(`
`).run();
module.exports = {
// ----- Suggestions -----
addSuggestion(threadId, authorId, text) {
db.prepare(`
INSERT INTO suggestions (thread_id, author_id, text)
@@ -122,7 +119,6 @@ module.exports = {
.run(value ? 1 : 0, userId);
},
// ----- Tickets -----
addTicket(ticket) {
const now = Date.now();
db.prepare(`
@@ -184,7 +180,6 @@ module.exports = {
`).get();
},
// ----- Ticket participants -----
addUserToTicket(ticketId, userId) {
db.prepare(`
INSERT INTO ticket_users (ticket_id, user_id)
@@ -205,7 +200,6 @@ module.exports = {
`).all(ticketId).map(r => r.user_id);
},
// ----- Global Settings -----
getSettings() {
const row = db.prepare(`SELECT data FROM settings WHERE id=1`).get();
if (!row) return {};
+47 -8
View File
@@ -8,9 +8,10 @@
// Installed with MIT License
//
// Discord Support: https://emeraldsrv.dev/discord
// Community Resources: https://emeraldsrv.dev/resources
// Community Resources: https://community.emeraldsrv.dev
const fs = require("fs");
const path = require("path");
const yaml = require("js-yaml");
const supportbot = yaml.load(
@@ -24,13 +25,51 @@ const client = new Client({
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);
});
+1 -3
View File
@@ -1,6 +1,6 @@
{
"name": "supportbot",
"version": "8.3",
"version": "8.4",
"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",
"scripts": {
@@ -18,8 +18,6 @@
},
"homepage": "https://community.emeraldsrv.dev",
"dependencies": {
"@paypal/checkout-server-sdk": "^1.0.3",
"@vitalets/google-translate-api": "^8.0.0",
"axios": "^1.7.2",
"better-sqlite3": "^12.2.0",
"discord.js": "^14.13.0",