v8.1
This commit is contained in:
1 parent
fd65d0a9a7
commit
9a6eece7a1
20 files changed
+900
-374
No files matched your search
@@ -0,0 +1,193 @@
|
|||||||
|
const fs = require("fs");
|
||||||
|
const {
|
||||||
|
EmbedBuilder,
|
||||||
|
ApplicationCommandOptionType,
|
||||||
|
ApplicationCommandType,
|
||||||
|
ActionRowBuilder,
|
||||||
|
ButtonBuilder,
|
||||||
|
ButtonStyle,
|
||||||
|
} = require("discord.js");
|
||||||
|
const yaml = require("js-yaml");
|
||||||
|
|
||||||
|
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||||
|
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
||||||
|
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
||||||
|
|
||||||
|
const Command = require("../Structures/Command.js");
|
||||||
|
|
||||||
|
module.exports = new Command({
|
||||||
|
name: cmdconfig.AddUser.Command,
|
||||||
|
description: cmdconfig.AddUser.Description,
|
||||||
|
type: ApplicationCommandType.ChatInput,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "user",
|
||||||
|
description: "The user to add",
|
||||||
|
type: ApplicationCommandOptionType.User,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
permissions: cmdconfig.AddUser.Permission,
|
||||||
|
|
||||||
|
async run(interaction) {
|
||||||
|
const userToAdd = interaction.options.getUser("user");
|
||||||
|
const ticketChannel = interaction.channel;
|
||||||
|
const ticketDataPath = "./Data/TicketData.json";
|
||||||
|
|
||||||
|
// Check if the channel is a ticket thread
|
||||||
|
if (!ticketChannel.isThread()) {
|
||||||
|
const onlyInTicket = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.NotInTicket_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.NotInTicket_Description)
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
return interaction.reply({
|
||||||
|
embeds: [onlyInTicket],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const ticketInviteEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.Invite_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.Invite_Description.replace("%username%", userToAdd.username))
|
||||||
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
|
await interaction.reply({
|
||||||
|
embeds: [ticketInviteEmbed],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const dmEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.DM_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.DM_Description.replace("%channelname%", ticketChannel.name))
|
||||||
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
|
const acceptButton = new ButtonBuilder()
|
||||||
|
.setCustomId("accept_invite")
|
||||||
|
.setLabel(msgconfig.AddUser.Accept_Label)
|
||||||
|
.setEmoji("✅")
|
||||||
|
.setStyle(ButtonStyle.Primary);
|
||||||
|
|
||||||
|
const rejectButton = new ButtonBuilder()
|
||||||
|
.setCustomId("reject_invite")
|
||||||
|
.setLabel(msgconfig.AddUser.Reject_Label)
|
||||||
|
.setEmoji("❌")
|
||||||
|
.setStyle(ButtonStyle.Secondary);
|
||||||
|
|
||||||
|
const row = new ActionRowBuilder().addComponents(acceptButton, rejectButton);
|
||||||
|
|
||||||
|
const dmMessage = await userToAdd.send({
|
||||||
|
embeds: [dmEmbed],
|
||||||
|
components: [row],
|
||||||
|
});
|
||||||
|
|
||||||
|
const filter = (i) => i.user.id === userToAdd.id;
|
||||||
|
const collector = dmMessage.createMessageComponentCollector({
|
||||||
|
filter,
|
||||||
|
time: 60000,
|
||||||
|
});
|
||||||
|
|
||||||
|
collector.on("collect", async (i) => {
|
||||||
|
if (i.customId === "accept_invite") {
|
||||||
|
try {
|
||||||
|
await ticketChannel.members.add(userToAdd.id);
|
||||||
|
|
||||||
|
const ticketData = JSON.parse(fs.readFileSync(ticketDataPath, "utf8"));
|
||||||
|
const ticketIndex = ticketData.tickets.findIndex((t) => t.id === ticketChannel.id);
|
||||||
|
if (ticketIndex !== -1) {
|
||||||
|
ticketData.tickets[ticketIndex].subUsers.push(userToAdd.id);
|
||||||
|
fs.writeFileSync(ticketDataPath, JSON.stringify(ticketData, null, 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
const acceptedEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.Accepted_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.Accepted_Message)
|
||||||
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
|
|
||||||
|
await i.update({
|
||||||
|
embeds: [acceptedEmbed],
|
||||||
|
components: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
const addedToTicketEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.AddedToTicket_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.AddedToTicket_Description.replace(
|
||||||
|
"%channel_link%",
|
||||||
|
`[${ticketChannel.name}](https://discord.com/channels/${ticketChannel.guild.id}/${ticketChannel.id})`
|
||||||
|
))
|
||||||
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
|
const ticketLinkButton = new ButtonBuilder()
|
||||||
|
.setLabel(msgconfig.AddUser.ViewTicket_Label)
|
||||||
|
.setURL(`https://discord.com/channels/${ticketChannel.guild.id}/${ticketChannel.id}`)
|
||||||
|
.setStyle(ButtonStyle.Link);
|
||||||
|
|
||||||
|
await userToAdd.send({
|
||||||
|
embeds: [addedToTicketEmbed],
|
||||||
|
components: [new ActionRowBuilder().addComponents(ticketLinkButton)],
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Error adding user to the ticket:", err);
|
||||||
|
|
||||||
|
const errorEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.Error_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.Error_Adding)
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
await i.update({
|
||||||
|
embeds: [errorEmbed],
|
||||||
|
components: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const declinedEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.Declined_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.Declined_Message)
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
await i.update({
|
||||||
|
embeds: [declinedEmbed],
|
||||||
|
components: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
collector.on("end", (collected) => {
|
||||||
|
if (collected.size === 0) {
|
||||||
|
userToAdd.send({
|
||||||
|
embeds: [
|
||||||
|
new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.NoResponse_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.NoResponse_Message)
|
||||||
|
.setColor(supportbot.Embed.Colours.Warning),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
if (error.code === 50007) {
|
||||||
|
const errorEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.DM_Error_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.DM_Error_Description.replace("%username%", userToAdd.username))
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
await ticketChannel.send({
|
||||||
|
embeds: [errorEmbed],
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.error("Error sending DM:", error);
|
||||||
|
|
||||||
|
const unexpectedErrorEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.AddUser.Unexpected_Error_Title)
|
||||||
|
.setDescription(msgconfig.AddUser.Unexpected_Error_Description.replace("%error%", error.message))
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
await ticketChannel.send({
|
||||||
|
embeds: [unexpectedErrorEmbed],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
// File: Commands/ForceAddUser.js
|
||||||
|
const fs = require("fs");
|
||||||
|
const {
|
||||||
|
EmbedBuilder,
|
||||||
|
ApplicationCommandOptionType,
|
||||||
|
ApplicationCommandType,
|
||||||
|
} = require("discord.js");
|
||||||
|
const yaml = require("js-yaml");
|
||||||
|
|
||||||
|
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||||
|
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
||||||
|
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
||||||
|
|
||||||
|
const Command = require("../Structures/Command.js");
|
||||||
|
|
||||||
|
module.exports = new Command({
|
||||||
|
name: cmdconfig.ForceAddUser.Command,
|
||||||
|
description: cmdconfig.ForceAddUser.Description,
|
||||||
|
type: ApplicationCommandType.ChatInput,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "user",
|
||||||
|
description: "The user to add",
|
||||||
|
type: ApplicationCommandOptionType.User,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
permissions: cmdconfig.ForceAddUser.Permission,
|
||||||
|
|
||||||
|
async run(interaction) {
|
||||||
|
|
||||||
|
const { getRole } = interaction.client;
|
||||||
|
let SupportStaff = await getRole(supportbot.Roles.StaffMember.Staff, interaction.guild);
|
||||||
|
let Admin = await getRole(supportbot.Roles.StaffMember.Admin, interaction.guild);
|
||||||
|
if (!SupportStaff || !Admin)
|
||||||
|
|
||||||
|
return interaction.reply(
|
||||||
|
"Some roles seem to be missing!\nPlease check for errors when starting the bot."
|
||||||
|
);
|
||||||
|
|
||||||
|
const NoPerms = new EmbedBuilder()
|
||||||
|
.setTitle("Invalid Permissions!")
|
||||||
|
.setDescription(
|
||||||
|
`${msgconfig.Error.IncorrectPerms}\n\nRole Required: \`${supportbot.Roles.StaffMember.Staff}\` or \`${supportbot.Roles.StaffMember.Admin}\``
|
||||||
|
)
|
||||||
|
.setColor(supportbot.Embed.Colours.Warn);
|
||||||
|
|
||||||
|
if (
|
||||||
|
!interaction.member.roles.cache.has(SupportStaff.id) &&
|
||||||
|
!interaction.member.roles.cache.has(Admin.id)
|
||||||
|
)
|
||||||
|
return interaction.reply({ embeds: [NoPerms] });
|
||||||
|
|
||||||
|
const userToAdd = interaction.options.getUser("user");
|
||||||
|
const ticketChannel = interaction.channel;
|
||||||
|
const ticketDataPath = "./Data/TicketData.json";
|
||||||
|
|
||||||
|
if (!ticketChannel.isThread()) {
|
||||||
|
const onlyInTicket = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.ForceAddUser.NotInTicket_Title)
|
||||||
|
.setDescription(msgconfig.ForceAddUser.NotInTicket_Description)
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
return interaction.reply({
|
||||||
|
embeds: [onlyInTicket],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await ticketChannel.members.add(userToAdd.id);
|
||||||
|
|
||||||
|
const ticketData = JSON.parse(fs.readFileSync(ticketDataPath, "utf8"));
|
||||||
|
const ticketIndex = ticketData.tickets.findIndex((t) => t.id === ticketChannel.id);
|
||||||
|
if (ticketIndex !== -1) {
|
||||||
|
ticketData.tickets[ticketIndex].subUsers.push(userToAdd.id);
|
||||||
|
fs.writeFileSync(ticketDataPath, JSON.stringify(ticketData, null, 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
const addedEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.ForceAddUser.Added_Title)
|
||||||
|
.setDescription(msgconfig.ForceAddUser.Added_Description.replace(
|
||||||
|
"%username%",
|
||||||
|
userToAdd.username
|
||||||
|
))
|
||||||
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
|
|
||||||
|
await interaction.reply({
|
||||||
|
embeds: [addedEmbed],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const addedToTicketEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.ForceAddUser.AddedToTicket_Title)
|
||||||
|
.setDescription(msgconfig.ForceAddUser.AddedToTicket_Description.replace(
|
||||||
|
"%channel_link%",
|
||||||
|
`[${ticketChannel.name}](https://discord.com/channels/${ticketChannel.guild.id}/${ticketChannel.id})`
|
||||||
|
))
|
||||||
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
|
await userToAdd.send({
|
||||||
|
embeds: [addedToTicketEmbed],
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Error adding user to the ticket:", err);
|
||||||
|
|
||||||
|
const errorEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.ForceAddUser.Error_Title)
|
||||||
|
.setDescription(msgconfig.ForceAddUser.Error_Adding)
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
await interaction.reply({
|
||||||
|
embeds: [errorEmbed],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
const fs = require("fs");
|
|
||||||
const Discord = require("discord.js");
|
|
||||||
const yaml = require("js-yaml");
|
|
||||||
const generateImage = require('../Structures/generateImage.js');
|
|
||||||
|
|
||||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
|
||||||
const Command = require("../Structures/Command.js");
|
|
||||||
|
|
||||||
module.exports = new Command({
|
|
||||||
name: "image",
|
|
||||||
description: "Create an image through SupportBot AI",
|
|
||||||
type: Discord.ApplicationCommandType.ChatInput,
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: "prompt",
|
|
||||||
description: "The prompt to generate an image from",
|
|
||||||
type: Discord.ApplicationCommandOptionType.String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "negativeprompt",
|
|
||||||
description: "The negative prompt to exclude from the image",
|
|
||||||
type: Discord.ApplicationCommandOptionType.String,
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "cfgscale",
|
|
||||||
description: "The cfg scale for the image generation",
|
|
||||||
type: Discord.ApplicationCommandOptionType.Number,
|
|
||||||
required: false,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
permissions: "SendMessages",
|
|
||||||
|
|
||||||
async run(interaction) {
|
|
||||||
const prompt = interaction.options.getString("prompt");
|
|
||||||
const negativePrompt = interaction.options.getString("negativeprompt") || "";
|
|
||||||
const cfgScale = interaction.options.getNumber("cfgscale") || 7.5; // Default value
|
|
||||||
|
|
||||||
try {
|
|
||||||
const imageUrl = await generateImage(prompt, negativePrompt, cfgScale);
|
|
||||||
|
|
||||||
const ImageEmbed = new Discord.EmbedBuilder()
|
|
||||||
.setTitle("Generated Image")
|
|
||||||
.setDescription(`Here is the image generated for your prompt: "${prompt}"`)
|
|
||||||
.setImage(imageUrl)
|
|
||||||
.setColor(supportbot.Embed.Colours.General)
|
|
||||||
.setFooter({
|
|
||||||
text: supportbot.Embed.Footer,
|
|
||||||
iconURL: interaction.user.displayAvatarURL(),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!interaction.replied) {
|
|
||||||
await interaction.reply({
|
|
||||||
ephemeral: true,
|
|
||||||
embeds: [ImageEmbed],
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await interaction.followUp({
|
|
||||||
ephemeral: true,
|
|
||||||
embeds: [ImageEmbed],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error generating image:', error);
|
|
||||||
if (!interaction.replied) {
|
|
||||||
await interaction.reply({
|
|
||||||
ephemeral: true,
|
|
||||||
content: `An error occurred while generating the image: ${error.message}. Please try again later.`,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await interaction.followUp({
|
|
||||||
ephemeral: true,
|
|
||||||
content: `An error occurred while generating the image: ${error.message}. Please try again later.`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
+3
-3
@@ -25,10 +25,10 @@ function updateClockedInStatus(profileEmbed, clockedIn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = new Command({
|
module.exports = new Command({
|
||||||
name: 'profile',
|
name: cmdconfig.Profile.Command,
|
||||||
description: 'Show user profile',
|
description: cmdconfig.Profile.Description,
|
||||||
type: ApplicationCommandType.ChatInput,
|
type: ApplicationCommandType.ChatInput,
|
||||||
permissions: ["SendMessages"],
|
permissions: cmdconfig.Profile.Permission,
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: 'user',
|
name: 'user',
|
||||||
|
|||||||
@@ -0,0 +1,125 @@
|
|||||||
|
// File path: Commands/RemoveUser.js
|
||||||
|
|
||||||
|
const fs = require("fs");
|
||||||
|
const {
|
||||||
|
EmbedBuilder,
|
||||||
|
ApplicationCommandOptionType,
|
||||||
|
ApplicationCommandType,
|
||||||
|
ActionRowBuilder,
|
||||||
|
ButtonBuilder,
|
||||||
|
ButtonStyle,
|
||||||
|
} = require("discord.js");
|
||||||
|
const yaml = require("js-yaml");
|
||||||
|
|
||||||
|
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
||||||
|
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
||||||
|
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
||||||
|
|
||||||
|
const Command = require("../Structures/Command.js");
|
||||||
|
|
||||||
|
module.exports = new Command({
|
||||||
|
name: cmdconfig.RemoveUser.Command,
|
||||||
|
description: cmdconfig.RemoveUser.Description,
|
||||||
|
type: ApplicationCommandType.ChatInput,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "user",
|
||||||
|
description: "The user to remove",
|
||||||
|
type: ApplicationCommandOptionType.User,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
permissions: cmdconfig.RemoveUser.Permission,
|
||||||
|
|
||||||
|
async run(interaction) {
|
||||||
|
|
||||||
|
const { getRole } = interaction.client;
|
||||||
|
let SupportStaff = await getRole(supportbot.Roles.StaffMember.Staff, interaction.guild);
|
||||||
|
let Admin = await getRole(supportbot.Roles.StaffMember.Admin, interaction.guild);
|
||||||
|
if (!SupportStaff || !Admin)
|
||||||
|
|
||||||
|
return interaction.reply(
|
||||||
|
"Some roles seem to be missing!\nPlease check for errors when starting the bot."
|
||||||
|
);
|
||||||
|
|
||||||
|
const NoPerms = new EmbedBuilder()
|
||||||
|
.setTitle("Invalid Permissions!")
|
||||||
|
.setDescription(
|
||||||
|
`${msgconfig.Error.IncorrectPerms}\n\nRole Required: \`${supportbot.Roles.StaffMember.Staff}\` or \`${supportbot.Roles.StaffMember.Admin}\``
|
||||||
|
)
|
||||||
|
.setColor(supportbot.Embed.Colours.Warn);
|
||||||
|
|
||||||
|
if (
|
||||||
|
!interaction.member.roles.cache.has(SupportStaff.id) &&
|
||||||
|
!interaction.member.roles.cache.has(Admin.id)
|
||||||
|
)
|
||||||
|
return interaction.reply({ embeds: [NoPerms] });
|
||||||
|
|
||||||
|
const userToRemove = interaction.options.getUser("user");
|
||||||
|
const ticketChannel = interaction.channel;
|
||||||
|
const ticketDataPath = "./Data/TicketData.json";
|
||||||
|
|
||||||
|
// Check if the channel is a ticket thread
|
||||||
|
if (!ticketChannel.isThread()) {
|
||||||
|
const onlyInTicket = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.RemoveUser.NotInTicket_Title)
|
||||||
|
.setDescription(msgconfig.RemoveUser.NotInTicket_Description)
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
return interaction.reply({
|
||||||
|
embeds: [onlyInTicket],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await ticketChannel.members.remove(userToRemove.id);
|
||||||
|
|
||||||
|
const ticketData = JSON.parse(fs.readFileSync(ticketDataPath, "utf8"));
|
||||||
|
const ticketIndex = ticketData.tickets.findIndex((t) => t.id === ticketChannel.id);
|
||||||
|
if (ticketIndex !== -1) {
|
||||||
|
const subUsers = ticketData.tickets[ticketIndex].subUsers;
|
||||||
|
const userIndex = subUsers.indexOf(userToRemove.id);
|
||||||
|
if (userIndex !== -1) {
|
||||||
|
subUsers.splice(userIndex, 1);
|
||||||
|
fs.writeFileSync(ticketDataPath, JSON.stringify(ticketData, null, 4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const removedEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.RemoveUser.Removed_Title)
|
||||||
|
.setDescription(msgconfig.RemoveUser.Removed_Message)
|
||||||
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
|
|
||||||
|
await interaction.reply({
|
||||||
|
embeds: [removedEmbed],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const removedFromTicketEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.RemoveUser.RemovedFromTicket_Title)
|
||||||
|
.setDescription(msgconfig.RemoveUser.RemovedFromTicket_Description.replace(
|
||||||
|
"%channel_link%",
|
||||||
|
`[${ticketChannel.name}](https://discord.com/channels/${ticketChannel.guild.id}/${ticketChannel.id})`
|
||||||
|
))
|
||||||
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
|
await userToRemove.send({
|
||||||
|
embeds: [removedFromTicketEmbed],
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Error removing user from the ticket:", err);
|
||||||
|
|
||||||
|
const errorEmbed = new EmbedBuilder()
|
||||||
|
.setTitle(msgconfig.RemoveUser.Error_Title)
|
||||||
|
.setDescription(msgconfig.RemoveUser.Error_Removing)
|
||||||
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
|
await interaction.reply({
|
||||||
|
embeds: [errorEmbed],
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
+51
-51
@@ -8,7 +8,7 @@ const {
|
|||||||
ButtonBuilder,
|
ButtonBuilder,
|
||||||
StringSelectMenuBuilder,
|
StringSelectMenuBuilder,
|
||||||
StringSelectMenuOptionBuilder,
|
StringSelectMenuOptionBuilder,
|
||||||
ButtonStyle
|
ButtonStyle,
|
||||||
} = require("discord.js");
|
} = require("discord.js");
|
||||||
const yaml = require("js-yaml");
|
const yaml = require("js-yaml");
|
||||||
|
|
||||||
@@ -201,10 +201,6 @@ async function assignTicketToUser(ticketChannel, Staff, Admin, interaction, atte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = new Command({
|
module.exports = new Command({
|
||||||
name: cmdconfig.OpenTicket.Command,
|
name: cmdconfig.OpenTicket.Command,
|
||||||
description: cmdconfig.OpenTicket.Description,
|
description: cmdconfig.OpenTicket.Description,
|
||||||
@@ -220,7 +216,11 @@ module.exports = new Command({
|
|||||||
|
|
||||||
async run(interaction) {
|
async run(interaction) {
|
||||||
try {
|
try {
|
||||||
let department = interaction.customId?.split("-")[1] || null;
|
let TicketReason = null;
|
||||||
|
if (supportbot.Ticket.TicketReason) {
|
||||||
|
TicketReason = interaction.reason || null; // Retrieve the reason from the interaction object
|
||||||
|
}
|
||||||
|
|
||||||
let TicketData = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
let TicketData = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
||||||
const { getRole, getChannel } = interaction.client;
|
const { getRole, getChannel } = interaction.client;
|
||||||
let User = interaction.guild.members.cache.get(interaction.user.id);
|
let User = interaction.guild.members.cache.get(interaction.user.id);
|
||||||
@@ -256,7 +256,7 @@ module.exports = new Command({
|
|||||||
}
|
}
|
||||||
|
|
||||||
let ticketNumberID = await TicketNumberID.pad();
|
let ticketNumberID = await TicketNumberID.pad();
|
||||||
const TicketSubject = interaction.options?.getString("reason") || msgconfig.Ticket.InvalidSubject;
|
const TicketSubject = TicketReason || msgconfig.Ticket.InvalidSubject;
|
||||||
|
|
||||||
const TicketExists = new EmbedBuilder()
|
const TicketExists = new EmbedBuilder()
|
||||||
.setTitle("Ticket Exists!")
|
.setTitle("Ticket Exists!")
|
||||||
@@ -304,9 +304,7 @@ module.exports = new Command({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add user to the ticket channel
|
// Add user to the ticket channel
|
||||||
if (!department) {
|
await ticketChannel.members.add(interaction.user.id);
|
||||||
await ticketChannel.members.add(interaction.user.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save ticket data
|
// Save ticket data
|
||||||
TicketData.tickets.push({
|
TicketData.tickets.push({
|
||||||
@@ -335,6 +333,7 @@ module.exports = new Command({
|
|||||||
msgconfig.Ticket.TicketCreatedAlert.replace(/%ticketauthor%/g, interaction.user.id)
|
msgconfig.Ticket.TicketCreatedAlert.replace(/%ticketauthor%/g, interaction.user.id)
|
||||||
.replace(/%ticketid%/g, ticketChannel.id)
|
.replace(/%ticketid%/g, ticketChannel.id)
|
||||||
.replace(/%ticketusername%/g, interaction.user.username)
|
.replace(/%ticketusername%/g, interaction.user.username)
|
||||||
|
.replace(/%ticketreason%/g, TicketSubject)
|
||||||
)
|
)
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
await interaction.reply({ embeds: [CreatedTicket], ephemeral: true });
|
await interaction.reply({ embeds: [CreatedTicket], ephemeral: true });
|
||||||
@@ -356,24 +355,22 @@ module.exports = new Command({
|
|||||||
msgconfig.Ticket.TicketMessage.replace(/%ticketauthor%/g, interaction.user.id)
|
msgconfig.Ticket.TicketMessage.replace(/%ticketauthor%/g, interaction.user.id)
|
||||||
.replace(/%ticketid%/g, ticketChannel.id)
|
.replace(/%ticketid%/g, ticketChannel.id)
|
||||||
.replace(/%ticketusername%/g, interaction.user.username)
|
.replace(/%ticketusername%/g, interaction.user.username)
|
||||||
|
.replace(/%ticketreason%/g, TicketSubject)
|
||||||
)
|
)
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
.setColor(supportbot.Embed.Colours.General);
|
||||||
|
|
||||||
|
// Add reason field if ticket reason is enabled
|
||||||
|
if (supportbot.Ticket.TicketReason && TicketReason) {
|
||||||
|
TicketMessage.addFields(
|
||||||
|
{ name: "Reason", value: TicketReason, inline: false }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Create the control panel
|
// Create the control panel
|
||||||
const SelectMenus = new StringSelectMenuBuilder()
|
const SelectMenus = new StringSelectMenuBuilder()
|
||||||
.setCustomId("ticketcontrolpanel")
|
.setCustomId("ticketcontrolpanel")
|
||||||
.setPlaceholder("Ticket Control Panel")
|
.setPlaceholder("Ticket Control Panel")
|
||||||
.addOptions(
|
.addOptions(
|
||||||
new StringSelectMenuOptionBuilder()
|
|
||||||
.setLabel("Add User")
|
|
||||||
.setDescription("Add a user to the ticket.")
|
|
||||||
.setEmoji(supportbot.SelectMenus.Tickets.AddUserEmoji)
|
|
||||||
.setValue("ticketadduser"),
|
|
||||||
new StringSelectMenuOptionBuilder()
|
|
||||||
.setLabel("Remove User")
|
|
||||||
.setDescription("Remove a user from the ticket.")
|
|
||||||
.setEmoji(supportbot.SelectMenus.Tickets.RemoveUserEmoji)
|
|
||||||
.setValue("ticketremoveuser"),
|
|
||||||
new StringSelectMenuOptionBuilder()
|
new StringSelectMenuOptionBuilder()
|
||||||
.setLabel("Close")
|
.setLabel("Close")
|
||||||
.setDescription("Close the ticket.")
|
.setDescription("Close the ticket.")
|
||||||
@@ -399,11 +396,12 @@ module.exports = new Command({
|
|||||||
components: [row2],
|
components: [row2],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handle department selection if not specified
|
||||||
if (!department) {
|
if (!department) {
|
||||||
try {
|
try {
|
||||||
let buttons = supportbot.Departments.map((x) =>
|
const buttons = supportbot.Departments.map((x, index) =>
|
||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
.setCustomId("Department" + supportbot.Departments.indexOf(x))
|
.setCustomId("Department" + index)
|
||||||
.setLabel(x.title)
|
.setLabel(x.title)
|
||||||
.setStyle(x.color)
|
.setStyle(x.color)
|
||||||
.setEmoji(x.emoji)
|
.setEmoji(x.emoji)
|
||||||
@@ -411,37 +409,39 @@ module.exports = new Command({
|
|||||||
|
|
||||||
const row = new ActionRowBuilder().addComponents(buttons);
|
const row = new ActionRowBuilder().addComponents(buttons);
|
||||||
|
|
||||||
try {
|
const message = await ticketChannel.send({
|
||||||
const filter = (i) => i.user.id === interaction.user.id;
|
content: "Please select a department:",
|
||||||
await m.awaitMessageComponent({
|
components: [row],
|
||||||
filter,
|
});
|
||||||
max: 1,
|
|
||||||
componentType: "BUTTON",
|
const filter = (i) => i.user.id === interaction.user.id;
|
||||||
time: supportbot.Ticket.Timeout * 60000,
|
await message.awaitMessageComponent({
|
||||||
});
|
filter,
|
||||||
} catch (e) {
|
max: 1,
|
||||||
if (e.code === "COLLECTOR_ERROR") {
|
componentType: "BUTTON",
|
||||||
try {
|
time: supportbot.Ticket.Timeout * 60000,
|
||||||
let ticket = TicketData.tickets.findIndex((t) => t.id === ticketChannel.id);
|
});
|
||||||
TicketData.tickets[ticket].open = false;
|
|
||||||
fs.writeFileSync(
|
} catch (e) {
|
||||||
"./Data/TicketData.json",
|
if (e.code === "COLLECTOR_ERROR") {
|
||||||
JSON.stringify(TicketData, null, 4),
|
try {
|
||||||
(err) => {
|
const ticket = TicketData.tickets.findIndex((t) => t.id === ticketChannel.id);
|
||||||
if (err) console.error(err);
|
TicketData.tickets[ticket].open = false;
|
||||||
}
|
fs.writeFileSync(
|
||||||
);
|
"./Data/TicketData.json",
|
||||||
interaction.user.send(
|
JSON.stringify(TicketData, null, 4),
|
||||||
"Your ticket has timed out. Please open a new one, and select a department."
|
(err) => {
|
||||||
);
|
if (err) console.error(err);
|
||||||
} catch (error) {return assignedUserId;
|
}
|
||||||
console.error("An error occurred while handling collector:", error);
|
);
|
||||||
}
|
await interaction.user.send(
|
||||||
return await ticketChannel.delete();
|
"Your ticket has timed out. Please open a new one and select a department."
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("An error occurred while handling collector:", error);
|
||||||
}
|
}
|
||||||
|
await ticketChannel.delete();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error("Error sending message:", error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -1,137 +0,0 @@
|
|||||||
// SupportBot | Emerald Services
|
|
||||||
// User Info Command
|
|
||||||
|
|
||||||
const fs = require("fs");
|
|
||||||
const moment = require("moment");
|
|
||||||
|
|
||||||
const Discord = 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 Command = require("../Structures/Command.js");
|
|
||||||
|
|
||||||
module.exports = new Command({
|
|
||||||
name: cmdconfig.UserInfo.Command,
|
|
||||||
description: cmdconfig.UserInfo.Description,
|
|
||||||
type: Discord.ApplicationCommandType.ChatInput,
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
type: Discord.ApplicationCommandOptionType.User,
|
|
||||||
name: "user",
|
|
||||||
description: "The user you want to get info about.",
|
|
||||||
required: true,
|
|
||||||
}, // The user input
|
|
||||||
],
|
|
||||||
permissions: cmdconfig.UserInfo.Permission,
|
|
||||||
|
|
||||||
async run(interaction) {
|
|
||||||
let disableCommand = true;
|
|
||||||
|
|
||||||
const { getRole } = interaction.client;
|
|
||||||
let SupportStaff = await getRole(supportbot.Roles.StaffMember.Staff, interaction.guild);
|
|
||||||
let Admin = await getRole(supportbot.Roles.StaffMember.Admin, interaction.guild);
|
|
||||||
if (!SupportStaff || !Admin)
|
|
||||||
|
|
||||||
return interaction.reply(
|
|
||||||
"Some roles seem to be missing!\nPlease check for errors when starting the bot."
|
|
||||||
);
|
|
||||||
|
|
||||||
const NoPerms = new Discord.EmbedBuilder()
|
|
||||||
.setTitle("Invalid Permissions!")
|
|
||||||
.setDescription(
|
|
||||||
`${msgconfig.Error.IncorrectPerms}\n\nRole Required: \`${supportbot.Roles.StaffMember.Staff}\` or \`${supportbot.Roles.StaffMember.Admin}\``
|
|
||||||
)
|
|
||||||
.setColor(supportbot.Embed.Colours.Warn);
|
|
||||||
|
|
||||||
if (
|
|
||||||
!interaction.member.roles.cache.has(SupportStaff.id) &&
|
|
||||||
!interaction.member.roles.cache.has(Admin.id)
|
|
||||||
)
|
|
||||||
return interaction.reply({ embeds: [NoPerms] });
|
|
||||||
|
|
||||||
let user = await interaction.options.getUser("user") || interaction.author; // Grab the mentioned user
|
|
||||||
let member = await interaction.guild.members.cache.get(user.id) // Check for user and his ID
|
|
||||||
|
|
||||||
const UserNotExist = new Discord.EmbedBuilder()
|
|
||||||
.setTitle("User Not Found!")
|
|
||||||
.setDescription(
|
|
||||||
`${msgconfig.Error.UserNotFound}\n\nTry Again:\`/${cmdconfig.UserInfoCommand} <@!User_ID> or @User\``
|
|
||||||
)
|
|
||||||
.setColor(supportbot.ErrorColour);
|
|
||||||
|
|
||||||
if (!user) return interaction.reply({ embeds: [UserNotExist] });
|
|
||||||
|
|
||||||
// Flags a user/bot can have
|
|
||||||
const flags = {
|
|
||||||
DISCORD_EMPLOYEE: 'Discord Employee',
|
|
||||||
DISCORD_PARTNER: 'Discord Partner',
|
|
||||||
BUGHUNTER_LEVEL_1: 'Bug Hunter (Level 1)',
|
|
||||||
BUGHUNTER_LEVEL_2: 'Bug Hunter (Level 2)',
|
|
||||||
HYPESQUAD_EVENTS: 'HypeSquad Events',
|
|
||||||
HOUSE_BRAVERY: 'House of Bravery',
|
|
||||||
HOUSE_BRILLIANCE: 'House of Brilliance',
|
|
||||||
HOUSE_BALANCE: 'House of Balance',
|
|
||||||
EARLY_SUPPORTER: 'Early Supporter',
|
|
||||||
TEAM_USER: 'Team User',
|
|
||||||
SYSTEM: 'System',
|
|
||||||
VERIFIED_BOT: 'Verified Bot',
|
|
||||||
VERIFIED_DEVELOPER: 'Verified Bot Developer'
|
|
||||||
};
|
|
||||||
|
|
||||||
// Status message with icon
|
|
||||||
let status = {
|
|
||||||
online: "🟢Online",
|
|
||||||
idle: "🟡Idle",
|
|
||||||
dnd: "🔴Do Not Disturb",
|
|
||||||
offline: "⚫Offline"
|
|
||||||
};
|
|
||||||
|
|
||||||
const userFlags = user.flags.toArray();
|
|
||||||
|
|
||||||
// Embed containing the userinfo
|
|
||||||
let userembed = new Discord.EmbedBuilder()
|
|
||||||
.setTitle(`User Info for User: ${user.tag}`)
|
|
||||||
.setThumbnail(member.displayAvatarURL({ dynamic: true, size: 512 }))
|
|
||||||
.setColor(member.roles.highest.hexColor)
|
|
||||||
.addFields(
|
|
||||||
{ name: "Name:", value: `${user.tag}\n<@${member.id}>`, inline: true },
|
|
||||||
{ name: "ID:", value: `${member.id}`, inline: true },
|
|
||||||
{ name: "Is Bot:", value: user.bot ? "Yes" : "No", inline: true },
|
|
||||||
{ name: "House/Badge:", value: `${userFlags.length ? userFlags.map(flag => flags[flag]).join("\n") : "None"}`, inline: true },
|
|
||||||
{ name: "Current Status:", value: `${status[member.presence ? member.presence.status : "offline"]}`, inline: true },
|
|
||||||
{ name: "Avatar URL:", value: `[Click Here](${member.displayAvatarURL()})`, inline: true },
|
|
||||||
{ name: "\u200b", value: "\u200b", inline: false}
|
|
||||||
)
|
|
||||||
.addFields(
|
|
||||||
{ name: "Creation Date:", value: `${moment(user.createdAt).format("MMMM Do YYYY, h:mm:ss a")}\n> ${moment(user.createdAt).startOf("day").fromNow()}`, inline: true },
|
|
||||||
{ name: "Joined Date:", value: `${moment(member.joinedAt).format("MMMM Do YYYY, h:mm:ss a")}\n> ${moment(member.joinedAt).startOf("day").fromNow()}`, inline: true },
|
|
||||||
{ name: "Roles Total:", value: `${member.roles.cache.size -1}`, inline: false },
|
|
||||||
{ name: "Highest Role:", value: `${member.roles.highest.id === interaction.guild.id ? "None" : member.roles.highest.toString()}`, inline: true },
|
|
||||||
{ name: "Roles:", value: `${member.roles.cache.map(r => r).join(" ").replace("@everyone", " ") || "None"}`, inline: false },
|
|
||||||
)
|
|
||||||
.setFooter({ text: supportbot.Footer })
|
|
||||||
.setTimestamp();
|
|
||||||
|
|
||||||
// Send embed [userembed]
|
|
||||||
await interaction.reply({ embeds: [userembed] }).catch((err) => console.error("An error has occured: ", err));
|
|
||||||
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @INFO
|
|
||||||
* UserInfo command by Sypher#3415 | 321332200668790786
|
|
||||||
* @INFO
|
|
||||||
* Solely created for SupportBot | https://github.com/Emerald-Services/SupportBot/
|
|
||||||
**/
|
|
||||||
+17
-11
@@ -19,12 +19,6 @@ Help:
|
|||||||
Permission: ["SendMessages"]
|
Permission: ["SendMessages"]
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
EnableAI:
|
|
||||||
Command: "enableai"
|
|
||||||
Description: "Talk with SupportBot"
|
|
||||||
Permission: ["SendMessages"]
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Info:
|
Info:
|
||||||
Command: "info"
|
Command: "info"
|
||||||
Description: "Get information about the **ServerName**."
|
Description: "Get information about the **ServerName**."
|
||||||
@@ -37,9 +31,9 @@ TicketPanel:
|
|||||||
Permission: ["Administrator"]
|
Permission: ["Administrator"]
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
TicketStats:
|
Profile:
|
||||||
Command: "ticketstats"
|
Command: "profile"
|
||||||
Description: "Shows staff members their ticket statistics"
|
Description: "Shows the profile for a discord member."
|
||||||
Permission: ["SendMessages"]
|
Permission: ["SendMessages"]
|
||||||
# Command is automatically disabled when the TicketClaims is disabled.
|
# Command is automatically disabled when the TicketClaims is disabled.
|
||||||
|
|
||||||
@@ -49,9 +43,21 @@ OpenTicket:
|
|||||||
Permission: ["SendMessages"]
|
Permission: ["SendMessages"]
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Add:
|
AddUser:
|
||||||
Command: "add"
|
Command: "add"
|
||||||
Description: "Add a user to the ticket."
|
Description: "Add a user to a support ticket."
|
||||||
|
Permission: ["SendMessages"]
|
||||||
|
Enabled: true
|
||||||
|
|
||||||
|
ForceAddUser:
|
||||||
|
Command: "forceadd"
|
||||||
|
Description: "Add a user to a support ticket by bypassing the invite system."
|
||||||
|
Permission: ["SendMessages"]
|
||||||
|
Enabled: true
|
||||||
|
|
||||||
|
RemoveUser:
|
||||||
|
Command: "remove"
|
||||||
|
Description: "Remove a user from a support ticket."
|
||||||
Permission: ["SendMessages"]
|
Permission: ["SendMessages"]
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
|||||||
+60
-6
@@ -70,12 +70,6 @@ Ticket:
|
|||||||
|
|
||||||
# <@%user%> - Tags the user who was added to the ticket.
|
# <@%user%> - Tags the user who was added to the ticket.
|
||||||
|
|
||||||
AddUserToTicket_Title: "➕ Add User!"
|
|
||||||
AddUserToTicket: "> To add a user to this ticket, Tag them."
|
|
||||||
|
|
||||||
RemovedUserFromTicket_Title: "➖ Removed User!"
|
|
||||||
RemovedUserFromTicket: "> <@%user%> has been `Removed` from this ticket"
|
|
||||||
|
|
||||||
Blacklisted: "> :x: You are not allowed to open a ticket"
|
Blacklisted: "> :x: You are not allowed to open a ticket"
|
||||||
Muted: "> :x: You are `Muted` and therefore not allowed to open any tickets"
|
Muted: "> :x: You are `Muted` and therefore not allowed to open any tickets"
|
||||||
InvalidSubject: "> No Reason Provided!"
|
InvalidSubject: "> No Reason Provided!"
|
||||||
@@ -108,6 +102,66 @@ TicketStats:
|
|||||||
|
|
||||||
Title: "Your Ticket Stats"
|
Title: "Your Ticket Stats"
|
||||||
|
|
||||||
|
AddUser:
|
||||||
|
NotInTicket_Title: "Ticket Invitation"
|
||||||
|
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."
|
||||||
|
|
||||||
|
DM_Title: "Ticket Invitation"
|
||||||
|
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."
|
||||||
|
AddedToTicket_Title: "Added to Ticket"
|
||||||
|
AddedToTicket_Description: "> You have been added to the ticket %channel_link%."
|
||||||
|
|
||||||
|
Declined_Title: "Invitation Declined"
|
||||||
|
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."
|
||||||
|
|
||||||
|
Error_Title: "Error"
|
||||||
|
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."
|
||||||
|
|
||||||
|
Unexpected_Error_Title: "Error"
|
||||||
|
Unexpected_Error_Description: "> An unexpected error occurred: %error%"
|
||||||
|
|
||||||
|
RemoveUser:
|
||||||
|
NotInTicket_Title: "Error"
|
||||||
|
NotInTicket_Description: "This command can only be used in ticket threads."
|
||||||
|
|
||||||
|
Removed_Title: "User Removed"
|
||||||
|
Removed_Message: "The user has been successfully removed from the ticket."
|
||||||
|
|
||||||
|
RemovedFromTicket_Title: "Removed from Ticket"
|
||||||
|
RemovedFromTicket_Description: "You have been removed from the ticket channel %channel_link%."
|
||||||
|
|
||||||
|
Error_Title: "Error"
|
||||||
|
Error_Removing: "There was an error removing the user from the ticket."
|
||||||
|
|
||||||
|
ForceAddUser:
|
||||||
|
NotInTicket_Title: "Not a Ticket"
|
||||||
|
NotInTicket_Description: "This command can only be used within a ticket thread."
|
||||||
|
|
||||||
|
Added_Title: "User Added"
|
||||||
|
Added_Description: "Successfully added %username% to the ticket."
|
||||||
|
|
||||||
|
AddedToTicket_Title: "You have been added to a Ticket"
|
||||||
|
AddedToTicket_Description: "You have been added to the ticket channel [%channel_link%]."
|
||||||
|
|
||||||
|
Error_Title: "Error"
|
||||||
|
Error_Adding: "There was an error adding the user to the ticket."
|
||||||
|
|
||||||
Error:
|
Error:
|
||||||
IncorrectPerms: "> :x: **Err!** You do not have the correct permissions to use this."
|
IncorrectPerms: "> :x: **Err!** You do not have the correct permissions to use this."
|
||||||
InvalidChannel: "> :x: **Err!** Channel not found. Please create it!"
|
InvalidChannel: "> :x: **Err!** Channel not found. Please create it!"
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ General:
|
|||||||
# Max tokens you can set is 400
|
# Max tokens you can set is 400
|
||||||
# For more information about tokens, go to https://openai.com/api/pricing/
|
# For more information about tokens, go to https://openai.com/api/pricing/
|
||||||
|
|
||||||
OpenAI_Key: "OPEN AI KEY"
|
OpenAI_Key: "OPENAI_KEY"
|
||||||
# To create an OpenAI API key, go to https://platform.openai.com/api-keys
|
# To create an OpenAI API key, go to https://platform.openai.com/api-keys
|
||||||
|
|
||||||
|
|
||||||
PastebinAPI_Key: "PASTEBIN KEY"
|
PastebinAPI_Key: "PASTEBIN_KEY"
|
||||||
# You can get your Pastebin API Key from https://pastebin.com
|
# You can get your Pastebin API Key from https://pastebin.com
|
||||||
PastebinAPI_URL: "https://pastebin.com/api/api_post.php"
|
PastebinAPI_URL: "https://pastebin.com/api/api_post.php"
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
# Official Documentation: https://github.com/Emerald-Services/SupportBot/wiki
|
# Official Documentation: https://github.com/Emerald-Services/SupportBot/wiki
|
||||||
# Third-Party Documentation: COMING SOON
|
# Third-Party Documentation: COMING SOON
|
||||||
|
|
||||||
SupportBot_Version: "v8.0.1"
|
SupportBot_Version: "v8.1"
|
||||||
# Do not change the version number
|
# Do not change the version number
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
@@ -20,7 +20,7 @@ SupportBot_Version: "v8.0.1"
|
|||||||
|
|
||||||
General:
|
General:
|
||||||
Name: "SupportBot"
|
Name: "SupportBot"
|
||||||
Token: "BOT TOKEN HERE"
|
Token: "BOT_TOKEN_HERE"
|
||||||
# To get your Discord Bot Token, Go to https://discord.com/developers/applications
|
# To get your Discord Bot Token, Go to https://discord.com/developers/applications
|
||||||
|
|
||||||
Addons:
|
Addons:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"clockedIn": true,
|
"clockedIn": false,
|
||||||
"bio": "Hi",
|
"bio": "Hi",
|
||||||
"timezone": "GMT"
|
"timezone": "GMT"
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"bio": "",
|
||||||
|
"timezone": "",
|
||||||
|
"clockedIn": true
|
||||||
|
}
|
||||||
@@ -12,5 +12,11 @@
|
|||||||
"author": "419821884431925260",
|
"author": "419821884431925260",
|
||||||
"upvotes": [],
|
"upvotes": [],
|
||||||
"downvotes": []
|
"downvotes": []
|
||||||
|
},
|
||||||
|
"1260279162854441042": {
|
||||||
|
"suggestion": "test",
|
||||||
|
"author": "419821884431925260",
|
||||||
|
"upvotes": [],
|
||||||
|
"downvotes": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,6 +179,91 @@
|
|||||||
"createdAt": "2024-07-02T19:37:19.467Z",
|
"createdAt": "2024-07-02T19:37:19.467Z",
|
||||||
"claimedAt": "2024-07-02T19:43:12.873Z",
|
"claimedAt": "2024-07-02T19:43:12.873Z",
|
||||||
"claimedBy": "419821884431925260"
|
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"id": 37,
|
"id": 43,
|
||||||
"TicketPanelID": "1250863985335472312"
|
"TicketPanelID": "1250863985335472312"
|
||||||
}
|
}
|
||||||
+159
-75
@@ -16,20 +16,25 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = new Event("interactionCreate", async (client, interaction) => {
|
module.exports = new Event("interactionCreate", async (client, interaction) => {
|
||||||
if (interaction.type == Discord.InteractionType.ApplicationCommand) {
|
console.log("Interaction received:", interaction.type); // Log interaction type
|
||||||
|
|
||||||
|
if (interaction.type === Discord.InteractionType.ApplicationCommand) {
|
||||||
const command = client.commands.find(
|
const command = client.commands.find(
|
||||||
(cmd) => cmd.name.toLowerCase() === interaction.commandName
|
(cmd) => cmd.name.toLowerCase() === interaction.commandName
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log("Command received:", interaction.commandName); // Log command name
|
||||||
|
|
||||||
if (interaction.user.bot || !interaction.guild) return;
|
if (interaction.user.bot || !interaction.guild) return;
|
||||||
|
|
||||||
const NotValid = new Discord.EmbedBuilder()
|
const NotValid = new Discord.EmbedBuilder()
|
||||||
.setDescription(`:x: \`Invalid Command\` `)
|
.setDescription(`:x: \`Invalid Command\``)
|
||||||
.setColor(supportbot.Embed.Colours.Error);
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
if (!command)
|
if (!command)
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
embeds: [NotValid],
|
embeds: [NotValid],
|
||||||
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const permission = interaction.member.permissions.has(command.permissions);
|
const permission = interaction.member.permissions.has(command.permissions);
|
||||||
@@ -43,8 +48,50 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
if (!permission)
|
if (!permission)
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
embeds: [ValidPerms],
|
embeds: [ValidPerms],
|
||||||
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
command.run(interaction);
|
|
||||||
|
try {
|
||||||
|
if (command.name === cmdconfig.OpenTicket.Command && supportbot.Ticket.TicketReason) {
|
||||||
|
const modal = new Discord.ModalBuilder()
|
||||||
|
.setCustomId("ticketReasonModal")
|
||||||
|
.setTitle("Ticket Reason")
|
||||||
|
.addComponents(
|
||||||
|
new Discord.ActionRowBuilder().addComponents(
|
||||||
|
new Discord.TextInputBuilder()
|
||||||
|
.setCustomId("reasonInput")
|
||||||
|
.setLabel("Reason")
|
||||||
|
.setStyle(Discord.TextInputStyle.Paragraph)
|
||||||
|
.setRequired(true)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
await interaction.showModal(modal);
|
||||||
|
} else {
|
||||||
|
console.log("Running command:", command.name); // Log running command
|
||||||
|
await command.run(interaction);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error executing command:", error);
|
||||||
|
await interaction.reply({
|
||||||
|
content: "An error occurred while executing the command.",
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (interaction.isModalSubmit()) {
|
||||||
|
if (interaction.customId === "ticketReasonModal") {
|
||||||
|
const reason = interaction.fields.getTextInputValue("reasonInput");
|
||||||
|
interaction.customId = `createticket-${reason}`;
|
||||||
|
const cmd = client.commands.get(cmdconfig.OpenTicket.Command);
|
||||||
|
if (cmd) {
|
||||||
|
interaction.reason = reason; // Attach the reason to the interaction object
|
||||||
|
await cmd.run(interaction);
|
||||||
|
} else {
|
||||||
|
console.error("Command not found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interaction.isStringSelectMenu()) {
|
if (interaction.isStringSelectMenu()) {
|
||||||
@@ -52,26 +99,11 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
const selectedOption = interaction.values[0];
|
const selectedOption = interaction.values[0];
|
||||||
const { getRole, getChannel } = interaction.client;
|
const { getRole, getChannel } = interaction.client;
|
||||||
switch (selectedOption) {
|
switch (selectedOption) {
|
||||||
case "ticketadduser":
|
|
||||||
const AddUserThreadTicket = new Discord.EmbedBuilder()
|
|
||||||
.setTitle(`${msgconfig.Ticket.AddUserToTicket}`)
|
|
||||||
.setDescription(`${msgconfig.Ticket.AddUserToTicket}`)
|
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
|
||||||
|
|
||||||
await interaction.reply({
|
|
||||||
embeds: [AddUserThreadTicket],
|
|
||||||
ephemeral: true,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "ticketremoveuser":
|
|
||||||
await removeUserFromThread(interaction);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "ticketclose":
|
case "ticketclose":
|
||||||
const closeCommand = client.commands.get(cmdconfig.CloseTicket.Command);
|
const closeCommand = client.commands.get(cmdconfig.CloseTicket.Command);
|
||||||
if (closeCommand) {
|
if (closeCommand) {
|
||||||
closeCommand.run(interaction);
|
await closeCommand.run(interaction);
|
||||||
} else {
|
} else {
|
||||||
console.error("[X] Close Command Not Found");
|
console.error("[X] Close Command Not Found");
|
||||||
}
|
}
|
||||||
@@ -89,32 +121,66 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (interaction.isButton()) {
|
if (interaction.isButton()) {
|
||||||
if (interaction.customId === 'createticket') {
|
if (interaction.customId === "createticket") {
|
||||||
try {
|
if (supportbot.Ticket.TicketReason) {
|
||||||
const cmd = client.commands.get(cmdconfig.OpenTicket.Command);
|
const modal = new Discord.ModalBuilder()
|
||||||
if (!cmd) return;
|
.setCustomId("ticketReasonModal")
|
||||||
cmd.run(interaction);
|
.setTitle("Ticket Reason")
|
||||||
} catch (error) {
|
.addComponents(
|
||||||
console.error("Error executing the ticket command:", error);
|
new Discord.ActionRowBuilder().addComponents(
|
||||||
await interaction.reply({
|
new Discord.TextInputBuilder()
|
||||||
content: "An error occurred while creating the ticket.",
|
.setCustomId("reasonInput")
|
||||||
ephemeral: true,
|
.setLabel("Reason")
|
||||||
});
|
.setStyle(Discord.TextInputStyle.Paragraph)
|
||||||
|
.setRequired(true)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
await interaction.showModal(modal);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const cmd = client.commands.get(cmdconfig.OpenTicket.Command);
|
||||||
|
if (!cmd) return;
|
||||||
|
await cmd.run(interaction);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error executing the ticket command:", error);
|
||||||
|
await interaction.reply({
|
||||||
|
content: "An error occurred while creating the ticket.",
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interaction.customId === "openticket") {
|
if (interaction.customId === "openticket") {
|
||||||
try {
|
if (supportbot.Ticket.TicketReason) {
|
||||||
const cmd = client.commands.get(cmdconfig.OpenTicket);
|
const modal = new Discord.ModalBuilder()
|
||||||
if (!cmd) return;
|
.setCustomId("ticketReasonModal")
|
||||||
cmd.run(interaction);
|
.setTitle("Ticket Reason")
|
||||||
} catch (error) {
|
.addComponents(
|
||||||
console.error(error);
|
new Discord.ActionRowBuilder().addComponents(
|
||||||
|
new Discord.TextInputBuilder()
|
||||||
|
.setCustomId("reasonInput")
|
||||||
|
.setLabel("Reason")
|
||||||
|
.setStyle(Discord.TextInputStyle.Paragraph)
|
||||||
|
.setRequired(true)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
await interaction.showModal(modal);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const cmd = client.commands.get(cmdconfig.OpenTicket.Command);
|
||||||
|
if (!cmd) return;
|
||||||
|
await cmd.run(interaction);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interaction.customId.startsWith('claimticket-')) {
|
if (interaction.customId.startsWith("claimticket-")) {
|
||||||
const ticketChannelId = interaction.customId.split('-')[1];
|
const ticketChannelId = interaction.customId.split("-")[1];
|
||||||
const ticketChannel = interaction.guild.channels.cache.get(ticketChannelId);
|
const ticketChannel = interaction.guild.channels.cache.get(ticketChannelId);
|
||||||
if (!ticketChannel) {
|
if (!ticketChannel) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
@@ -144,7 +210,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
const NoPermsClaim = new Discord.EmbedBuilder()
|
const NoPermsClaim = new Discord.EmbedBuilder()
|
||||||
.setTitle(msgconfig.Ticket.ClaimTickets.NoPermsToClaimTitle)
|
.setTitle(msgconfig.Ticket.ClaimTickets.NoPermsToClaimTitle)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
msgconfig.Ticket.ClaimTickets.NoPermsToClaim.replace('%channel%', ticketChannel.name)
|
msgconfig.Ticket.ClaimTickets.NoPermsToClaim.replace("%channel%", ticketChannel.name)
|
||||||
)
|
)
|
||||||
.setColor(supportbot.Embed.Colours.Error);
|
.setColor(supportbot.Embed.Colours.Error);
|
||||||
|
|
||||||
@@ -160,7 +226,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
pingclaimedstaff.delete();
|
pingclaimedstaff.delete();
|
||||||
}, 2000)
|
}, 2000);
|
||||||
|
|
||||||
const TicketData = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
const TicketData = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
|
||||||
const ticketIndex = TicketData.tickets.findIndex((t) => t.id === ticketChannelId);
|
const ticketIndex = TicketData.tickets.findIndex((t) => t.id === ticketChannelId);
|
||||||
@@ -174,13 +240,13 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
const claimedEmbed = new Discord.EmbedBuilder(claimMessage.embeds[0].data)
|
const claimedEmbed = new Discord.EmbedBuilder(claimMessage.embeds[0].data)
|
||||||
.setTitle(msgconfig.Ticket.ClaimTickets.ClaimedTitle)
|
.setTitle(msgconfig.Ticket.ClaimTickets.ClaimedTitle)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
msgconfig.Ticket.ClaimTickets.ClaimMessage_Edit.replace('%user%', interaction.user.id).replace('%channel%', ticketChannel.id)
|
msgconfig.Ticket.ClaimTickets.ClaimMessage_Edit.replace("%user%", interaction.user.id).replace("%channel%", ticketChannel.id)
|
||||||
)
|
)
|
||||||
.setColor(supportbot.Embed.Colours.Success);
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
|
|
||||||
const successfullyClaimed = new Discord.EmbedBuilder()
|
const successfullyClaimed = new Discord.EmbedBuilder()
|
||||||
.setTitle(msgconfig.Ticket.ClaimTickets.ClaimedTitle)
|
.setTitle(msgconfig.Ticket.ClaimTickets.ClaimedTitle)
|
||||||
.setDescription(msgconfig.Ticket.ClaimTickets.Claimed.replace('%channel%', ticketChannel.id))
|
.setDescription(msgconfig.Ticket.ClaimTickets.Claimed.replace("%channel%", ticketChannel.id))
|
||||||
.setColor(supportbot.Embed.Colours.Success);
|
.setColor(supportbot.Embed.Colours.Success);
|
||||||
|
|
||||||
await claimMessage.edit({ embeds: [claimedEmbed], components: [] });
|
await claimMessage.edit({ embeds: [claimedEmbed], components: [] });
|
||||||
@@ -192,35 +258,40 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
|
|
||||||
// SUGGESTION INTERACTIONS [START]
|
// SUGGESTION INTERACTIONS [START]
|
||||||
|
|
||||||
if (interaction.customId === 'upvote' || interaction.customId === 'downvote' || interaction.customId === 'removevote') {
|
if (
|
||||||
|
interaction.customId === "upvote" ||
|
||||||
|
interaction.customId === "downvote" ||
|
||||||
|
interaction.customId === "removevote"
|
||||||
|
) {
|
||||||
const suggestion = suggestions[interaction.message.id];
|
const suggestion = suggestions[interaction.message.id];
|
||||||
if (!suggestion) return interaction.reply({ content: 'Suggestion not found.', ephemeral: true });
|
if (!suggestion)
|
||||||
|
return interaction.reply({ content: "Suggestion not found.", ephemeral: true });
|
||||||
|
|
||||||
const userId = interaction.user.id;
|
const userId = interaction.user.id;
|
||||||
const hasUpvoted = suggestion.upvotes.includes(userId);
|
const hasUpvoted = suggestion.upvotes.includes(userId);
|
||||||
const hasDownvoted = suggestion.downvotes.includes(userId);
|
const hasDownvoted = suggestion.downvotes.includes(userId);
|
||||||
|
|
||||||
if (interaction.customId === 'upvote') {
|
if (interaction.customId === "upvote") {
|
||||||
if (hasUpvoted) {
|
if (hasUpvoted) {
|
||||||
suggestion.upvotes = suggestion.upvotes.filter(id => id !== userId);
|
suggestion.upvotes = suggestion.upvotes.filter((id) => id !== userId);
|
||||||
} else {
|
} else {
|
||||||
suggestion.upvotes.push(userId);
|
suggestion.upvotes.push(userId);
|
||||||
if (hasDownvoted) {
|
if (hasDownvoted) {
|
||||||
suggestion.downvotes = suggestion.downvotes.filter(id => id !== userId);
|
suggestion.downvotes = suggestion.downvotes.filter((id) => id !== userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (interaction.customId === 'downvote') {
|
} else if (interaction.customId === "downvote") {
|
||||||
if (hasDownvoted) {
|
if (hasDownvoted) {
|
||||||
suggestion.downvotes = suggestion.downvotes.filter(id => id !== userId);
|
suggestion.downvotes = suggestion.downvotes.filter((id) => id !== userId);
|
||||||
} else {
|
} else {
|
||||||
suggestion.downvotes.push(userId);
|
suggestion.downvotes.push(userId);
|
||||||
if (hasUpvoted) {
|
if (hasUpvoted) {
|
||||||
suggestion.upvotes = suggestion.upvotes.filter(id => id !== userId);
|
suggestion.upvotes = suggestion.upvotes.filter((id) => id !== userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (interaction.customId === 'removevote') {
|
} else if (interaction.customId === "removevote") {
|
||||||
suggestion.upvotes = suggestion.upvotes.filter(id => id !== userId);
|
suggestion.upvotes = suggestion.upvotes.filter((id) => id !== userId);
|
||||||
suggestion.downvotes = suggestion.downvotes.filter(id => id !== userId);
|
suggestion.downvotes = suggestion.downvotes.filter((id) => id !== userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.writeFileSync("./Data/SuggestionData.json", JSON.stringify(suggestions, null, 2));
|
fs.writeFileSync("./Data/SuggestionData.json", JSON.stringify(suggestions, null, 2));
|
||||||
@@ -228,13 +299,20 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
const upvoteCount = suggestion.upvotes.length;
|
const upvoteCount = suggestion.upvotes.length;
|
||||||
const downvoteCount = suggestion.downvotes.length;
|
const downvoteCount = suggestion.downvotes.length;
|
||||||
|
|
||||||
const updatedEmbed = new Discord.EmbedBuilder(interaction.message.embeds[0].data)
|
const updatedEmbed = new Discord.EmbedBuilder(interaction.message.embeds[0].data).setFields([
|
||||||
.setFields([
|
{ name: "Suggestion", value: suggestion.suggestion, inline: true },
|
||||||
{ name: 'Suggestion', value: suggestion.suggestion, inline: true },
|
{ name: "From", value: `<@${suggestion.author}>` },
|
||||||
{ name: 'From', value: `<@${suggestion.author}>` },
|
{
|
||||||
{ name: `${supportbot.Suggestions.UpvoteEmoji} ${supportbot.Suggestions.UpvoteTitle}`, value: `${upvoteCount}`, inline: true },
|
name: `${supportbot.Suggestions.UpvoteEmoji} ${supportbot.Suggestions.UpvoteTitle}`,
|
||||||
{ name: `${supportbot.Suggestions.DownvoteEmoji} ${supportbot.Suggestions.DownvoteTitle}`, value: `${downvoteCount}`, inline: true }
|
value: `${upvoteCount}`,
|
||||||
]);
|
inline: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: `${supportbot.Suggestions.DownvoteEmoji} ${supportbot.Suggestions.DownvoteTitle}`,
|
||||||
|
value: `${downvoteCount}`,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
await interaction.update({ embeds: [updatedEmbed] });
|
await interaction.update({ embeds: [updatedEmbed] });
|
||||||
}
|
}
|
||||||
@@ -246,7 +324,9 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
const Admin = await getRole(supportbot.Roles.StaffMember.Admin, interaction.guild);
|
const Admin = await getRole(supportbot.Roles.StaffMember.Admin, interaction.guild);
|
||||||
|
|
||||||
if (!SupportStaff || !Admin) {
|
if (!SupportStaff || !Admin) {
|
||||||
return interaction.reply("Some roles seem to be missing!\nPlease check for errors when starting the bot.");
|
return interaction.reply(
|
||||||
|
"Some roles seem to be missing!\nPlease check for errors when starting the bot."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const NoPerms = new Discord.EmbedBuilder()
|
const NoPerms = new Discord.EmbedBuilder()
|
||||||
@@ -256,7 +336,10 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
)
|
)
|
||||||
.setColor(supportbot.Embed.Colours.Warn);
|
.setColor(supportbot.Embed.Colours.Warn);
|
||||||
|
|
||||||
if (!interaction.member.roles.cache.has(SupportStaff.id) && !interaction.member.roles.cache.has(Admin.id)) {
|
if (
|
||||||
|
!interaction.member.roles.cache.has(SupportStaff.id) &&
|
||||||
|
!interaction.member.roles.cache.has(Admin.id)
|
||||||
|
) {
|
||||||
return interaction.reply({ embeds: [NoPerms] });
|
return interaction.reply({ embeds: [NoPerms] });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,9 +347,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
await interaction.channel.setInvitable(enable);
|
await interaction.channel.setInvitable(enable);
|
||||||
|
|
||||||
const message = enable ? msgconfig.Ticket.EnableInvites : msgconfig.Ticket.DisableInvites;
|
const message = enable ? msgconfig.Ticket.EnableInvites : msgconfig.Ticket.DisableInvites;
|
||||||
const embed = new Discord.EmbedBuilder()
|
const embed = new Discord.EmbedBuilder().setDescription(message).setColor(supportbot.Embed.Colours.General);
|
||||||
.setDescription(message)
|
|
||||||
.setColor(supportbot.Embed.Colours.General);
|
|
||||||
|
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
@@ -275,7 +356,7 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Modal submission handler for editing profile
|
// Modal submission handler for editing profile
|
||||||
if (interaction.type === Discord.InteractionType.ModalSubmit && interaction.customId === 'editProfileModal') {
|
if (interaction.type === Discord.InteractionType.ModalSubmit && interaction.customId === "editProfileModal") {
|
||||||
const userId = interaction.user.id;
|
const userId = interaction.user.id;
|
||||||
const profilePath = `./Data/Profiles/${userId}.json`;
|
const profilePath = `./Data/Profiles/${userId}.json`;
|
||||||
|
|
||||||
@@ -286,13 +367,13 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
profileData = {
|
profileData = {
|
||||||
bio: "",
|
bio: "",
|
||||||
timezone: "",
|
timezone: "",
|
||||||
clockedIn: false
|
clockedIn: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const newBio = interaction.fields.getTextInputValue('bio');
|
const newBio = interaction.fields.getTextInputValue("bio");
|
||||||
const newTimezone = interaction.fields.getTextInputValue('timezone');
|
const newTimezone = interaction.fields.getTextInputValue("timezone");
|
||||||
|
|
||||||
profileData.bio = newBio;
|
profileData.bio = newBio;
|
||||||
profileData.timezone = newTimezone;
|
profileData.timezone = newTimezone;
|
||||||
@@ -304,22 +385,25 @@ module.exports = new Event("interactionCreate", async (client, interaction) => {
|
|||||||
.setColor(supportbot.Embed.Colours.General)
|
.setColor(supportbot.Embed.Colours.General)
|
||||||
.setThumbnail(interaction.user.displayAvatarURL())
|
.setThumbnail(interaction.user.displayAvatarURL())
|
||||||
.addFields(
|
.addFields(
|
||||||
{ name: 'Bio', value: newBio || 'No bio set.', inline: false },
|
{ name: "Bio", value: newBio || "No bio set.", inline: false },
|
||||||
{ name: 'Timezone', value: newTimezone || 'No timezone set.', inline: true }
|
{ name: "Timezone", value: newTimezone || "No timezone set.", inline: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
if (profileData.clockedIn !== undefined) {
|
if (profileData.clockedIn !== undefined) {
|
||||||
updatedProfileEmbed.addFields({
|
updatedProfileEmbed.addFields({
|
||||||
name: 'Clocked In Status',
|
name: "Clocked In Status",
|
||||||
value: profileData.clockedIn ? '✅ Clocked In' : '❌ Clocked Out',
|
value: profileData.clockedIn ? "✅ Clocked In" : "❌ Clocked Out",
|
||||||
inline: true
|
inline: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await interaction.reply({ embeds: [updatedProfileEmbed], ephemeral: true });
|
await interaction.reply({ embeds: [updatedProfileEmbed], ephemeral: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to update profile data: ", error);
|
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 });
|
await interaction.reply({
|
||||||
|
content: "There was an error while updating your profile. Please try again later.",
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
+24
-4
@@ -14,10 +14,10 @@ function loadConfig(path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const supportbotai = yaml.load(fs.readFileSync("./Configs/supportbot-ai.yml"));
|
const supportbotai = loadConfig("./Configs/supportbot-ai.yml");
|
||||||
const supportbot = yaml.load(fs.readFileSync("./Configs/supportbot.yml", "utf8"));
|
const supportbot = loadConfig("./Configs/supportbot.yml");
|
||||||
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
|
const cmdconfig = loadConfig("./Configs/commands.yml");
|
||||||
const msgconfig = yaml.load(fs.readFileSync("./Configs/messages.yml", "utf8"));
|
const msgconfig = loadConfig("./Configs/messages.yml");
|
||||||
|
|
||||||
// Validate configuration values
|
// Validate configuration values
|
||||||
function validateConfig(config, keys) {
|
function validateConfig(config, keys) {
|
||||||
@@ -28,6 +28,11 @@ function validateConfig(config, keys) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validateConfig(supportbotai, ['General', 'Channels', 'Messages']);
|
||||||
|
validateConfig(supportbot, ['Embed']);
|
||||||
|
validateConfig(cmdconfig, ['Ping']);
|
||||||
|
validateConfig(msgconfig, ['ErrorResponse', 'OpenAIError']);
|
||||||
|
|
||||||
const CHANNELS = [supportbotai.Channels.AIChannel];
|
const CHANNELS = [supportbotai.Channels.AIChannel];
|
||||||
|
|
||||||
// Initialize Discord client
|
// Initialize Discord client
|
||||||
@@ -64,11 +69,26 @@ 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
|
// Event handler for message creation
|
||||||
module.exports = new Event("messageCreate", async (client, message) => {
|
module.exports = new Event("messageCreate", async (client, message) => {
|
||||||
if (message.author.bot || !message.guild) return;
|
if (message.author.bot || !message.guild) return;
|
||||||
if (!CHANNELS.includes(message.channelId) && !message.mentions.users.has(client.user.id)) 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(() => {
|
const sendTypingInterval = setInterval(() => {
|
||||||
message.channel.sendTyping();
|
message.channel.sendTyping();
|
||||||
|
|||||||
+14
-2
@@ -85,8 +85,20 @@ class Client extends Discord.Client {
|
|||||||
tempCommandFiles = tempCommandFiles.filter(item => item !== "Ping.js");
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "Ping.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supportbot.Ticket.ClaimTickets.Enabled === false) {
|
if (cmdconfig.AddUser.Enabled === false) {
|
||||||
tempCommandFiles = tempCommandFiles.filter(item => item !== "ticketstats.js");
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "addUser.js");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmdconfig.RemoveUser.Enabled === false) {
|
||||||
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "removeUser.js");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmdconfig.ForceAddUser.Enabled === false) {
|
||||||
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "forceaddUser.js");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmdconfig.Profile.Enabled === false) {
|
||||||
|
tempCommandFiles = tempCommandFiles.filter(item => item !== "Profile.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
const commandFiles = tempCommandFiles;
|
const commandFiles = tempCommandFiles;
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
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;
|
||||||
Reference in new issue
Block a user