8.0.1 Update

This commit is contained in:
1tzEmerald committed 2024-07-30 17:45:35 +01:00
1 parent 9a6eece7a1
commit 4f14722e14
20 files changed
+1837 -629

No files matched your search

+2 -1
View File
@@ -81,7 +81,8 @@ module.exports = new Command({
const CloseButton = new Discord.ButtonBuilder()
.setCustomId("confirmCloseTicket")
.setLabel(supportbot.Ticket.Close.Confirmation_Button)
.setStyle(Discord.ButtonStyle.Danger);
.setEmoji(supportbot.Ticket.Close.Confirmation_Emoji)
.setStyle(supportbot.Ticket.Close.Confirmation_Style);
const row = new Discord.ActionRowBuilder().addComponents(CloseButton);
+10
View File
@@ -376,6 +376,16 @@ module.exports = new Command({
.setDescription("Close the ticket.")
.setEmoji(supportbot.SelectMenus.Tickets.CloseEmoji)
.setValue("ticketclose"),
new StringSelectMenuOptionBuilder()
.setLabel("Archive")
.setDescription("Acrhive the ticket.")
.setEmoji(supportbot.SelectMenus.Tickets.ArchiveEmoji)
.setValue("archiveticket"),
new StringSelectMenuOptionBuilder()
.setLabel("Lock Ticket")
.setDescription("Lock the ticket.")
.setEmoji(supportbot.SelectMenus.Tickets.LockEmoji)
.setValue("lockticket"),
new StringSelectMenuOptionBuilder()
.setLabel("Enable Invites")
.setDescription("Enable invites.")
+40 -37
View File
@@ -24,7 +24,7 @@ Welcome:
Embed:
Colour: "#f74343"
Title: "Welcome to ServerName"
Message: "> :smile: %joined_user% has just landed!"
Message: ":smile: %joined_user% has just landed!"
Thumbnail: "BOT"
ImageEnabled: false
@@ -34,7 +34,7 @@ Leave:
Embed:
Colour: "#f74343"
Title: "Goodbye!"
Message: "> :slight_frown: %joined_user% has recently dropped out!"
Message: ":slight_frown: %joined_user% has recently dropped out!"
Thumbnail: "BOT"
ImageEnabled: false
@@ -42,8 +42,8 @@ Leave:
Suggestions:
Sent_Title: "Suggestion Sent!"
Sent: "> :white_check_mark: **You have successfully sent a suggestion.**"
NoSelfVote: "> :x: **You cannot vote on your own suggestion.**"
Sent: ":white_check_mark: **You have successfully sent a suggestion.**"
NoSelfVote: ":x: **You cannot vote on your own suggestion.**"
RemoveVoteButton: "Remove Vote"
Ticket:
@@ -56,44 +56,47 @@ Ticket:
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."
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%>"
TicketExists: "> ❌ Ticket already exists"
TicketClaim: "> :white_check_mark: Ticket claimed by" #The user who claimed the ticket will be added to the end of this message
TicketUnclaim: "> :white_check_mark: Ticket unclaimed by" #The user who claimed the ticket will be added to the end of this message
TicketCreatedAlert: ":ticket: Ticked Created: <#%ticketid%>"
TicketExists: "❌ Ticket already exists"
TicketClaim: ":white_check_mark: Ticket claimed by" #The user who claimed the ticket will be added to the end of this message
TicketUnclaim: ":white_check_mark: Ticket unclaimed by" #The user who claimed the ticket will be added to the end of this message
DisableInvites: "> 🔒 Invites have been disabled for this ticket."
EnableInvites: "> 🔓 Invites have been enabled for this ticket."
TicketArchived: ":white_check_mark: Ticket archived."
TicketUnarchived: ":white_check_mark: Ticket unarchived."
TicketLocked: ":lock: Ticket is locked."
DisableInvites: "🔒 Invites have been disabled for this ticket."
EnableInvites: "🔓 Invites have been enabled for this ticket."
# Available Placeholders:
# <@%user%> - Tags the user who was added to the ticket.
Blacklisted: "> :x: You are not allowed to open a ticket"
Muted: "> :x: You are `Muted` and therefore not allowed to open any tickets"
InvalidSubject: "> No Reason Provided!"
Blacklisted: ":x: You are not allowed to open a ticket"
Muted: ":x: You are `Muted` and therefore not allowed to open any tickets"
InvalidSubject: "No Reason Provided!"
TranscriptSavedMessage: "📝 **Transcript Saved!**"
TicketLockMessage: "❌ **Ticket Locked!**"
TicketDeleteMessage: "⚠ **Ticket Deleting!**"
ClosingTicket: "> :warning: You have requested to close your support ticket."
ConfirmClose: "> Please confirm closing the ticket by clicking the button below."
CloseTimeout: "> Ticket close confirmation timed out."
ClosingTicket: ":warning: You have requested to close your support ticket."
ConfirmClose: "Please confirm closing the ticket by clicking the button below."
CloseTimeout: "Ticket close confirmation timed out."
ClaimTickets:
ClaimTitle: "Incoming Support Request!"
ClaimMessage: "> A new ticket has been created by <@!%user%>. Click the button below to claim this ticket."
ClaimMessage_Edit: "> <#%channel%> was claimed by <@!%user%>."
ClaimMessage: "A new ticket has been created by <@!%user%>. Click the button below to claim this ticket."
ClaimMessage_Edit: "<#%channel%> was claimed by <@!%user%>."
ClaimedTitle: "Ticket Claimed!"
Claimed: "> You have successfully claimed this ticket. <#%channel%>"
Claimed: "You have successfully claimed this ticket. <#%channel%>"
NoPermsToClaimTitle: "Error, no permissions!"
NoPermsToClaim: "> :x: **Err!** You do not permissions to claim this ticket."
NoPermsToClaim: ":x: **Err!** You do not permissions to claim this ticket."
ReassigningTitle: "Reassigning!..."
ReassigningMessage: "> <@%user%> did not claim the ticket. **Reassigning...**"
ReassigningMessage: "<@%user%> did not claim the ticket. **Reassigning...**"
TicketStats:
OpenTickets: "✅ Open Tickets"
@@ -104,37 +107,37 @@ TicketStats:
AddUser:
NotInTicket_Title: "Ticket Invitation"
NotInTicket_Description: "> This command can only be used within a ticket thread."
NotInTicket_Description: "This command can only be used within a ticket thread."
Invite_Title: "User Invited"
Invite_Description: "> %username% has been invited to join the ticket."
Invite_Description: "%username% has been invited to join the ticket."
DM_Title: "Ticket Invitation"
DM_Description: "> You have been invited to join the ticket %channelname%. Do you accept?"
DM_Description: "You have been invited to join the ticket %channelname%. Do you accept?"
Accept_Label: "Accept"
Reject_Label: "Reject"
ViewTicket_Label: "Go to Ticket"
Accepted_Title: "Invitation Accepted"
Accepted_Message: "> You have been added to the ticket."
Accepted_Message: "You have been added to the ticket."
AddedToTicket_Title: "Added to Ticket"
AddedToTicket_Description: "> You have been added to the ticket %channel_link%."
AddedToTicket_Description: "You have been added to the ticket %channel_link%."
Declined_Title: "Invitation Declined"
Declined_Message: "> You have declined the invitation."
Declined_Message: "You have declined the invitation."
NoResponse_Title: "No Response"
NoResponse_Message: "> You did not respond in time. Please contact staff if you wish to join the ticket."
NoResponse_Message: "You did not respond in time. Please contact staff if you wish to join the ticket."
Error_Title: "Error"
Error_Adding: "> There was an error adding you to the ticket. Please try again."
Error_Adding: "There was an error adding you to the ticket. Please try again."
DM_Error_Title: "Error"
DM_Error_Description: "> Unable to send a DM to %username%. Please ensure your DMs are enabled."
DM_Error_Description: "Unable to send a DM to %username%. Please ensure your DMs are enabled."
Unexpected_Error_Title: "Error"
Unexpected_Error_Description: "> An unexpected error occurred: %error%"
Unexpected_Error_Description: "An unexpected error occurred: %error%"
RemoveUser:
NotInTicket_Title: "Error"
@@ -163,11 +166,11 @@ ForceAddUser:
Error_Adding: "There was an error adding the user to the ticket."
Error:
IncorrectPerms: "> :x: **Err!** You do not have the correct permissions to use this."
InvalidChannel: "> :x: **Err!** Channel not found. Please create it!"
UserNotFound: "> :x: **Err!** This user doesn't exist, Are they in this server?"
NoValidTicket: "> :warning: You cannot execute this command here."
TicketExists: "> :warning: This ticket cannot be opened, It already exists!"
IncorrectPerms: ":x: **Err!** You do not have the correct permissions to use this."
InvalidChannel: ":x: **Err!** Channel not found. Please create it!"
UserNotFound: ":x: **Err!** This user doesn't exist, Are they in this server?"
NoValidTicket: ":warning: You cannot execute this command here."
TicketExists: ":warning: This ticket cannot be opened, It already exists!"
+2 -3
View File
@@ -16,12 +16,11 @@ General:
Tokens: 400
# Max tokens you can set is 400
# For more information about tokens, go to https://openai.com/api/pricing/
OpenAI_Key: "OPENAI_KEY"
OpenAI_Key: "OPEN_AI_KEY_HERE"
# To create an OpenAI API key, go to https://platform.openai.com/api-keys
PastebinAPI_Key: "PASTEBIN_KEY"
PastebinAPI_Key: "PASTEBIN_API_KEY_HERE"
# You can get your Pastebin API Key from https://pastebin.com
PastebinAPI_URL: "https://pastebin.com/api/api_post.php"
+25 -6
View File
@@ -145,11 +145,22 @@ Ticket:
StaffOnly: true
# Set to false is anyone is able to close a ticket.
Confirmation_Button: "Confirm Close"
Confirmation_Emoji: "🗑️"
Confirmation_Style: "2"
Title: "Are you sure you want to close this ticket?"
# Available Button Styles
# 1 - Blurple
# 2 - Grey
# 3 - Green
# 4 - Red
Invites:
StaffOnly: true
LockedTickets:
Channel: "1267856939275124809"
ClaimTickets:
Enabled: true
Channel: "1249723473757077624"
@@ -188,6 +199,15 @@ Buttons:
ClaimEmoji: "🧑‍💻"
ClaimStyle: "1"
Unarchive: "Unarchive Ticket"
Unarchive_Emoji: "♻️"
Unarchive_Style: "2"
Unlock: "Unlock Ticket"
Unlock_Emoji: "🔓"
Unlock_Style: "2"
# Available Button Styles
# 1 - Blurple
# 2 - Grey
@@ -202,14 +222,13 @@ Buttons:
SelectMenus:
Tickets:
PanelEmoji: "⚙️"
CloseEmoji: "🗑️"
ArchiveEmoji: "♻️"
LockTicketEmoji: "🔒"
UnLockTicketEmoji: "🔓"
EnableInvitesEmoji: "🔒"
DisableInvitesEmoji: "🔓"
AddUserEmoji: "➕"
RemoveUserEmoji: "➖"
LockEmoji: "🔐"
EnableInvitesEmoji: "📤"
DisableInvitesEmoji: "📥"
# -------------------------
+1 -7
View File
@@ -1,7 +1 @@
{
"419821884431925260": {
"bio": "Hi",
"timezone": "",
"isClockedIn": false
}
}
{}
-5
View File
@@ -1,5 +0,0 @@
{
"bio": "",
"timezone": "",
"clockedIn": false
}
-5
View File
@@ -1,5 +0,0 @@
{
"clockedIn": false,
"bio": "Hi",
"timezone": "GMT"
}
-5
View File
@@ -1,5 +0,0 @@
{
"bio": "This is the most W bio",
"timezone": "cst",
"clockedIn": false
}
-5
View File
@@ -1,5 +0,0 @@
{
"bio": "",
"timezone": "",
"clockedIn": true
}
+1 -3
View File
@@ -1,3 +1 @@
[
"419821884431925260"
]
{}
+1 -22
View File
@@ -1,22 +1 @@
{
"1250864227460186240": {
"suggestion": "hi",
"author": "419821884431925260",
"upvotes": [
"419821884431925260"
],
"downvotes": []
},
"1250900161958248533": {
"suggestion": "blob",
"author": "419821884431925260",
"upvotes": [],
"downvotes": []
},
"1260279162854441042": {
"suggestion": "test",
"author": "419821884431925260",
"upvotes": [],
"downvotes": []
}
}
{}
+1 -265
View File
@@ -1,269 +1,5 @@
{
"tickets": [
{},
{
"id": "1253862843053510687",
"name": "ticket-0021",
"user": "419821884431925260",
"number": "0021",
"reason": "> No Reason Provided!",
"open": true,
"subUsers": [],
"createdAt": "2024-06-22T00:03:18.227Z",
"claimedAt": null
},
{
"id": "1253863588012232727",
"name": "ticket-0022",
"user": "419821884431925260",
"number": "0022",
"reason": "> No Reason Provided!",
"open": true,
"subUsers": [],
"createdAt": "2024-06-22T00:06:16.126Z",
"claimedAt": "2024-06-22T00:09:12.693Z",
"claimedBy": "419821884431925260"
},
{
"id": "1255499438483574847",
"name": "ticket-0023",
"user": "419821884431925260",
"number": "0023",
"reason": "> No Reason Provided!",
"open": true,
"subUsers": [],
"createdAt": "2024-06-26T12:26:35.729Z",
"claimedAt": null
},
{
"id": "1255500796355678229",
"name": "ticket-0024",
"user": "419821884431925260",
"number": "0024",
"reason": "> No Reason Provided!",
"open": true,
"subUsers": [],
"createdAt": "2024-06-26T12:31:56.888Z",
"claimedAt": "2024-06-26T12:32:41.240Z",
"claimedBy": "419821884431925260"
},
{
"id": "1255501873386094603",
"name": "ticket-0025",
"user": "419821884431925260",
"number": "0025",
"reason": "> No Reason Provided!",
"open": false,
"subUsers": [],
"createdAt": "2024-06-26T12:36:13.810Z",
"claimedAt": null
},
{
"id": "1255508653906198709",
"name": "ticket-0026",
"user": "419821884431925260",
"number": "0026",
"reason": "> No Reason Provided!",
"open": true,
"subUsers": [],
"createdAt": "2024-06-26T13:03:10.321Z",
"claimedAt": null
},
{
"id": "1256299016023572572",
"name": "ticket-0027",
"user": "419821884431925260",
"number": "0027",
"reason": "> No Reason Provided!",
"open": false,
"subUsers": [],
"createdAt": "2024-06-28T17:23:50.113Z",
"claimedAt": null
},
{
"id": "1256300956824633426",
"name": "ticket-0028",
"user": "419821884431925260",
"number": "0028",
"reason": "> No Reason Provided!",
"open": false,
"subUsers": [],
"createdAt": "2024-06-28T17:31:31.454Z",
"claimedAt": null
},
{
"id": "1256302271461986507",
"name": "ticket-0029",
"user": "419821884431925260",
"number": "0029",
"reason": "> No Reason Provided!",
"open": false,
"subUsers": [],
"createdAt": "2024-06-28T17:36:44.673Z",
"claimedAt": null
},
{
"id": "1256303116505317457",
"name": "ticket-0030",
"user": "419821884431925260",
"number": "0030",
"reason": "> No Reason Provided!",
"open": true,
"subUsers": [],
"createdAt": "2024-06-28T17:40:06.292Z",
"claimedAt": null
},
{
"id": "1257775687562166304",
"name": "ticket-0031",
"user": "419821884431925260",
"number": "0031",
"reason": "> No Reason Provided!",
"open": false,
"subUsers": [],
"createdAt": "2024-07-02T19:11:33.760Z",
"claimedAt": null
},
{
"id": "1257776136843427841",
"name": "ticket-0032",
"user": "419821884431925260",
"number": "0032",
"reason": "> No Reason Provided!",
"open": false,
"subUsers": [],
"createdAt": "2024-07-02T19:13:20.641Z",
"claimedAt": null
},
{
"id": "1257777774483996795",
"name": "ticket-0033",
"user": "419821884431925260",
"number": "0033",
"reason": "> No Reason Provided!",
"open": false,
"subUsers": [],
"createdAt": "2024-07-02T19:19:51.116Z",
"claimedAt": null
},
{
"id": "1257778630600167535",
"name": "ticket-0034",
"user": "419821884431925260",
"number": "0034",
"reason": "> No Reason Provided!",
"open": false,
"subUsers": [],
"createdAt": "2024-07-02T19:23:15.328Z",
"claimedAt": null
},
{
"id": "1257780259374366841",
"name": "ticket-0035",
"user": "419821884431925260",
"number": "0035",
"reason": "> No Reason Provided!",
"open": false,
"subUsers": [],
"createdAt": "2024-07-02T19:29:43.607Z",
"claimedAt": null
},
{
"id": "1257782171389657180",
"name": "ticket-0036",
"user": "419821884431925260",
"number": "0036",
"reason": "> No Reason Provided!",
"open": true,
"subUsers": [],
"createdAt": "2024-07-02T19:37:19.467Z",
"claimedAt": "2024-07-02T19:43:12.873Z",
"claimedBy": "419821884431925260"
},
{
"id": "1259980339816697907",
"name": "ticket-0037",
"user": "419821884431925260",
"number": "0037",
"reason": "> No Reason Provided!",
"open": false,
"subUsers": [],
"createdAt": "2024-07-08T21:12:06.009Z",
"claimedAt": "2024-07-08T21:12:17.454Z",
"claimedBy": "419821884431925260"
},
{
"id": "1259980831749832807",
"name": "ticket-0038",
"user": "419821884431925260",
"number": "0038",
"reason": "> No Reason Provided!",
"open": false,
"subUsers": [],
"createdAt": "2024-07-08T21:14:01.173Z",
"claimedAt": "2024-07-08T21:14:12.930Z",
"claimedBy": "419821884431925260"
},
{
"id": "1260004238856163470",
"name": "ticket-0039",
"user": "419821884431925260",
"number": "0039",
"reason": "> No Reason Provided!",
"open": true,
"subUsers": [],
"createdAt": "2024-07-08T22:47:02.254Z",
"claimedAt": "2024-07-08T22:47:11.156Z",
"claimedBy": "419821884431925260"
},
{
"id": "1260009197207027846",
"name": "ticket-0040",
"user": "419821884431925260",
"number": "0040",
"reason": "test",
"open": true,
"subUsers": [],
"createdAt": "2024-07-08T23:06:44.329Z",
"claimedAt": "2024-07-08T23:06:51.047Z",
"claimedBy": "419821884431925260"
},
{
"id": "1260257345292865556",
"name": "ticket-0041",
"user": "419821884431925260",
"number": "0041",
"reason": "blob",
"open": true,
"subUsers": [
"709003903353618506",
"709003903353618506",
"709003903353618506",
"709003903353618506",
"709003903353618506",
"709003903353618506",
"709003903353618506",
"419821884431925260",
"419821884431925260",
"709003903353618506",
"419821884431925260",
"709003903353618506"
],
"createdAt": "2024-07-09T15:32:47.543Z",
"claimedAt": "2024-07-09T15:33:06.442Z",
"claimedBy": "419821884431925260"
},
{
"id": "1260263275464233060",
"name": "ticket-0042",
"user": "419821884431925260",
"number": "0042",
"reason": "blob",
"open": true,
"subUsers": [],
"createdAt": "2024-07-09T15:56:21.766Z",
"claimedAt": "2024-07-09T15:58:15.205Z",
"claimedBy": "709003903353618506"
}
{}
]
}
+2 -2
View File
@@ -1,4 +1,4 @@
{
"id": 43,
"TicketPanelID": "1250863985335472312"
"id": 0,
"TicketPanelID": "000000000000000000"
}
+60 -4
View File
@@ -16,15 +16,12 @@ try {
}
module.exports = new Event("interactionCreate", async (client, interaction) => {
console.log("Interaction received:", interaction.type); // Log interaction type
if (interaction.type === Discord.InteractionType.ApplicationCommand) {
const command = client.commands.find(
(cmd) => cmd.name.toLowerCase() === interaction.commandName
);
console.log("Command received:", interaction.commandName); // Log command name
if (interaction.user.bot || !interaction.guild) return;
const NotValid = new Discord.EmbedBuilder()
@@ -68,7 +65,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
await interaction.showModal(modal);
} else {
console.log("Running command:", command.name); // Log running command
console.log("\u001b[32m", "[Executed]", "\u001b[37;1m", `${interaction.user.username} has executed ${command.name}`);
await command.run(interaction);
}
} catch (error) {
@@ -109,6 +106,50 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
}
break;
case "archiveticket":
const arcembed = new Discord.EmbedBuilder()
.setDescription(msgconfig.Ticket.TicketArchived)
.setColor(supportbot.Embed.Colours.Success);
const CloseButton = new Discord.ButtonBuilder()
.setCustomId("confirmCloseTicket")
.setLabel(supportbot.Ticket.Close.Confirmation_Button)
.setEmoji(supportbot.Ticket.Close.Confirmation_Emoji)
.setStyle(supportbot.Ticket.Close.Confirmation_Style);
const unarchiveButton = new Discord.ButtonBuilder()
.setCustomId("unarchiveTicket")
.setLabel(supportbot.Buttons.Tickets.Unarchive)
.setEmoji(supportbot.Buttons.Tickets.Unarchive_Emoji)
.setStyle(supportbot.Buttons.Tickets.Unarchive_Style);
const ArchivedOptions = new Discord.ActionRowBuilder()
.addComponents(CloseButton, unarchiveButton);
await interaction.channel.send({
embeds: [arcembed],
components: [ArchivedOptions],
});
await interaction.channel.setArchived(true);
break;
case "lockticket":
const lockembed = new Discord.EmbedBuilder()
.setDescription(msgconfig.Ticket.TicketLocked)
.setColor(supportbot.Embed.Colours.Success);
await interaction.channel.send({
embeds: [lockembed],
components: [],
ephemeral: true,s
});
await interaction.channel.setLocked(true);
break;
case "enableinvites":
await handleInvites(interaction, true);
break;
@@ -121,6 +162,20 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
}
if (interaction.isButton()) {
if (interaction.customId === "unarchiveTicket") {
await interaction.channel.setArchived(false);
const unrcembed = new Discord.EmbedBuilder()
.setDescription(msgconfig.Ticket.TicketUnarchived)
.setColor(supportbot.Embed.Colours.Success);
await interaction.update({
embeds: [unrcembed],
components: [],
});
}
if (interaction.customId === "createticket") {
if (supportbot.Ticket.TicketReason) {
const modal = new Discord.ModalBuilder()
@@ -320,6 +375,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
async function handleInvites(interaction, enable) {
if (supportbot.Ticket.Invites.StaffOnly) {
const { getRole, getChannel } = interaction.client;
const SupportStaff = await getRole(supportbot.Roles.StaffMember.Staff, interaction.guild);
const Admin = await getRole(supportbot.Roles.StaffMember.Admin, interaction.guild);
+68 -140
View File
@@ -14,11 +14,10 @@ function loadConfig(path) {
}
}
const supportbotai = loadConfig("./Configs/supportbot-ai.yml");
const supportbot = loadConfig("./Configs/supportbot.yml");
const cmdconfig = loadConfig("./Configs/commands.yml");
const msgconfig = loadConfig("./Configs/messages.yml");
const supportbotai = yaml.load(fs.readFileSync("./Configs/supportbot-ai.yml"));
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"));
// Validate configuration values
function validateConfig(config, keys) {
keys.forEach(key => {
@@ -28,11 +27,6 @@ function validateConfig(config, keys) {
});
}
validateConfig(supportbotai, ['General', 'Channels', 'Messages']);
validateConfig(supportbot, ['Embed']);
validateConfig(cmdconfig, ['Ping']);
validateConfig(msgconfig, ['ErrorResponse', 'OpenAIError']);
const CHANNELS = [supportbotai.Channels.AIChannel];
// Initialize Discord client
@@ -69,170 +63,104 @@ async function createPaste(content) {
}
}
// Function to fetch latest commands and configuration
function getDynamicData() {
const commands = loadConfig("./Configs/commands.yml");
const configurations = {
supportbotai: loadConfig("./Configs/supportbot-ai.yml"),
supportbot: loadConfig("./Configs/supportbot.yml"),
cmdconfig: loadConfig("./Configs/commands.yml"),
msgconfig: loadConfig("./Configs/messages.yml"),
};
return { commands, configurations };
}
// Event handler for message creation
module.exports = new Event("messageCreate", async (client, message) => {
if (message.author.bot || !message.guild) return;
if (!CHANNELS.includes(message.channelId) && !message.mentions.users.has(client.user.id)) return;
const { commands, configurations } = getDynamicData();
if (supportbotai.Enabled) {
if (supportbotai.Enabled) {
const sendTypingInterval = setInterval(() => {
message.channel.sendTyping();
}, 5000);
const sendTypingInterval = setInterval(() => {
message.channel.sendTyping();
}, 5000);
let conversation = [{
role: "system",
content: `SupportBot is your friendly neighbourhood support bot. Current date and time: ${new Date().toLocaleString()}.
The bot uses a modular command handler where commands are loaded dynamically from the './Commands' directory. Each command has a name, description, and execute method.
The main Client class structure:
- Commands are loaded from the './Commands/' directory.
- Configs are loaded from the './Configs/' directory if enabled.
- Events are loaded from the './Events/' directory.
- Addons are loaded from the './Addons/' directory if enabled.
Example of a command structure:
{
module.exports = new Command({
name: cmdconfig.Ping.Command,
description: cmdconfig.Ping.Description,
options: [],
permissions: cmdconfig.Ping.Permission,
)}
}
let conversation = [{
role: "system",
content: "SupportBot is your friendly neighbourhood support bot."
}];
You can find more information about the commands and configuration files in the 'Configs' and 'Commands' directories.
let prevMessages = await message.channel.messages.fetch({ limit: 10 });
prevMessages = prevMessages.reverse().filter(msg => !msg.author.bot || msg.author.id === client.user.id);
All commands are loaded into the bot at startup from ./Events/ready.js and ./Client.js.
prevMessages.forEach((msg) => {
const username = msg.author.username.replace(/\s+/g, '_').replace(/[^\w\s]/gi, '');
If someone asks you to do something, you can use the 'assist' command to have the bot respond, For example: "Can I speak to a support agent?", You would respond by opening a ticket which is the /Commands/ticket.js file or you can tell them to create a ticket in the channel defined as supportbot.Ticket.
conversation.push({
role: msg.author.id === client.user.id ? "assistant" : "user",
name: username,
content: msg.content,
});
});
You can find the source code for the bot at https://github.com/EmeraldServices/SupportBot.
You then need to understand how the bot works. Interactions are handled by the ./Events/interactionCreate.js file.
Commands are filtered based on configuration settings and loaded into the bot at startup.
Xiled Gaming Network (XGN) is a gaming community that typically offers various services and activities for gamers.
Xiled Gaming Network (XGN) has 4 divisions, Team Xiled International (TXI), The XiledOnes (TXO), Dealers of Death (DOD), Psychotic Solutions (PS)
Xiled Gaming Network (XGN) can be found at https://officialxgn.gg/handbook/, This is where you can the code of conduct, policies and other important information for members.
You can join XGN with the discord - discord.gg/xgn
You can apply to join the XGN Clan - join.officialxgn.gg
You can find the founders of XGN under the history section of the handbook. https://officialxgn.gg/handbook/.
`
}];
let prevMessages = await message.channel.messages.fetch({ limit: 10 });
prevMessages = prevMessages.reverse().filter(msg => !msg.author.bot || msg.author.id === client.user.id);
prevMessages.forEach((msg) => {
const username = msg.author.username.replace(/\s+/g, '_').replace(/[^\w\s]/gi, '');
conversation.push({
role: msg.author.id === client.user.id ? "assistant" : "user",
name: username,
content: msg.content,
});
try {
const response = await openai.chat.completions.create({
model: supportbotai.General.Model,
messages: conversation,
max_tokens: supportbotai.General.Tokens,
});
try {
const response = await openai.chat.completions.create({
model: supportbotai.General.Model,
messages: conversation,
max_tokens: supportbotai.General.Tokens,
});
clearInterval(sendTypingInterval);
clearInterval(sendTypingInterval);
if (response.choices && response.choices.length > 0) {
const replyContent = response.choices[0].message.content;
if (response.choices && response.choices.length > 0) {
const replyContent = response.choices[0].message.content;
const SupportBotAI = new Discord.EmbedBuilder()
.setAuthor({ name: supportbotai.General.Name, iconURL: client.user.displayAvatarURL() })
.setDescription(replyContent)
.setColor(supportbotai.Embed.Color)
.setFooter({ text: supportbotai.Embed.Footer, iconURL: message.author.displayAvatarURL() })
.setTimestamp();
if (replyContent.toLowerCase().startsWith("generate image:")) {
const prompt = replyContent.substring(15).trim();
const imageUrl = await generateImage(prompt);
if (replyContent.length > 2000) {
const pasteLink = await createPaste(replyContent);
const SupportBotAIImage = new Discord.EmbedBuilder()
.setAuthor({ name: supportbotai.General.Name, iconURL: client.user.displayAvatarURL() })
.setDescription(`Here is the image generated for your prompt: "${prompt}"`)
.setImage(imageUrl)
.setColor(supportbotai.Embed.Color)
.setFooter({ text: supportbotai.Embed.Footer, iconURL: message.author.displayAvatarURL() })
.setTimestamp();
message.reply({ embeds: [SupportBotAIImage] });
} else {
const SupportBotAI = new Discord.EmbedBuilder()
.setAuthor({ name: supportbotai.General.Name, iconURL: client.user.displayAvatarURL() })
.setDescription(replyContent)
.setColor(supportbotai.Embed.Color)
.setFooter({ text: supportbotai.Embed.Footer, iconURL: message.author.displayAvatarURL() })
.setTimestamp();
if (replyContent.length > 2000) {
const pasteLink = await createPaste(replyContent);
const SupportBotAIPastebin = new Discord.EmbedBuilder()
.setAuthor({ name: supportbotai.General.Name, iconURL: client.user.displayAvatarURL() })
.setDescription(supportbotai.Messages.MessageTooLong.replace("{pastebin}", pasteLink))
.setColor(supportbotai.Embed.Color)
.setFooter({ text: supportbotai.Embed.Footer, iconURL: message.author.displayAvatarURL() })
.setTimestamp();
message.reply({ embeds: [SupportBotAIPastebin] });
} else {
message.reply({ embeds: [SupportBotAI] });
}
}
} else {
const SupportBotAIErrorResponse = new Discord.EmbedBuilder()
const SupportBotAIPastebin = new Discord.EmbedBuilder()
.setAuthor({ name: supportbotai.General.Name, iconURL: client.user.displayAvatarURL() })
.setDescription(supportbotai.Messages.ErrorResponse)
.setDescription(supportbotai.Messages.MessageTooLong.replace("{pastebin}", pasteLink))
.setColor(supportbotai.Embed.Color)
.setFooter({ text: supportbotai.Embed.Footer, iconURL: message.author.displayAvatarURL() })
.setTimestamp();
message.reply({ embeds: [SupportBotAIErrorResponse], ephemeral: true });
message.reply({ embeds: [SupportBotAIPastebin] });
} else {
message.reply({ embeds: [SupportBotAI] });
}
} catch (error) {
clearInterval(sendTypingInterval);
} else {
const SupportBotAIErrorResponse = new Discord.EmbedBuilder()
.setAuthor({ name: supportbotai.General.Name, iconURL: client.user.displayAvatarURL() })
.setDescription(supportbotai.Messages.OpenAIError)
.setColor(supportbot.Embed.Colours.Error)
.setDescription(supportbotai.Messages.ErrorResponse)
.setColor(supportbotai.Embed.Color)
.setFooter({ text: supportbotai.Embed.Footer, iconURL: message.author.displayAvatarURL() })
.setTimestamp();
console.error('OpenAI Error:', error);
message.reply({ embeds: [SupportBotAIErrorResponse], ephemeral: true });
}
}
} catch (error) {
clearInterval(sendTypingInterval);
if (!supportbotai.Enabled) {
const AIDisabled = new Discord.EmbedBuilder()
const SupportBotAIErrorResponse = new Discord.EmbedBuilder()
.setAuthor({ name: supportbotai.General.Name, iconURL: client.user.displayAvatarURL() })
.setDescription(supportbotai.Messages.AIDisabled)
.setDescription(supportbotai.Messages.OpenAIError)
.setColor(supportbot.Embed.Colours.Error)
.setFooter({ text: supportbotai.Embed.Footer, iconURL: message.author.displayAvatarURL() })
.setTimestamp();
message.reply({ embeds: [AIDisabled], ephemeral: true });
return;
console.error('OpenAI Error:', error);
message.reply({ embeds: [SupportBotAIErrorResponse], ephemeral: true });
}
});
}
if (supportbotai.Enabled === false) {
const AIDisabled = new Discord.EmbedBuilder()
.setAuthor({ name: supportbotai.General.Name, iconURL: client.user.displayAvatarURL() })
.setDescription(supportbotai.Messages.AIDisabled)
.setColor(supportbot.Embed.Colours.Error)
.setFooter({ text: supportbotai.Embed.Footer, iconURL: message.author.displayAvatarURL() })
.setTimestamp();
message.reply({ embeds: [AIDisabled], ephemeral: true })
return;
}
});
+25 -80
View File
@@ -59,7 +59,7 @@ module.exports = new Event("ready", async (client, interaction) => {
});
}
console.log(`\u001b[32m`, `――――――――――――――――――――――――――――――――――――――――――――`);
console.log(`\u001b[33m`, `――――――――――――――――――――――――――――――――――――――――――――`);
console.log(` `);
console.log(`\u001b[31m`, `┏━━━┓╋╋╋╋╋╋╋╋╋╋╋╋╋┏┓┏━━┓╋╋╋┏┓`);
console.log(`\u001b[31m`, `┃┏━┓┃╋╋╋╋╋╋╋╋╋╋╋╋┏┛┗┫┏┓┃╋╋┏┛┗┓`);
@@ -70,60 +70,22 @@ module.exports = new Event("ready", async (client, interaction) => {
console.log(`\u001b[31m`, `┗╋╋╋╋╋╋╋┃┃╋┃┃`);
console.log(`\u001b[31m`, `╋╋╋╋╋╋╋┗┛╋┗┛`);
console.log(` `);
console.log(`\u001b[32m`, `――――――――――――――――――――――――――――――――――――――――――――`);
console.log(`\u001b[33m`, `――――――――――――――――――――――――――――――――――――――――――――`);
console.log(` `);
console.log(`\u001b[33m`, `${supportbot.General.Name} | [${supportbot.SupportBot_Version}]`, `\u001b[32m`, `Connected to Discord`,);
console.log("\u001b[32m", "SupportBot created by Emerald Development ");
console.log(` `);
console.log(
`\u001b[31m`,
`${supportbot.General.Name} | [${supportbot.SupportBot_Version}]`,
`\u001b[32m`,
`Connected to Discord`,
);
console.log(`\u001b[31m`, `SupportBot proudly created by Emerald Development`);
console.log(`\u001b[33m`, `――――――――――――――――― [Links] ――――――――――――――――――`);
console.log("\u001b[32m", "Discord: https://dsc.gg/emerald-dev");
console.log("\u001b[32m", "Website: https://emeraldsrv.com");
console.log("\u001b[32m", "Community: https://community.emeraldsrv.com");
console.log("\u001b[32m", "Documentation: https://docs.emeraldsrv.com");
console.log(` `);
console.log(
`\u001b[31m`,
`Discord`,
`\u001b[32m`,
`https://dsc.gg/emerald-dev`,
);
console.log(
`\u001b[31m`,
`Website`,
`\u001b[32m`,
`https://emeraldsrv.com`,
);
console.log(
`\u001b[31m`,
`Marketplace`,
`\u001b[32m`,
`https://market.emeraldsrv.com`,
);
console.log(
`\u001b[31m`,
`Documentation`,
`\u001b[32m`,
`https://emeraldsrv.com/third-party`,
);
console.log(`\u001b[33m`, `――――――――――――――――― [Invite] ――――――――――――――――――`);
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[31m`,
`Invite URL:`,
`\u001b[36m`,
`https://discord.com/api/oauth2/authorize?client_id=` +
client.user.id +
`&permissions=8&scope=bot%20applications.commands`
);
console.log(` `);
console.log(`\u001b[32m`, `――――――――――――――――――――――――――――――――――――――――――――`);
console.log(`\u001b[33m`, `――――――――――――――――― [Config Check] ――――――――――――――――――`);
console.log("\u001b[32m", "Config initialization...");
const roles = [
supportbot.Roles.StaffMember.Admin,
@@ -168,35 +130,18 @@ module.exports = new Event("ready", async (client, interaction) => {
// if (!find) missingCat.push(cat);
// }
if (missingR.length > 0) {
console.log(
"\u001b[31m",
`[MISSING CONFIGURATION]`,
"\u001b[33m",
`The following Roles could not be found in your server.\n`, `\u001b[31m`, `[${missingR.join(
", "
)}]`, `\n `,
);
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(', ')}`);
}
if (missingC.length > 0) {
console.log(
"\u001b[31m",
`[MISSING CONFIGURATION]`,
"\u001b[33m",
`The following Channels could not be found in your server.\n`, `\u001b[31m`, `[${missingC.join(
", "
)}]`, `\n `
);
}
if (missingCat.length > 0) {
console.log(
"\u001b[31m",
`[MISSING CONFIGURATION]`,
"\u001b[33m",
`The following Categories could not be found in your server.\n`, `\u001b[31m`, `[${missingCat.join(
", "
)}]`, `\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(` `);
});
+6 -6
View File
@@ -105,7 +105,7 @@ class Client extends Discord.Client {
const commands = commandFiles.map((file) => require(`../Commands/${file}`));
// Load main commands
console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬");
console.log(`\u001b[33m`, "――――――――――――――――――――――――――――――――――――――――――――");
commands.forEach((cmd) => {
console.log(`\u001b[32m`, `[CMD]`, `\u001b[37;1m`, `${cmd.name}`, `\u001b[32;1m`, "Loaded");
@@ -113,7 +113,7 @@ class Client extends Discord.Client {
});
// Load addon commands and events
console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬");
console.log(`\u001b[33m`, "▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬");
if (supportbot.General.Addons.Enabled) {
const addonFiles = fs.readdirSync("./Addons").filter((file) => file.endsWith(".js"));
@@ -126,7 +126,7 @@ class Client extends Discord.Client {
// Addons
console.log(" ");
console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬");
console.log(`\u001b[33m`, "▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬");
addons.forEach((addon) => {
console.log(
@@ -151,7 +151,7 @@ class Client extends Discord.Client {
}
});
console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬");
console.log(`\u001b[33m`, "▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬");
}
// Register Slash Commands
@@ -167,7 +167,7 @@ class Client extends Discord.Client {
});
console.log(" ");
console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬");
console.log(`\u001b[33m`, "▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬");
fs.readdirSync("./Events").filter((file) => file.endsWith(".js")).forEach((file) => {
const event = require(`../Events/${file}`);
@@ -175,7 +175,7 @@ class Client extends Discord.Client {
this.on(event.event, (...args) => event.run(this, ...args));
});
console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬");
console.log(`\u001b[33m`, "▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬");
if (process.argv[2] !== "test") {
await this.login(token);
} else {
-33
View File
@@ -1,33 +0,0 @@
const fs = require("fs");
const yaml = require("js-yaml");
const axios = require("axios");
const supportbotai = yaml.load(fs.readFileSync("./Configs/supportbot-ai.yml", "utf8"));
async function generateImage(prompt, negativePrompt, cfgScale) {
try {
const response = await axios.post('https://api.pepperai.xyz/generate', {
prompt: prompt,
negativePrompt: negativePrompt,
cfgScale: cfgScale
}, {
headers: {
'Authorization': `Bearer ${supportbotai.General.PepperAI_Key}`,
'Content-Type': 'application/json'
}
});
console.log('PepperAI Response:', response.data); // Log the entire response for debugging
if (response.data && response.data.imageUrl) {
return response.data.imageUrl;
} else {
throw new Error(`Invalid response structure: ${JSON.stringify(response.data)}`);
}
} catch (error) {
console.error('PepperAI Image Generation Error:', error);
throw error;
}
}
module.exports = generateImage;
+1593
View File
File diff suppressed because it is too large. Load diff