diff --git a/Commands/General/info copy.js b/Commands/General/info copy.js new file mode 100644 index 0000000..4d47059 --- /dev/null +++ b/Commands/General/info copy.js @@ -0,0 +1,45 @@ +// SupportBot | Emerald Services +// Info Command + +const fs = require("fs"); + +const { ContainerBuilder, UserSelectMenuBuilder, ButtonStyle, MessageFlags } = require('discord.js'); +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 db = require("../../Structures/Database.js"); +const Command = require("../../Structures/Command.js"); + +module.exports = new Command({ + name: "test", + description: cmdconfig.Info.Description, + options: [], + permissions: cmdconfig.Info.Permission, + + async run(interaction, client) { + + const ticketPanelembed = new ContainerBuilder() + .addTextDisplayComponents( + textDisplay => textDisplay + .setContent("SupportBot"), + ) + + +await interaction.reply({ + components: [ticketPanelembed], + flags: MessageFlags.IsComponentsV2, +}); + + }, +}); \ No newline at end of file diff --git a/Commands/Tickets/close.js b/Commands/Tickets/close.js index 8ebf8e3..6d618e8 100644 --- a/Commands/Tickets/close.js +++ b/Commands/Tickets/close.js @@ -289,112 +289,141 @@ function parseMarkdown(content) { function createTranscriptHTML(ticket, reason) { return ` - + + Ticket Transcript

Ticket Transcript

-
+

Channel: ${ticket.name}

Ticket ID: ${ticket.id}

Message Count: ${ticket.messages.length}

@@ -426,9 +455,7 @@ function createTranscriptHTML(ticket, reason) { `).join('')} ${msg.attachments.map(att => ` - - 📎 ${att.name} - + 📎 ${att.name} `).join('')}
diff --git a/Commands/Tickets/ticket.js b/Commands/Tickets/ticket.js index e023d89..fc110cf 100644 --- a/Commands/Tickets/ticket.js +++ b/Commands/Tickets/ticket.js @@ -11,6 +11,9 @@ const { ButtonStyle, MessageCollector, MessageFlags, + SeparatorBuilder, + ContainerBuilder, + TextDisplayBuilder } = require("discord.js"); const yaml = require("js-yaml"); @@ -455,32 +458,57 @@ module.exports = new Command({ .setColor(supportbot.Embed.Colours.General); await interaction.reply({ embeds: [CreatedTicket], flags: MessageFlags.Ephemeral }); - const TicketMessage = new EmbedBuilder() - .setAuthor({ - name: msgconfig.Ticket.TicketAuthorTitle.replace(/%ticketauthor%/g, interaction.user.id) - .replace(/%ticketid%/g, ticketChannel.id) - .replace(/%ticketusername%/g, interaction.user.username), - iconURL: interaction.user.displayAvatarURL(), - }) - .setTitle( - msgconfig.Ticket.TicketTitle.replace(/%ticketauthor%/g, interaction.user.id) - .replace(/%ticketid%/g, ticketChannel.id) - .replace(/%ticketusername%/g, interaction.user.username) + // TICKET MESSAGE - UPDATED WITH COMPONENTS V2 + + const ticketMsgContainer = new ContainerBuilder() + + if (supportbot.Embed.Colours.General) { + ticketMsgContainer.setAccentColor( + parseInt(supportbot.Embed.Colours.General.replace("#", ""), 16) ) - .setDescription( - msgconfig.Ticket.TicketMessage.replace(/%ticketauthor%/g, interaction.user.id) - .replace(/%ticketid%/g, ticketChannel.id) - .replace(/%ticketusername%/g, interaction.user.username) - .replace(/%ticketreason%/g, TicketSubject) - ) - .setColor(supportbot.Embed.Colours.General); - - if (supportbot.Ticket.TicketReason && TicketReason) { - TicketMessage.addFields( - { name: "Reason", value: TicketReason, inline: false } - ); } + const ticketAuthor = new TextDisplayBuilder().setContent( + msgconfig.Ticket.TicketAuthorTitle.replace(/%ticketauthor%/g, interaction.user.id) + .replace(/%ticketid%/g, ticketChannel.id) + .replace(/%ticketusername%/g, interaction.user.username), + ); + + ticketMsgContainer.addTextDisplayComponents(ticketAuthor) + + const ticketTitle = new TextDisplayBuilder().setContent( + msgconfig.Ticket.TicketTitle.replace(/%ticketauthor%/g, interaction.user.id) + .replace(/%ticketid%/g, ticketChannel.id) + .replace(/%ticketusername%/g, interaction.user.username) + ); + + ticketMsgContainer.addTextDisplayComponents(ticketTitle) + + const seperator2 = new SeparatorBuilder() + .setDivider(true) + + ticketMsgContainer.addSeparatorComponents(seperator2) + + const ticketDescription = new TextDisplayBuilder().setContent( + msgconfig.Ticket.TicketMessage.replace(/%ticketauthor%/g, interaction.user.id) + .replace(/%ticketid%/g, ticketChannel.id) + .replace(/%ticketusername%/g, interaction.user.username) + .replace(/%ticketreason%/g, TicketSubject) + ); + + ticketMsgContainer.addTextDisplayComponents(ticketDescription) + + const seperator3 = new SeparatorBuilder() + .setDivider(true) + + ticketMsgContainer.addSeparatorComponents(seperator3) + + const ticketReason = new TextDisplayBuilder().setContent( + `**Reason:**\n ${TicketReason}` + ); + + const selectMenuRow = new ActionRowBuilder(); + const SelectMenus = new StringSelectMenuBuilder() .setCustomId("ticketcontrolpanel") .setPlaceholder("Ticket Control Panel") @@ -529,11 +557,17 @@ module.exports = new Command({ ); } - const row2 = new ActionRowBuilder().addComponents(SelectMenus); + selectMenuRow.addComponents(SelectMenus) + + ticketMsgContainer.addActionRowComponents(selectMenuRow) + + if (supportbot.Ticket.TicketReason && TicketReason) { + ticketMsgContainer.addTextDisplayComponents(ticketReason) + } await ticketChannel.send({ - embeds: [TicketMessage], - components: [row2], + flags: MessageFlags.IsComponentsV2, + components: [ticketMsgContainer], }); if (supportbot.Ticket.Questions.Enabled) { diff --git a/Commands/Tickets/ticketpanel.js b/Commands/Tickets/ticketpanel.js index ba3659f..f880c5a 100644 --- a/Commands/Tickets/ticketpanel.js +++ b/Commands/Tickets/ticketpanel.js @@ -5,6 +5,12 @@ const { ActionRowBuilder, ButtonBuilder, MessageFlags, + ContainerBuilder, + TextDisplayBuilder, + MediaGalleryBuilder, + SeparatorBuilder, + ThumbnailBuilder, + SectionBuilder } = require("discord.js"); const yaml = require("js-yaml"); @@ -52,6 +58,7 @@ module.exports = new Command({ } const panelRow = db.getTicketPanel(); + if (panelRow) { try { await channel.messages.fetch(panelRow.message_id); @@ -62,24 +69,35 @@ module.exports = new Command({ } catch (err) {} } - let embed = new EmbedBuilder() - .setTitle(panelconfig.PanelTitle) - .setColor(panelconfig.PanelColour) - .setFooter({ - text: supportbot.Embed.Footer, - iconURL: interaction.user.displayAvatarURL(), - }); + const panelContainer = new ContainerBuilder() - if (panelconfig.TicketPanel_Description) { - embed.setDescription(panelconfig.PanelMessage); + if (panelconfig.Style.Color) { + panelContainer.setAccentColor( + parseInt(panelconfig.Style.Color.replace("#", ""), 16) + ) } - if (panelconfig.TicketPanel_Thumbnail) { - embed.setThumbnail(panelconfig.PanelThumbnail); + const panelTitle = new TextDisplayBuilder().setContent( + panelconfig.Style.Title, + ); + + const topSeperator = new SeparatorBuilder() + .setDivider(true) + + if (panelconfig.Settings.TopTitle) { + panelContainer.addTextDisplayComponents(panelTitle) } - if (panelconfig.TicketPanel_Image) { - embed.setImage(panelconfig.PanelImage); + if (panelconfig.Settings.TopDivider) { + panelContainer.addSeparatorComponents(topSeperator) + } + + const panelDesc = new TextDisplayBuilder().setContent( + panelconfig.Style.Description, + ); + + if (panelconfig.Style.Layout === "3") { + panelContainer.addTextDisplayComponents(panelDesc) } const createTicketButton = new ButtonBuilder() @@ -88,12 +106,62 @@ module.exports = new Command({ .setEmoji(panelconfig.Button.Emoji) .setStyle(panelconfig.Button.Color); - let row = new ActionRowBuilder().addComponents(createTicketButton); + const middleSection = new SectionBuilder() + .addTextDisplayComponents(panelDesc) + .setButtonAccessory(createTicketButton) + + if (panelconfig.Style.Layout === "1") { + panelContainer.addSectionComponents(middleSection) + } + + const panelImage = new MediaGalleryBuilder() + .addItems([ + { + media: { + url: panelconfig.Style.Image, + }, + } + ]) + + if (panelconfig.Settings.Image) { + panelContainer.addMediaGalleryComponents(panelImage) + } + + // START OF STYLE 2 - TEXT UNDER THE IMAGE + + const bottomSeperator = new SeparatorBuilder() + .setDivider(true) + + if (panelconfig.Settings.BottomTitle) { + panelContainer.addTextDisplayComponents(panelTitle) + } + + if (panelconfig.Settings.BottomDivider) { + panelContainer.addSeparatorComponents(bottomSeperator) + } + + if (panelconfig.Style.Layout === "2") { + panelContainer.addSectionComponents(middleSection) + } + + // START OF STYLE 3 + + const buttonRow = new ActionRowBuilder(); + const ticketButtonRow = new ButtonBuilder() + .setCustomId("createticket") + .setLabel(panelconfig.Button.Text) + .setEmoji(panelconfig.Button.Emoji) + .setStyle(panelconfig.Button.Color); + buttonRow.addComponents(ticketButtonRow) + + if (panelconfig.Style.Layout === "3") { + panelContainer.addActionRowComponents(buttonRow) + } try { const message = await channel.send({ - embeds: [embed], - components: [row], + flags: MessageFlags.IsComponentsV2, + components: [panelContainer], }); db.saveTicketPanel(message.id, channel.id); diff --git a/Configs/messages.yml b/Configs/messages.yml index a728c11..9336b92 100644 --- a/Configs/messages.yml +++ b/Configs/messages.yml @@ -117,8 +117,18 @@ Ticket: # <@%ticketauthor%> - Tags the user who created the ticket. # <#%ticketid%> - Mentions the ticket channel. - TicketAuthorTitle: "%ticketusername%'s Ticket" - TicketTitle: "Support Ticket" + # You can use Markdown formatting in this message: + # # Heading 1 + # ## Heading 2 + # ### Heading 3 + # **Bold** text + # *Italic* text + # -# Small text + # - Bullet points + # Links: [text](https://example.com) + + TicketAuthorTitle: "-# %ticketusername%'s Ticket" + TicketTitle: "## Support Ticket" TicketMessage: "Hello <@%ticketauthor%>, Thank you for creating a support ticket\nPlease wait patiently whilst a member of our team reaches out to you." TicketThumbnail: "https://images.emojiterra.com/google/android-pie/512px/1f39f.png" TicketCreatedAlert: ":ticket: Ticked Created: <#%ticketid%>" diff --git a/Configs/supportbot.yml b/Configs/supportbot.yml index 3498630..d57d7e0 100644 --- a/Configs/supportbot.yml +++ b/Configs/supportbot.yml @@ -13,7 +13,7 @@ # # SupportBot Configuration (supportbot.yml) -SupportBot_Version: "v8.4-DEV-2" +SupportBot_Version: "v8.4" # ------------------------- # General @@ -21,7 +21,7 @@ SupportBot_Version: "v8.4-DEV-2" General: Name: "SupportBot" - Token: "" + Token: "BOT_TOKEN" Addons: Enabled: true @@ -50,10 +50,10 @@ Activity: Embed: Colours: - General: 0x0cc559 - Success: 0x04b545 - Error: 0xd13030 - Warn: 0xfca117 + General: "#0cc559" + Success: "#04b545" + Error: "#d13030" + Warn: "#fca117" Footer: "SupportBot | Developed by Emerald Development" @@ -66,12 +66,12 @@ Embed: Roles: AutoRole: Enabled: true - Role: "1202669457751801917" + Role: "1111111111111111" StaffMember: - Staff: "996420644373811371" - Admin: "996419960442208326" - Moderator: "996420644373811371" + Staff: "1111111111111111" + Admin: "1111111111111111" + Moderator: "1111111111111111" Mod: AllowSupportStaff: false @@ -84,11 +84,11 @@ Roles: Welcome: Enabled: true - Channel: "1295788797065166869" + Channel: "1111111111111111" Leave: Enabled: true - Channel: "1295788797065166869" + Channel: "1111111111111111" # ---------------------------- # Suggestions @@ -96,8 +96,8 @@ Leave: Suggestions: Mode: "Channel" # Channel or Forum - ForumChannel: "1402655496477081671" - Channel: "1295788900094316706" + ForumChannel: "1111111111111111" + Channel: "1111111111111111" UpvoteEmoji: "✅" DownvoteEmoji: "❌" @@ -130,10 +130,10 @@ Suggestions: # 4 - Red Tags: - Created: "1418937323118137435" - Considering: "1418937237156139130" - Solved: "1418937168029679697" - Denied: "1418937185469464647" + Created: "1111111111111111" + Considering: "1111111111111111" + Solved: "1111111111111111" + Denied: "1111111111111111" # ------------------------- # Tickets @@ -141,7 +141,7 @@ Suggestions: VoiceTickets: Name: "%username%'s VC" - Category: "1419062819688550460" + Category: "1111111111111111" Ticket: TicketType: "threads" @@ -150,16 +150,16 @@ Ticket: # channels - Tickets will be created as channels in the TicketChannelsCategory # threads - Tickets will be created as threads through the "TicketHome" channel. - TicketHome: "1295784943204700171" + TicketHome: "1111111111111111" # What is TicketHome? # - Channel where the Ticket creation panel is sent. # - Channel where ticket threads are made. (only if ticket threads is enabled above.) # For TicketType: channels - TicketChannelsCategory: "1418988408193155112" - TicketChannelsCategory2: "1418988456167870615" # This will be used if the first category has reached the max channel limit. - TicketArchiveCategory: "1418988434600759348" + TicketChannelsCategory: "1111111111111111" + TicketChannelsCategory2: "1111111111111111" # This will be used if the first category has reached the max channel limit. + TicketArchiveCategory: "1111111111111111" # --- Channel: "ticket-" # The prefix for ticket channel names @@ -198,7 +198,7 @@ Ticket: ClaimTickets: Enabled: true - Channel: "1295789389619793961" + Channel: "1111111111111111" # Channel where the ticket assignments are sent for staff to claim. ClaimAcceptTime: 120000 @@ -221,7 +221,7 @@ Ticket: ReviewSystem: Enabled: false - Channel: "1304480728884445225" + Channel: "1111111111111111" UseModal: true Questions: @@ -232,9 +232,9 @@ Ticket: - "Have you tried resolving the issue yourself?" Log: - TicketDataLog: "1339271338761650290" + TicketDataLog: "1111111111111111" TickeDataTitle: "Ticket Data" - TicketBlacklistLog: "1339271338761650290" + TicketBlacklistLog: "1111111111111111" # ------------------------- # Buttons @@ -287,12 +287,12 @@ SelectMenus: # ------------------------- MessageDelete: - Channel: "1202671982932402246" + Channel: "1111111111111111" Colour: "#d92525" MessageUpdate: - Channel: "1202671982932402246" + Channel: "1111111111111111" Colour: "#f2a024" Translate: - TranslateLog: "1202671982932402246" + TranslateLog: "1111111111111111" diff --git a/Configs/ticket-panel.yml b/Configs/ticket-panel.yml index c8e6b5b..b14eadf 100644 --- a/Configs/ticket-panel.yml +++ b/Configs/ticket-panel.yml @@ -19,19 +19,28 @@ Panel: true -LayoutStyle: modern - # ---------------------------------------- # Ticket Panel Message Configuration #2b2d31 # ---------------------------------------- -PanelTitle: "SupportBot" -PanelColour: "#0cc559" +Style: + Title: "## SupportBot Ticket Creation" + Description: "Click on the button to file a `Ticket` and our team will try their best to assist you in the best way we can!" + Image: "https://i.imgur.com/dejQvkg.png" + Color: "#45b463" + # Leave Color empty to remove the color from the embed/container. + + Layout: "3" + +# Available Layout Styles +# "1" - Style 1 - Title & Text, Button at the top -- Image at the bottom +# "2" - Style 2 - Title & Text, Button at the bottom -- Image at the top +# "3" - Style 3 - The classic look - Title & Text at the top -- Image in the middle -- Button at the bottom Button: Text: "Create Ticket" Emoji: "🎫" - Color: "2" + Color: "3" # Available Button Styles # 1 - Blurple @@ -39,10 +48,15 @@ Button: # 3 - Red # 4 - Green -TicketPanel_Description: true -TicketPanel_Thumbnail: false -TicketPanel_Image: true +Settings: + Image: true -PanelMessage: "Click on the button to file a `Ticket` and our team will try their best to assist you in the best way we can!" -PanelThumbnail: "https://i.imgur.com/ieeZejl.png" -PanelImage: "https://i.imgur.com/dejQvkg.png" \ No newline at end of file + # Text and divider will appear above the image. + TopTitle: true + TopDivider: true + + # Text and divider will appear below the image. + BottomTitle: false + BottomDivider: false + + # Note: If Image is set to false, the bottom and top settings will look the samme. \ No newline at end of file diff --git a/Events/guildMemberAdd.js b/Events/guildMemberAdd.js index 58692a7..521b772 100644 --- a/Events/guildMemberAdd.js +++ b/Events/guildMemberAdd.js @@ -35,7 +35,8 @@ function getWelcomeThumbnail(client, member, iconCfg) { } function buildModernComponents(client, member) { - const container = new ContainerBuilder().setAccentColor( + const container = new ContainerBuilder() + .setAccentColor( parseInt(msgconfig.Welcome.Modern.Colour.replace("#", ""), 16) ); @@ -79,6 +80,7 @@ function buildModernComponents(client, member) { }); container.addActionRowComponents(row); + } return [container];