SupportBot-7.2-Release

This commit is contained in:
ItzEmerald committed 2021-10-24 22:41:46 +01:00
1 parent 85667ddfad
commit d4f95e752b
22 files changed
+1371 -1065

No files matched your search

+18 -21
View File
@@ -4,31 +4,28 @@
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
// Your Addon Config file! Saved in /Addons/Settings/YourAddonConig.yml // Your Addon Config file! Saved in /Addons/Settings/YourAddonConfig.yml
// const exampleaddon = yaml.load(fs.readFileSync('./Addons/Settings/YourAddonConig.yml', 'utf8')); // const exampleaddon = yaml.load(fs.readFileSync('./Addons/Settings/YourAddonConfig.yml', 'utf8'));
const Command = require("../Structures/Command.js"); const Command = require("../Structures/Command.js");
module.exports = new Command({ module.exports = new Command({
name: "hello", name: "hello",
description: "hello", description: "hello",
type: "BOTH", slashCommandOptions: [],
slashCommandOptions: [], permission: "SEND_MESSAGES",
permission: "SEND_MESSAGES",
async run(message, args, client) { async run(interaction) {
const Embed = new Discord.MessageEmbed()
.setDescription("Hello World!")
.setColor(supportbot.InfoColour);
const Embed = new Discord.MessageEmbed() interaction.reply({
.setDescription("Hello World!") embeds: [Embed],
.setColor(supportbot.InfoColour) });
},
message.channel.send({ });
embeds: [Embed]
})
}
});
+76 -56
View File
@@ -1,75 +1,95 @@
// SupportBot | Emerald Services // SupportBot | Emerald Services
// Info Command // Ticket Add Command
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const Command = require("../Structures/Command.js"); const Command = require("../Structures/Command.js");
async function asyncForEach(array, callback) { async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) { for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array); await callback(array[index], index, array);
}
} }
}
module.exports = new Command({ module.exports = new Command({
name: cmdconfig.TicketAdd, name: cmdconfig.TicketAdd,
description: cmdconfig.TicketAddDesc, description: cmdconfig.TicketAddDesc,
type: "BOTH", slashCommandOptions: [
slashCommandOptions: [], {
permission: "SEND_MESSAGES", name: "user",
description: "User to add",
type: "USER",
required: true,
},
],
permission: "SEND_MESSAGES",
async run(message, args, client) { async run(interaction) {
let SupportStaff =
interaction.guild.roles.cache.find(
(SupportTeam) => SupportTeam.name === supportbot.Staff
) ||
interaction.guild.roles.cache.find(
(SupportTeam) => SupportTeam.id === supportbot.Staff
);
let Admins =
interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.name === supportbot.Admin
) ||
interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.id === supportbot.Admin
);
let SupportStaff = message.guild.roles.cache.find(SupportTeam => SupportTeam.name === supportbot.Staff) || message.guild.roles.cache.find(SupportTeam => SupportTeam.id === supportbot.Staff) const NoPerms = new Discord.MessageEmbed()
let Admins = message.guild.roles.cache.find(AdminUser => AdminUser.name === supportbot.Admin) || message.guild.roles.cache.find(AdminUser => AdminUser.id === supportbot.Admin) .setTitle("Invalid Permissions!")
.setDescription(
`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``
)
.setColor(supportbot.WarningColour);
const NoPerms = new Discord.MessageEmbed() if (
.setTitle("Invalid Permissions!") interaction.member.roles.cache.has(SupportStaff.id) ||
.setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) interaction.member.roles.cache.has(Admins.id)
.setColor(supportbot.WarningColour) ) {
if (
!interaction.channel.name.startsWith(`${supportbot.TicketChannel}-`)
) {
const Exists = new Discord.MessageEmbed()
.setTitle("No Ticket Found!")
.setDescription(`${supportbot.NoValidTicket}`)
.setColor(supportbot.WarningColour);
return interaction.reply({ embeds: [Exists] });
}
if (message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id)) { let uMember = interaction.options.getUser("user");
if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const UserNotExist = new Discord.MessageEmbed()
const Exists = new Discord.MessageEmbed() .setTitle("User Not Found!")
.setTitle("No Ticket Found!") .setDescription(
.setDescription(`${supportbot.NoValidTicket}`) `${supportbot.UserNotFound}\n\nTry Again:\`/${cmdconfig.TicketAdd} <user#0000>\``
.setColor(supportbot.WarningColour); )
message.channel.send({ embeds: [Exists] }); .setColor(supportbot.ErrorColour);
return;
}
let uMember = message.mentions.users.first();
const UserNotExist = new Discord.MessageEmbed()
.setTitle("User Not Found!")
.setDescription(`${supportbot.UserNotFound}\n\nTry Again:\`${supportbot.Prefix}${cmdconfig.TicketAdd} <user#0000>\``)
.setColor(supportbot.ErrorColour)
if (!uMember) return message.channel.send({ embeds: [UserNotExist] });
message.channel.permissionOverwrites.edit(uMember, {
VIEW_CHANNEL: true,
READ_MESSAGE_HISTORY: true,
SEND_MESSAGES: true,
});
const Complete = new Discord.MessageEmbed()
.setTitle("User Added!")
.setDescription(supportbot.AddedUser.replace(/%user%/g, uMember.id))
.setTimestamp()
.setColor(supportbot.EmbedColour)
message.channel.send({ embeds: [Complete] });
} else {
return message.channel.send({ embeds: [NoPerms] });
} if (!uMember) return interaction.reply({ embeds: [UserNotExist] });
interaction.channel.permissionOverwrites.edit(uMember, {
VIEW_CHANNEL: true,
READ_MESSAGE_HISTORY: true,
SEND_MESSAGES: true,
});
const Complete = new Discord.MessageEmbed()
.setTitle("User Added!")
.setDescription(supportbot.AddedUser.replace(/%user%/g, uMember.id))
.setTimestamp()
.setColor(supportbot.EmbedColour);
interaction.reply({ embeds: [Complete] });
} else {
return interaction.reply({ embeds: [NoPerms] });
} }
},
}); });
+76 -56
View File
@@ -1,75 +1,95 @@
// SupportBot | Emerald Services // SupportBot | Emerald Services
// Info Command // Ticket Remove Command
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const Command = require("../Structures/Command.js"); const Command = require("../Structures/Command.js");
async function asyncForEach(array, callback) { async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) { for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array); await callback(array[index], index, array);
}
} }
}
module.exports = new Command({ module.exports = new Command({
name: cmdconfig.TicketRemove, name: cmdconfig.TicketRemove,
description: cmdconfig.TicketRemoveDesc, description: cmdconfig.TicketRemoveDesc,
type: "BOTH", slashCommandOptions: [
slashCommandOptions: [], {
permission: "SEND_MESSAGES", name: "user",
description: "User to remove",
type: "USER",
required: true,
},
],
permission: "SEND_MESSAGES",
async run(message, args, client) { async run(interaction) {
let SupportStaff =
interaction.guild.roles.cache.find(
(SupportTeam) => SupportTeam.name === supportbot.Staff
) ||
interaction.guild.roles.cache.find(
(SupportTeam) => SupportTeam.id === supportbot.Staff
);
let Admins =
interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.name === supportbot.Admin
) ||
interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.id === supportbot.Admin
);
let SupportStaff = message.guild.roles.cache.find(SupportTeam => SupportTeam.name === supportbot.Staff) || message.guild.roles.cache.find(SupportTeam => SupportTeam.id === supportbot.Staff) const NoPerms = new Discord.MessageEmbed()
let Admins = message.guild.roles.cache.find(AdminUser => AdminUser.name === supportbot.Admin) || message.guild.roles.cache.find(AdminUser => AdminUser.id === supportbot.Admin) .setTitle("Invalid Permissions!")
.setDescription(
`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``
)
.setColor(supportbot.WarningColour);
const NoPerms = new Discord.MessageEmbed() if (
.setTitle("Invalid Permissions!") interaction.member.roles.cache.has(SupportStaff.id) ||
.setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) interaction.member.roles.cache.has(Admins.id)
.setColor(supportbot.WarningColour) ) {
if (
!interaction.channel.name.startsWith(`${supportbot.TicketChannel}-`)
) {
const Exists = new Discord.MessageEmbed()
.setTitle("No Ticket Found!")
.setDescription(`${supportbot.NoValidTicket}`)
.setColor(supportbot.WarningColour);
return interaction.reply({ embeds: [Exists] });
}
if (message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id)) { let uMember = interaction.options.getUser("user");
if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const UserNotExist = new Discord.MessageEmbed()
const Exists = new Discord.MessageEmbed() .setTitle("User Not Found!")
.setTitle("No Ticket Found!") .setDescription(
.setDescription(`${supportbot.NoValidTicket}`) `${supportbot.UserNotFound}\n\nTry Again:\`/${cmdconfig.TicketRemove} <user#0000>\``
.setColor(supportbot.WarningColour); )
message.channel.send({ embeds: [Exists] }); .setColor(supportbot.ErrorColour);
return;
}
let uMember = message.mentions.users.first();
const UserNotExist = new Discord.MessageEmbed()
.setTitle("User Not Found!")
.setDescription(`${supportbot.UserNotFound}\n\nTry Again:\`${supportbot.Prefix}${cmdconfig.TicketRemove} <user#0000>\``)
.setColor(supportbot.ErrorColour)
if (!uMember) return message.channel.send({ embeds: [UserNotExist] });
message.channel.permissionOverwrites.edit(uMember, {
VIEW_CHANNEL: false,
READ_MESSAGE_HISTORY: false,
SEND_MESSAGES: false,
});
const Complete = new Discord.MessageEmbed()
.setTitle("User Removed!")
.setDescription(supportbot.RemovedUser.replace(/%user%/g, uMember.id))
.setTimestamp()
.setColor(supportbot.EmbedColour)
message.channel.send({ embeds: [Complete] });
} else {
return message.channel.send({ embeds: [NoPerms] });
} if (!uMember) return interaction.reply({ embeds: [UserNotExist] });
interaction.channel.permissionOverwrites.edit(uMember, {
VIEW_CHANNEL: false,
READ_MESSAGE_HISTORY: false,
SEND_MESSAGES: false,
});
const Complete = new Discord.MessageEmbed()
.setTitle("User Removed!")
.setDescription(supportbot.RemovedUser.replace(/%user%/g, uMember.id))
.setTimestamp()
.setColor(supportbot.EmbedColour);
interaction.reply({ embeds: [Complete] });
} else {
return interaction.reply({ embeds: [NoPerms] });
} }
},
}); });
+198 -145
View File
@@ -4,171 +4,224 @@
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const Command = require("../Structures/Command.js"); const Command = require("../Structures/Command.js");
const TicketNumberID = require('../Structures/TicketID.js'); const TicketNumberID = require("../Structures/TicketID.js");
async function asyncForEach(array, callback) { async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) { for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array); await callback(array[index], index, array);
}
} }
}
module.exports = new Command({ module.exports = new Command({
name: cmdconfig.CloseTicket, name: cmdconfig.CloseTicket,
description: cmdconfig.CloseTicketDesc, description: cmdconfig.CloseTicketDesc,
type: "BOTH", slashCommandOptions: [
slashCommandOptions: [], {
permission: "SEND_MESSAGES", name: "reason",
description: "Ticket Close Reason",
type: "STRING",
},
],
permission: "SEND_MESSAGES",
async run(message, args, client) { async run(interaction) {
if (!interaction.channel.name.startsWith(`${supportbot.TicketChannel}-`)) {
if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed()
const Exists = new Discord.MessageEmbed() .setTitle("No Ticket Found!")
.setTitle("No Ticket Found!") .setDescription(`${supportbot.NoValidTicket}`)
.setDescription(`${supportbot.NoValidTicket}`) .setColor(supportbot.WarningColour);
.setColor(supportbot.WarningColour); return interaction.reply({ embed: Exists });
message.channel.send({ embed: Exists }); }
return; if (supportbot.CloseConfirmation) {
const CloseTicketRequest = new Discord.MessageEmbed()
.setTitle(`**${supportbot.ClosingTicket}**`)
.setDescription(
`Please confirm by repeating the following word.. \`${supportbot.ClosingConfirmation_Word}\` `
)
.setColor(supportbot.EmbedColour);
} interaction
.reply(CloseTicketRequest)
.then((m) => {
interaction.channel
.awaitMessages(
(response) =>
response.content.toLowerCase() ===
supportbot.ClosingConfirmation_Word,
{
max: 1,
time: 20000,
errors: ["time"],
}
)
.then((collected) => {
let logChannel =
interaction.guild.channels.cache.find(
(channel) => channel.name === supportbot.TranscriptLog
) ||
interaction.guild.channels.cache.find(
(channel) => channel.id === supportbot.TranscriptLog
);
let user = interaction.user;
let reason =
interaction.options.getString("reason") ||
"No Reason Provided.";
if (supportbot.CloseConfirmation) { let name = interaction.channel.name;
const CloseTicketRequest = new Discord.MessageEmbed() let ticketChannel = interaction.channel;
.setTitle(`**${supportbot.ClosingTicket}**`)
.setDescription(`Please confirm by repeating the following word.. \`${supportbot.ClosingConfirmation_Word}\` `)
.setColor(supportbot.EmbedColour);
message.channel.send(CloseTicketRequest).then(m => { interaction
message.channel.awaitMessages( response => response.content.toLowerCase() === supportbot.ClosingConfirmation_Word, { .reply(`**${supportbot.ClosingTicket}**`)
max: 1,
time: 20000,
errors: [ 'time' ],
.then(() => {
}).then( collected => { const logEmbed = new Discord.MessageEmbed()
let logChannel = message.guild.channels.cache.find(channel => channel.name === supportbot.TranscriptLog) || message.guild.channels.cache.find(channel => channel.id === supportbot.TranscriptLog) .setTitle(supportbot.TranscriptTitle)
let user = message.author; .setColor(supportbot.EmbedColour)
let reason = args.join(" ") || "No Reason Provided."; .setFooter(supportbot.EmbedFooter)
.addField("Closed By", interaction.user.tag)
.addField("Reason", reason);
let name = message.channel.name; interaction.channel.interactions
let ticketChannel = message.channel; .fetch({ limit: 100 })
.then((msgs) => {
let html = "";
message.channel.send(`**${supportbot.ClosingTicket}**`) msgs = msgs.sort(
(a, b) => a.createdTimestamp - b.createdTimestamp
);
html += `<strong>Server Name:</strong> ${interaction.guild.name}<br>`;
html += `<strong>Ticket:</strong> ${ticketChannel.name}<br>`;
html += `<strong>Message:</strong> ${msgs.size} Messages<br><br><br>`;
.then(() => { msgs.forEach((msg) => {
const logEmbed = new Discord.MessageEmbed() if (msg.content) {
.setTitle(supportbot.TranscriptTitle) html += `<strong>User:</strong> ${msg.author.tag}<br>`;
.setColor(supportbot.EmbedColour) html += `<strong>Message:</strong> ${msg.content}<br>`;
.setFooter(supportbot.EmbedFooter) html += `-----<br><br>`;
.addField("Closed By", message.author.tag) }
.addField("Reason", reason); });
message.channel.messages.fetch({ limit: 100 }).then( msgs => { logChannel.send({ embeds: [logEmbed] }).catch((err) => {
let html = ''; interaction.reply(err);
});
msgs = msgs.sort( ( a, b ) => a.createdTimestamp - b.createdTimestamp ); let file = new Discord.MessageAttachment(
html += `<strong>Server Name:</strong> ${message.guild.name}<br>`; Buffer.from(html),
html += `<strong>Ticket:</strong> ${ticketChannel.name}<br>`; `${name}.html`
html += `<strong>Message:</strong> ${msgs.size} Messages<br><br><br>`; );
logChannel
.send({ embeds: [logEmbed], files: [file] })
.catch((err) => {
interaction.reply(err);
});
msgs.forEach( msg => { interaction.channel.delete().catch((error) => {
if ( msg.content ) { if (
html += `<strong>User:</strong> ${msg.author.tag}<br>`; error.code !==
html += `<strong>Message:</strong> ${msg.content}<br>`; Discord.Constants.APIErrors.UNKNOWN_CHANNEL
html += `-----<br><br>`; ) {
} console.error(
}); "Failed to delete the interaction:",
error
logChannel.send({embeds: [logEmbed]}).catch(err => { );
message.reply(err) }
}) });
let file = new Discord.MessageAttachment( Buffer.from( html ), `${name}.html` )
logChannel.send({embeds: [logEmbed], files: [file]}).catch(err => {
message.reply(err)
})
message.channel.delete().catch(error => {
if (error.code !== Discord.Constants.APIErrors.UNKNOWN_CHANNEL) {
console.error('Failed to delete the message:', error);
}
});
})
})
})
}).catch( () => {
interaction.m.edit({content: 'The request to close the ticket has timed out.'}).then(m2 => setTimeout(() => channel.delete(3000)) );
});
}
if (!supportbot.CloseConfirmation) {
let logChannel = message.guild.channels.cache.find(channel => channel.name === supportbot.TranscriptLog) || message.guild.channels.cache.find(channel => channel.id === supportbot.TranscriptLog)
let user = message.author;
let reason = args.join(" ") || "No Reason Provided.";
let name = message.channel.name;
let ticketChannel = message.channel;
message.channel.send(`**${supportbot.ClosingTicket}**`)
.then(() => {
const logEmbed = new Discord.MessageEmbed()
.setTitle(supportbot.TranscriptTitle)
.setColor(supportbot.EmbedColour)
.setFooter(supportbot.EmbedFooter)
.addField("Closed By", message.author.tag)
.addField("Reason", reason);
message.channel.messages.fetch({ limit: 100 }).then( msgs => {
let html = '';
msgs = msgs.sort( ( a, b ) => a.createdTimestamp - b.createdTimestamp );
html += `<strong>Server Name:</strong> ${message.guild.name}<br>`;
html += `<strong>Ticket:</strong> ${ticketChannel.name}<br>`;
html += `<strong>Message:</strong> ${msgs.size} Messages<br><br><br>`;
msgs.forEach( msg => {
if ( msg.content ) {
html += `<strong>User:</strong> ${msg.author.tag}<br>`;
html += `<strong>Message:</strong> ${msg.content}<br>`;
html += `-----<br><br>`;
}
});
logChannel.send({embeds: [logEmbed]}).catch(err => {
message.reply(err)
})
let file = new Discord.MessageAttachment( Buffer.from( html ), `${name}.html` )
logChannel.send({embeds: [logEmbed], files: [file]}).catch(err => {
message.reply(err)
})
message.channel.delete().catch(error => {
if (error.code !== Discord.Constants.APIErrors.UNKNOWN_CHANNEL) {
console.error('Failed to delete the message:', error);
}
});
})
}).catch( () => {
interaction.m.edit({content: 'The request to close the ticket has timed out.'}).then(m2 => setTimeout(() => channel.delete(3000)) );
}); });
});
});
})
.catch(() => {
interaction
.followUp({
content: "The request to close the ticket has timed out.",
})
.then((m2) => setTimeout(() => interaction.channel.delete(3000)));
});
}
} if (!supportbot.CloseConfirmation) {
let logChannel =
interaction.guild.channels.cache.find(
(channel) => channel.name === supportbot.TranscriptLog
) ||
interaction.guild.channels.cache.find(
(channel) => channel.id === supportbot.TranscriptLog
);
let user = interaction.user;
let reason =
(await interaction.options.getString("reason")) ||
"No Reason Provided.";
} let name = interaction.channel.name;
let ticketChannel = interaction.channel;
interaction
.reply(`**${supportbot.ClosingTicket}**`)
.then(() => {
const logEmbed = new Discord.MessageEmbed()
.setTitle(supportbot.TranscriptTitle)
.setColor(supportbot.EmbedColour)
.setFooter(supportbot.EmbedFooter)
.addField("Closed By", interaction.user.tag)
.addField("Reason", reason);
interaction.channel.interactions
.fetch({ limit: 100 })
.then((msgs) => {
let html = "";
msgs = msgs.sort(
(a, b) => a.createdTimestamp - b.createdTimestamp
);
html += `<strong>Server Name:</strong> ${interaction.guild.name}<br>`;
html += `<strong>Ticket:</strong> ${ticketChannel.name}<br>`;
html += `<strong>Message:</strong> ${msgs.size} Messages<br><br><br>`;
msgs.forEach((msg) => {
if (msg.content) {
html += `<strong>User:</strong> ${msg.author.tag}<br>`;
html += `<strong>Message:</strong> ${msg.content}<br>`;
html += `-----<br><br>`;
}
});
logChannel.send({ embeds: [logEmbed] }).catch((err) => {
interaction.reply(err);
});
let file = new Discord.MessageAttachment(
Buffer.from(html),
`${name}.html`
);
logChannel
.send({ embeds: [logEmbed], files: [file] })
.catch((err) => {
interaction.reply(err);
});
interaction.channel.delete().catch((error) => {
if (
error.code !== Discord.Constants.APIErrors.UNKNOWN_CHANNEL
) {
console.error("Failed to delete the interaction:", error);
}
});
});
})
.catch(() => {
interaction
.followUp({
content: "The request to close the ticket has timed out.",
})
.then((m2) => setTimeout(() => interaction.channel.delete(3000)));
});
}
},
}); });
+78
View File
@@ -0,0 +1,78 @@
// SupportBot | Emerald Services
// Embed Command
const fs = require("fs");
const Discord = require("discord.js");
const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const Command = require("../Structures/Command.js");
module.exports = new Command({
name: cmdconfig.EmbedCommand,
description: cmdconfig.EmbedCommandDesc,
slashCommandOptions: [
{
name: "title",
description: "Embed Title",
type: "STRING",
},
{
name: "message",
description: "Embed Message",
type: "STRING",
},
],
permission: "SEND_MESSAGES",
async run(interaction) {
let SupportStaff =
interaction.guild.roles.cache.find(
(SupportTeam) => SupportTeam.name === supportbot.Staff
) ||
interaction.guild.roles.cache.find(
(SupportTeam) => SupportTeam.id === supportbot.Staff
);
let Admins =
interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.name === supportbot.Admin
) ||
interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.id === supportbot.Admin
);
const NoPerms = new Discord.MessageEmbed()
.setTitle("Invalid Permissions!")
.setDescription(
`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``
)
.setColor(supportbot.WarningColour);
if (
interaction.member.roles.cache.has(SupportStaff.id) ||
interaction.member.roles.cache.has(Admins.id)
) {
const EmbedTitle = interaction.options.getString("title")
const EmbedSubject = interaction.options.getString("message")
const EmbedMsg = new Discord.MessageEmbed()
.setTitle(EmbedTitle)
.setDescription(EmbedSubject)
interaction.reply({
embeds: [EmbedMsg],
});
} else {
return interaction.reply({ embeds: [NoPerms] });
}
},
});
+87 -69
View File
@@ -1,86 +1,104 @@
// SupportBot | Emerald Services // SupportBot | Emerald Services
// Close Ticket Command // Help Command
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const Command = require("../Structures/Command.js"); const Command = require("../Structures/Command.js");
const TicketNumberID = require('../Structures/TicketID.js');
async function asyncForEach(array, callback) { async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) { for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array); await callback(array[index], index, array);
}
} }
}
module.exports = new Command({ module.exports = new Command({
name: cmdconfig.HelpCommand, name: cmdconfig.HelpCommand,
description: cmdconfig.HelpCommandDesc, description: cmdconfig.HelpCommandDesc,
type: "BOTH", slashCommandOptions: [],
slashCommandOptions: [], permission: "SEND_MESSAGES",
permission: "SEND_MESSAGES",
async run(message, args, client) { async run(interaction) {
let SupportStaff =
interaction.guild.roles.cache.find(
(adminRole) => adminRole.name === supportbot.Staff
) ||
interaction.guild.roles.cache.find(
(staffRole) => staffRole.id === supportbot.Staff
);
let AdminStaff =
interaction.guild.roles.cache.find(
(adminRole) => adminRole.name === supportbot.Admin
) ||
interaction.guild.roles.cache.find(
(adminRole) => adminRole.id === supportbot.Admin
);
let SupportStaff = message.guild.roles.cache.find(adminRole => adminRole.name === supportbot.Staff) || message.guild.roles.cache.find(staffRole => staffRole.id === supportbot.Staff); if (supportbot.HelpMenu) {
let AdminStaff = message.guild.roles.cache.find(adminRole => adminRole.name === supportbot.Admin) || message.guild.roles.cache.find(adminRole => adminRole.id === supportbot.Admin); let botCommands = "";
botCommands += `**/${cmdconfig.HelpCommand}** ${cmdconfig.HelpCommandDesc}\n`;
if (supportbot.HelpMenu) { botCommands += `**/${cmdconfig.InfoCommand}** ${cmdconfig.InfoCommandDesc}\n`;
let botCommands = ""; botCommands += `**/${cmdconfig.PingCommand}** ${cmdconfig.PingCommandDesc}\n`;
botCommands += `**${supportbot.Prefix}${cmdconfig.HelpCommand}** ${cmdconfig.HelpCommandDesc}\n`;
botCommands += `**${supportbot.Prefix}${cmdconfig.InfoCommand}** ${cmdconfig.InfoCommandDesc}\n`;
botCommands += `**${supportbot.Prefix}${cmdconfig.PingCommand}** ${cmdconfig.PingCommandDesc}\n`
let ticketCommands = "";
ticketCommands += `**${supportbot.Prefix}${cmdconfig.OpenTicket}** ${cmdconfig.OpenTicketDesc}\n`;
ticketCommands += `**${supportbot.Prefix}${cmdconfig.CloseTicket}** ${cmdconfig.CloseTicketDesc}\n`
let staffCommands = ""; let ticketCommands = "";
staffCommands += `**${supportbot.Prefix}${cmdconfig.TicketAdd}** ${cmdconfig.TicketAddDesc}\n` ticketCommands += `**/${cmdconfig.OpenTicket}** ${cmdconfig.OpenTicketDesc}\n`;
staffCommands += `**${supportbot.Prefix}${cmdconfig.TicketRemove}** ${cmdconfig.TicketRemoveDesc}\n` ticketCommands += `**/${cmdconfig.CloseTicket}** ${cmdconfig.CloseTicketDesc}\n`;
const HelpEmbed1 = new Discord.MessageEmbed() let staffCommands = "";
.setTitle(supportbot.Name) staffCommands += `**/${cmdconfig.TicketAdd}** ${cmdconfig.TicketAddDesc}\n`;
.setThumbnail(message.author.displayAvatarURL()) staffCommands += `**/${cmdconfig.TicketRemove}** ${cmdconfig.TicketRemoveDesc}\n`;
.addFields( const HelpEmbed1 = new Discord.MessageEmbed()
{ name: '🖥️ General Commands\n', value: `${botCommands}\n`, inline: false }, .setTitle(supportbot.Name + " Commands")
{ name: '🎫 Support Commands\n', value: `${ticketCommands}\n`, inline: false }, .setThumbnail(interaction.user.displayAvatarURL())
)
.addFields(
.setColor(supportbot.EmbedColour) {
.setFooter(supportbot.EmbedFooter, message.author.displayAvatarURL()); name: "🖥️ General Commands\n",
value: `${botCommands}\n`,
if (message.member.roles.cache.has(SupportStaff.id)) { inline: false,
HelpEmbed1.addFields( },
{ name: '🔐 Staff Commands\n', value: `${staffCommands}\n`, inline: false }, {
) name: "🎫 Support Commands\n",
} else { value: `${ticketCommands}\n`,
if ((message.member.roles.cache.has(AdminStaff.id))) { inline: false,
HelpEmbed1.addFields( }
{ name: '🔐 Staff Commands\n', value: `${staffCommands}\n`, inline: false }, )
)
} .setColor(supportbot.EmbedColour)
} .setFooter(supportbot.EmbedFooter, interaction.user.displayAvatarURL());
if (supportbot.SendHelpPage === "dm") { if (interaction.member.roles.cache.has(SupportStaff.id)) {
message.author.send({ HelpEmbed1.addFields({
embeds: [HelpEmbed1] name: "🔐 Staff Commands\n",
}); value: `${staffCommands}\n`,
} inline: false,
});
if (supportbot.SendHelpPage === "channel") { } else {
message.channel.send({ if (interaction.member.roles.cache.has(AdminStaff.id)) {
embeds: [HelpEmbed1] HelpEmbed1.addFields({
}); name: "🔐 Staff Commands\n",
} value: `${staffCommands}\n`,
inline: false,
});
}
} }
}
if (supportbot.SendHelpPage === "dm") {
interaction.user.reply({
embeds: [HelpEmbed1],
});
}
if (supportbot.SendHelpPage === "channel") {
interaction.reply({
embeds: [HelpEmbed1],
});
}
}
},
}); });
+24 -28
View File
@@ -4,39 +4,35 @@
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const Command = require("../Structures/Command.js"); const Command = require("../Structures/Command.js");
module.exports = new Command({ module.exports = new Command({
name: cmdconfig.InfoCommand, name: cmdconfig.InfoCommand,
description: cmdconfig.InfoCommandDesc, description: cmdconfig.InfoCommandDesc,
type: "BOTH", slashCommandOptions: [],
slashCommandOptions: [], permission: "SEND_MESSAGES",
permission: "SEND_MESSAGES",
async run(message, args, client) { async run(interaction) {
const InfoButton = new Discord.MessageButton()
.setLabel(supportbot.InfoButtonText)
.setURL(supportbot.InfoURL)
.setStyle("LINK");
const InfoButton = new Discord.MessageButton() const inforow = new Discord.MessageActionRow().addComponents(InfoButton);
.setLabel(supportbot.InfoButtonText)
.setURL(supportbot.InfoURL)
.setStyle('LINK')
const inforow = new Discord.MessageActionRow() const InfoEmbed = new Discord.MessageEmbed()
.addComponents(InfoButton) .setURL(supportbot.InfoURL)
.setTitle(supportbot.InfoTitle)
.setDescription(supportbot.AboutMe)
.setColor(supportbot.InfoColour);
const InfoEmbed = new Discord.MessageEmbed() interaction.reply({
.setURL(supportbot.InfoURL) embeds: [InfoEmbed],
.setTitle(supportbot.InfoTitle) components: [inforow],
.setDescription(supportbot.AboutMe) });
.setColor(supportbot.InfoColour) },
});
message.channel.send({
embeds: [InfoEmbed], components: [inforow]
})
}
});
+4 -2
View File
@@ -14,13 +14,14 @@
# Commamnd Name Configuration # Commamnd Name Configuration
# ------------------------------- # -------------------------------
TicketAdd: "ticketadd" TicketAdd: "add"
TicketRemove: "ticketremove" TicketRemove: "remove"
OpenTicket: "ticket" OpenTicket: "ticket"
CloseTicket: "close" CloseTicket: "close"
InfoCommand: "info" InfoCommand: "info"
PingCommand: "ping" PingCommand: "ping"
HelpCommand: "help" HelpCommand: "help"
EmbedCommand: "embed"
# --------------------------------------- # ---------------------------------------
# Commamnd Description Configuration # Commamnd Description Configuration
@@ -33,5 +34,6 @@ CloseTicketDesc: "Close your support ticket."
InfoCommandDesc: "Get information about the brand." InfoCommandDesc: "Get information about the brand."
PingCommandDesc: "Pong!" PingCommandDesc: "Pong!"
HelpCommandDesc: "Get a list of all the commands." HelpCommandDesc: "Get a list of all the commands."
EmbedCommandDesc: "Send a message as an embed."
+2 -2
View File
@@ -17,14 +17,14 @@ SupportBot_Version: "7.2 pre-3"
# ------------------------- # -------------------------
Name: "SupportBot" Name: "SupportBot"
Prefix: "!" Prefix: "!" # Everything uses the new Slash (/) Commands feature!
Token: "BOT_TOKEN" Token: "BOT_TOKEN"
# ------------------------- # -------------------------
# Activity Configuration # Activity Configuration
# ------------------------- # -------------------------
BotActivity: "Need Help? -ticket" BotActivity: "Need Help? /ticket"
StreamingURL: "https://www.twitch.tv/YOUR_TWITCH_NAME" StreamingURL: "https://www.twitch.tv/YOUR_TWITCH_NAME"
# Set The ActivityType to "STREAMING" for a streaming status! # Set The ActivityType to "STREAMING" for a streaming status!
+1 -1
View File
@@ -1 +1 @@
TicketPanelID: '896035054235574362' TicketPanelID: ''
+28 -25
View File
@@ -4,37 +4,40 @@
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const panelconfig = yaml.load(fs.readFileSync('./Data/ticket-panel.yml', 'utf8')); const panelconfig = yaml.load(
fs.readFileSync("./Data/ticket-panel.yml", "utf8")
);
const Event = require("../Structures/Event.js"); const Event = require("../Structures/Event.js");
module.exports = new Event("messageReactionAdd", async (client) => { module.exports = new Event("messageReactionAdd", async (client) => {
let message = {
guild: reaction.message.channel.guild,
author: user,
content: "N/A",
channel: reaction.message.channel,
};
let message = { if (panelconfig.TicketPanel) {
guild: reaction.message.channel.guild, if (reaction.message.id === panelconfig.TicketPanelID) {
author: user, if (
content: "N/A", reaction.emoji.name == panelconfig.ButtonEmoji ||
channel: reaction.message.channel reaction.emoji.id == panelconfig.ButtonEmoji
} ) {
await reaction.users.remove(user.id);
if (panelconfig.TicketPanel) { try {
if (reaction.message.id === panelconfig.TicketPanelID) { const cmd = client.commands.get(cmdconfig.OpenTicket);
if (reaction.emoji.name == panelconfig.ButtonEmoji || reaction.emoji.id == panelconfig.ButtonEmoji) { if (!cmd) return;
await reaction.users.remove(user.id)
try { cmd.run(message, message.content);
const cmd = client.commands.get(cmdconfig.OpenTicket); } catch (error) {
if(!cmd) return; console.error(error);
cmd.run(message, message.content);
} catch (error) {
console.error(error);
}
}
} }
}
} }
}
}); });
+62 -66
View File
@@ -8,96 +8,92 @@ const Command = require("./Command.js");
const Event = require("./Event.js"); const Event = require("./Event.js");
const intents = new Discord.Intents(32767); const intents = new Discord.Intents(32767);
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
class Client extends Discord.Client { class Client extends Discord.Client {
constructor() { constructor() {
super({ intents }); super({ intents });
this.commands = new Discord.Collection(); this.commands = new Discord.Collection();
}
this.prefix = supportbot.Prefix; start(token) {
} const commandFiles = fs
.readdirSync("./Commands")
.filter((file) => file.endsWith(".js"));
start(token) { const commands = commandFiles.map((file) => require(`../Commands/${file}`));
const commandFiles = fs.readdirSync("./Commands")
.filter(file => file.endsWith(".js"));
const commands = commandFiles.map(file => require(`../Commands/${file}`)); console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬");
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬') commands.forEach((cmd) => {
console.log(`\u001b[31;1m`, `${cmd.name}`, `\u001b[32;1m`, "Loaded");
this.commands.set(cmd.name, cmd);
});
commands.forEach(cmd => { console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬");
console.log(`\u001b[31;1m`, `${cmd.name}`, `\u001b[32;1m`, 'Loaded');
this.commands.set(cmd.name, cmd);
});
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬') // Addons
// Addons const addonFiles = fs
.readdirSync("./Addons")
.filter((file) => file.endsWith(".js"));
const addonFiles = fs.readdirSync("./Addons") const addons = addonFiles.map((file) => require(`../Addons/${file}`));
.filter(file => file.endsWith(".js"));
const addons = addonFiles.map(file => require(`../Addons/${file}`)); console.log(" ");
console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬");
console.log(' ') addons.forEach((addon) => {
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬') console.log(`\u001b[31;1m`, `${addon.name}`, `\u001b[32;1m`, "Loaded");
this.commands.set(addon.name, addon);
});
addons.forEach(addon => { console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬");
console.log(`\u001b[31;1m`, `${addon.name}`, `\u001b[32;1m`, 'Loaded'); console.log(" ");
this.commands.set(addon.name, addon);
});
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬') // Slash Commands
console.log(' ')
// Slash Commands const slashCommands = commands.map((cmd) => ({
name: cmd.name.toLowerCase(),
description: cmd.description,
permissions: [],
options: cmd.slashCommandOptions,
defaultPermission: true,
}));
const slashCommands = commands this.removeAllListeners();
.filter(cmd => ["BOTH", "SLASH"].includes(cmd.type))
.map(cmd => ({
name: cmd.name.toLowerCase(),
description: cmd.description,
permissions: [],
options: cmd.slashCommandOptions,
defaultPermission: true
}));
this.removeAllListeners(); this.on("ready", async () => {
const cmds = await this.application?.commands.set(slashCommands);
this.on("ready", async () => { console.log(" ");
const cmds = await this.application.commands.set(slashCommands); console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Slash Command ▬▬▬▬▬▬▬"),
console.log(" ");
console.log(' ') cmds.forEach((cmd) =>
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Slash Command ▬▬▬▬▬▬▬'), console.log(`Slash Command ${cmd.name} registered`)
console.log(' ') );
});
cmds.forEach(cmd => console.log(" ");
console.log(`Slash Command ${cmd.name} registered`), console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬");
)
}) fs.readdirSync("./Events")
.filter((file) => file.endsWith(".js"))
.forEach((file) => {
const event = require(`../Events/${file}`);
console.log(`\u001b[31;1m`, `${event.event}`, `\u001b[32;1m`, "Loaded");
console.log(' ') this.on(event.event, event.run.bind(null, this));
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬') });
fs.readdirSync("./Events") console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬");
.filter(file => file.endsWith(".js")) console.log(" ");
.forEach(file => {
const event = require(`../Events/${file}`); this.login(token);
console.log(`\u001b[31;1m`, `${event.event}`, `\u001b[32;1m`, 'Loaded'); }
this.on(event.event, event.run.bind(null, this));
});
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬')
console.log(' ')
this.login(token);
}
} }
module.exports = Client; module.exports = Client;
+11 -12
View File
@@ -5,20 +5,19 @@ const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
function RunFunction(message, args, client) {} function RunFunction(interaction) {}
class Command { class Command {
constructor(options) { constructor(options) {
this.name = options.name; this.name = options.name;
this.description = options.description; this.description = options.description;
this.permission = options.permission; this.permission = options.permission;
this.type = ["BOTH", "SLASH", "TEXT"].includes(options.type) ? options.type : "TEXT"; this.slashCommandOptions = options.slashCommandOptions || [];
this.slashCommandOptions = options.slashCommandOptions || []; this.run = options.run;
this.run = options.run; }
}
} }
module.exports = Command; module.exports = Command;
+7 -8
View File
@@ -5,17 +5,16 @@ const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
function RunFunction(client, ...eventArgs) {} function RunFunction(client, ...eventArgs) {}
class Event { class Event {
constructor(event, runFunction) {
constructor(event, runFunction) { this.event = event;
this.event = event; this.run = runFunction;
this.run = runFunction; }
}
} }
module.exports = Event; module.exports = Event;
+57 -43
View File
@@ -8,69 +8,83 @@ const Command = require("./Command.js");
const Client = require("./Client.js"); const Client = require("./Client.js");
const Event = require("./Event.js"); const Event = require("./Event.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
class TicketNumberID { class TicketNumberID {
static pad(guildId) {
static pad(guildId) { let n = this.get(guildId) + "";
let n = this.get(guildId) + ''; let z = "0";
let z = '0'; let width = 4;
let width = 4; setTimeout(() => {
setTimeout(() => { this.set(guildId, this.get(guildId) + 1);
this.set(guildId, this.get(guildId) + 1); }, 50);
}, 50); return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n; }
}
static get(guildId) { static get(guildId) {
let ticketnumberID = JSON.parse(
let ticketnumberID = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8")); fs.readFileSync("./Data/TicketData.json", "utf8")
);
if (!ticketnumberID[guildId]) { if (!ticketnumberID[guildId]) {
ticketnumberID[guildId] = { ticketnumberID[guildId] = {
id: 0 id: 0,
};
fs.writeFileSync(
"./Data/TicketData.json",
JSON.stringify(ticketnumberID, null, 4),
(err) => {
if (err) console.log(err);
} }
);
fs.writeFileSync("./Data/TicketData.json", JSON.stringify(ticketnumberID, null, 4), err => { return 0;
if (err) console.log(err);
});
return 0;
} else { } else {
return ticketnumberID[guildId].id; return ticketnumberID[guildId].id;
} }
} }
static set(guildId, value) {
let ticketnumberID = JSON.parse(
fs.readFileSync("./Data/TicketData.json", "utf8")
);
static set(guildId, value) {
let ticketnumberID = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
ticketnumberID[guildId] = { ticketnumberID[guildId] = {
id: value id: value,
} };
fs.writeFileSync("./Data/TicketData.json", JSON.stringify(ticketnumberID, null, 4), err => { fs.writeFileSync(
"./Data/TicketData.json",
JSON.stringify(ticketnumberID, null, 4),
(err) => {
if (err) console.log(err); if (err) console.log(err);
}); }
);
return value; return value;
} }
static reset(guildId) {
let ticketnumberID = JSON.parse(
fs.readFileSync("./Data/TicketData.json", "utf8")
);
static reset(guildId) {
let ticketnumberID = JSON.parse(fs.readFileSync("./Data/TicketData.json", "utf8"));
ticketnumberID[guildId] = { ticketnumberID[guildId] = {
id: 0 id: 0,
} };
fs.writeFileSync("./Data/TicketData.json", JSON.stringify(ticketnumberID, null, 4), err => { fs.writeFileSync(
"./Data/TicketData.json",
JSON.stringify(ticketnumberID, null, 4),
(err) => {
if (err) console.log(err); if (err) console.log(err);
}); }
);
return 0; return 0;
} }
} }
module.exports = TicketNumberID; module.exports = TicketNumberID;
+18 -18
View File
@@ -4,27 +4,27 @@
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const Command = require("../Structures/Command.js"); const Command = require("../Structures/Command.js");
module.exports = new Command({ module.exports = new Command({
name: cmdconfig.PingCommand, name: cmdconfig.PingCommand,
description: cmdconfig.PingCommandDesc, description: cmdconfig.PingCommandDesc,
type: "BOTH", slashCommandOptions: [],
slashCommandOptions: [], permission: "SEND_MESSAGES",
permission: "SEND_MESSAGES",
async run(message, args, client) { async run(interaction) {
const PingEmbed = new Discord.MessageEmbed()
.setDescription(
`:ping_pong: **Ping:** \`${interaction.client.ws.ping} ms\``
)
.setColor(supportbot.EmbedColour);
const PingEmbed = new Discord.MessageEmbed() interaction.reply({
.setDescription(`:ping_pong: **Ping:** \`${client.ws.ping} ms\``) embeds: [PingEmbed],
.setColor(supportbot.EmbedColour) });
},
message.channel.send({ });
embeds: [PingEmbed]
});
}
});
+341 -225
View File
@@ -4,242 +4,358 @@
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const Command = require("../Structures/Command.js"); const Command = require("../Structures/Command.js");
const TicketNumberID = require('../Structures/TicketID.js'); const TicketNumberID = require("../Structures/TicketID.js");
async function asyncForEach(array, callback) { async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) { for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array); await callback(array[index], index, array);
}
} }
}
module.exports = new Command({ module.exports = new Command({
name: cmdconfig.OpenTicket, name: cmdconfig.OpenTicket,
description: cmdconfig.OpenTicketDesc, description: cmdconfig.OpenTicketDesc,
type: "BOTH", slashCommandOptions: [
slashCommandOptions: [], {
permission: "SEND_MESSAGES", name: "reason",
description: "Ticket Reason",
type: "STRING",
},
],
permission: "SEND_MESSAGES",
async run(message, args, client) { async run(interaction) {
let reactionUser = interaction.guild.members.cache.get(interaction.user.id);
let reactionUser = message.guild.members.cache.get(message.author.id)
if (
if (reactionUser.roles.cache.find(role => role.name === supportbot.TicketBlackListRole) || reactionUser.roles.cache.find(role => role.id === supportbot.TicketBlackListRole)) { reactionUser.roles.cache.find(
return message.channel.send({content:`<@${message.author.id}> ${supportbot.TicketBlackListMessage}`}).then(msg => { (role) => role.name === supportbot.TicketBlackListRole
setTimeout(() => msg.delete(), 3500) ) ||
}) reactionUser.roles.cache.find(
} (role) => role.id === supportbot.TicketBlackListRole
)
// Ticket ID ) {
let ticketNumberID = TicketNumberID.pad(message.guild.id); return interaction
.reply({
// Ticket Subject content: `<@${interaction.user.id}> ${supportbot.TicketBlackListMessage}`,
const TicketSubject = args || supportbot.NoTicketSubject; })
.then((msg) => {
const TicketExists = new Discord.MessageEmbed() setTimeout(() => msg.delete(), 3500);
.setTitle("Ticket Exists!") });
.setDescription(`${supportbot.TicketExists}`) }
.setColor(supportbot.WarningColour)
// Ticket ID
if (message.guild.channels.cache.find(ticketChannel => ticketChannel.name === `${supportbot.TicketChannel}-${ticketNumberID}`)) { let ticketNumberID = TicketNumberID.pad(interaction.guild.id);
return message.channel.send({ embeds: [TicketExists] });
// Ticket Subject
const TicketSubject =
interaction.options?.getString("reason") || supportbot.NoTicketSubject;
const TicketExists = new Discord.MessageEmbed()
.setTitle("Ticket Exists!")
.setDescription(`${supportbot.TicketExists}`)
.setColor(supportbot.WarningColour);
if (
interaction.guild.channels.cache.find(
(ticketChannel) =>
ticketChannel.name === `${supportbot.TicketChannel}-${ticketNumberID}`
)
) {
return interaction.reply({ embeds: [TicketExists] });
}
const Staff =
interaction.guild.roles.cache.find(
(SupportTeam) => SupportTeam.name === supportbot.Staff
) ||
interaction.guild.roles.cache.find(
(SupportTeam) => SupportTeam.id === supportbot.Staff
);
const Admins =
interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.name === supportbot.Admin
) ||
interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.id === supportbot.Admin
);
const DeptRole1 =
interaction.guild.roles.cache.find(
(DepartmentRole) =>
DepartmentRole.name === `${supportbot.DepartmentRole_1}`
) ||
interaction.guild.roles.cache.find(
(DepartmentRole) =>
DepartmentRole.id === `${supportbot.DepartmentRole_1}`
);
const DeptRole2 =
interaction.guild.roles.cache.find(
(DepartmentRole) =>
DepartmentRole.name === `${supportbot.DepartmentRole_2}`
) ||
interaction.guild.roles.cache.find(
(DepartmentRole) =>
DepartmentRole.id === `${supportbot.DepartmentRole_2}`
);
const DeptRole3 =
interaction.guild.roles.cache.find(
(DepartmentRole) =>
DepartmentRole.name === `${supportbot.DepartmentRole_3}`
) ||
interaction.guild.roles.cache.find(
(DepartmentRole) =>
DepartmentRole.id === `${supportbot.DepartmentRole_3}`
);
const Author = interaction.user;
const Everyone = interaction.guild.id;
const ticketChannel = await interaction.guild.channels.create(
`${supportbot.TicketChannel}-${ticketNumberID}`,
{
type: "GUILD_TEXT",
}
);
if (
interaction.channel.name === supportbot.ReactionChannel ||
interaction.channel.id === supportbot.ReactionChannel
) {
const CreatedTicket = new Discord.MessageEmbed()
.setDescription(
supportbot.TicketCreatedAlert.replace(
/%ticketauthor%/g,
interaction.user.id
)
.replace(/%ticketid%/g, ticketChannel.id)
.replace(/%ticketusername%/g, interaction.user.username)
)
.setColor(supportbot.EmbedColour);
interaction.reply({ embeds: [CreatedTicket], ephemeral: true });
} else {
const CreatedTicket = new Discord.MessageEmbed()
.setDescription(
supportbot.TicketCreatedAlert.replace(
/%ticketauthor%/g,
interaction.user.id
)
.replace(/%ticketid%/g, ticketChannel.id)
.replace(/%ticketusername%/g, interaction.user.username)
)
.setColor(supportbot.EmbedColour);
interaction.reply({ embeds: [CreatedTicket], ephemeral: true });
}
let AllowArr = [Staff, Staff, Admins, Author];
await asyncForEach(AllowArr, (index) => {
ticketChannel.permissionOverwrites.create(index, { VIEW_CHANNEL: true });
});
let DenyArr = [Everyone];
await asyncForEach(DenyArr, (index) => {
ticketChannel.permissionOverwrites.create(index, { VIEW_CHANNEL: false });
});
let TicketCategory =
interaction.guild.channels.cache.find(
(category) => category.name === supportbot.TicketCategory
) ||
interaction.guild.channels.cache.find(
(category) => category.id === supportbot.TicketCategory
);
if (TicketCategory) {
ticketChannel.setParent(TicketCategory.id);
}
if (supportbot.AllowTicketMentions) {
ticketChannel.send({ content: `${interaction.user}` });
}
const TicketMessage = new Discord.MessageEmbed()
.setTitle(
supportbot.Ticket_Title.replace(/%ticketauthor%/g, interaction.user.id)
.replace(/%ticketid%/g, ticketChannel.id)
.replace(/%ticketusername%/g, interaction.user.username)
)
.setDescription(
supportbot.TicketMessage.replace(/%ticketauthor%/g, interaction.user.id)
.replace(/%ticketid%/g, ticketChannel.id)
.replace(/%ticketusername%/g, interaction.user.username)
)
.setColor(supportbot.EmbedColour);
if (supportbot.TicketSubject === "embed") {
if (TicketSubject != "No Reason Provided.") {
TicketMessage.addFields({ name: "Reason", value: TicketSubject });
}
}
if (supportbot.TicketSubject === "description") {
if (TicketSubject != "No Reason Provided.") {
ticketChannel.setTopic(
`Reason: ${TicketSubject} - User ID: ${interaction.user.id} - Ticket: ${ticketChannel.name}`
);
}
}
if (supportbot.TicketDepartments) {
TicketMessage.addFields({
name: "Departments",
value: ` **${supportbot.DepartmentTitle_1}**\n **${supportbot.DepartmentTitle_2}**\n **${supportbot.DepartmentTitle_3}**`,
});
}
const CloseButton = new Discord.MessageButton()
.setCustomId("ticketclose")
.setLabel("Close")
.setStyle(supportbot.TicketCloseColour)
.setEmoji(supportbot.TicketCloseEmoji);
const LockButton = new Discord.MessageButton()
.setCustomId("ticketlock")
.setLabel("Lock")
.setStyle(supportbot.TicketLockColour)
.setEmoji(supportbot.TicketLockEmoji);
const row2 = new Discord.MessageActionRow().addComponents(
CloseButton,
LockButton
);
if (supportbot.TicketDepartments) {
let DenyArr = [DeptRole1, DeptRole2, DeptRole3];
await asyncForEach(DenyArr, (index) => {
ticketChannel.permissionOverwrites.create(index, {
VIEW_CHANNEL: false,
});
});
const Department1Button = new Discord.MessageButton()
.setCustomId("Department1")
.setLabel(`${supportbot.DepartmentTitle_1}`)
.setStyle(supportbot.TicketDept1Colour)
.setEmoji(supportbot.TicketDept1Emoji);
const Department2Button = new Discord.MessageButton()
.setCustomId("Department2")
.setLabel(`${supportbot.DepartmentTitle_2}`)
.setStyle(supportbot.TicketDept2Colour)
.setEmoji(supportbot.TicketDept2Emoji);
const Department3Button = new Discord.MessageButton()
.setCustomId("Department3")
.setLabel(`${supportbot.DepartmentTitle_3}`)
.setStyle(supportbot.TicketDept3Colour)
.setEmoji(supportbot.TicketDept3Emoji);
const row = new Discord.MessageActionRow().addComponents(
Department1Button,
Department2Button,
Department3Button
);
const m = await ticketChannel.send({
embeds: [TicketMessage],
components: [row],
});
const filter = (i) => {
i.deferUpdate();
return i.user.id === interaction.user.id;
};
const collector = m.createMessageComponentCollector({
filter,
max: 1,
componentType: "BUTTON",
time: 60000,
});
collector.on("collect", async (i) => {
if (i.customId === "Department1") {
ticketChannel.permissionOverwrites.edit(DeptRole1, {
VIEW_CHANNEL: true,
READ_MESSAGE_HISTORY: true,
SEND_MESSAGES: true,
});
if (!supportbot.AllowStaff) {
ticketChannel.permissionOverwrites.edit(Staff, {
VIEW_CHANNEL: false,
READ_MESSAGE_HISTORY: false,
SEND_MESSAGES: false,
});
} }
const Staff = message.guild.roles.cache.find(SupportTeam => SupportTeam.name === supportbot.Staff) || message.guild.roles.cache.find(SupportTeam => SupportTeam.id === supportbot.Staff)
const Admins = message.guild.roles.cache.find(AdminUser => AdminUser.name === supportbot.Admin) || message.guild.roles.cache.find(AdminUser => AdminUser.id === supportbot.Admin) const Department1 = new Discord.MessageEmbed()
const DeptRole1 = message.guild.roles.cache.find(DepartmentRole => DepartmentRole.name === `${supportbot.DepartmentRole_1}`) || message.guild.roles.cache.find(DepartmentRole => DepartmentRole.id === `${supportbot.DepartmentRole_1}`) .setDescription(
const DeptRole2 = message.guild.roles.cache.find(DepartmentRole => DepartmentRole.name === `${supportbot.DepartmentRole_2}`) || message.guild.roles.cache.find(DepartmentRole => DepartmentRole.id === `${supportbot.DepartmentRole_2}`) `> Thank for reaching out to the **${supportbot.DepartmentTitle_1} Department**. Please provide us information regarding your query.`
const DeptRole3 = message.guild.roles.cache.find(DepartmentRole => DepartmentRole.name === `${supportbot.DepartmentRole_3}`) || message.guild.roles.cache.find(DepartmentRole => DepartmentRole.id === `${supportbot.DepartmentRole_3}`) )
const Author = message.author .setColor(supportbot.EmbedColour);
const Everyone = message.guild.id ticketChannel.send({ embeds: [Department1] });
const ticketChannel = await message.guild.channels.create(`${supportbot.TicketChannel}-${ticketNumberID}`, {
type: "GUILD_TEXT",
})
if (message.channel.name === supportbot.ReactionChannel || message.channel.id === supportbot.ReactionChannel) {
const CreatedTicket = new Discord.MessageEmbed()
.setDescription(supportbot.TicketCreatedAlert.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, ticketChannel.id).replace(/%ticketusername%/g, message.author.username))
.setColor(supportbot.EmbedColour)
message.channel.send({embeds: [CreatedTicket]}).then(msg => {
setTimeout(() => msg.delete(), 5000)
})
} else {
const CreatedTicket = new Discord.MessageEmbed()
.setDescription(supportbot.TicketCreatedAlert.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, ticketChannel.id).replace(/%ticketusername%/g, message.author.username))
.setColor(supportbot.EmbedColour)
message.channel.send({embeds: [CreatedTicket]}).then(msg => setTimeout(() => msg.delete(), 5000));
}
let AllowArr = [Staff, Staff, Admins, Author]
await asyncForEach(AllowArr, (index) => {
ticketChannel.permissionOverwrites.create(index, {VIEW_CHANNEL: true})
})
let DenyArr = [Everyone]
await asyncForEach(DenyArr, (index) => {
ticketChannel.permissionOverwrites.create(index, {VIEW_CHANNEL: false})
})
let TicketCategory = message.guild.channels.cache.find(category => category.name === supportbot.TicketCategory) || message.guild.channels.cache.find(category => category.id === supportbot.TicketCategory)
if(TicketCategory) {
ticketChannel.setParent(TicketCategory.id)
}
if (supportbot.AllowTicketMentions) { if (supportbot.AllowTicketMentions) {
ticketChannel.send({content:`${message.author}`}) ticketChannel.send({ content: `@here` });
} }
}
const TicketMessage = new Discord.MessageEmbed() i.message.edit({ embeds: [TicketMessage], components: [row2] });
.setTitle(supportbot.Ticket_Title.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, ticketChannel.id).replace(/%ticketusername%/g, message.author.username))
.setDescription(supportbot.TicketMessage.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, ticketChannel.id).replace(/%ticketusername%/g, message.author.username)) if (i.customId === "Department2") {
.setColor(supportbot.EmbedColour) ticketChannel.permissionOverwrites.edit(DeptRole2, {
VIEW_CHANNEL: true,
if (supportbot.TicketSubject === "embed") { READ_MESSAGE_HISTORY: true,
SEND_MESSAGES: true,
if (TicketSubject != 'No Reason Provided.') { });
TicketMessage.addFields({ name: 'Reason', value: TicketSubject })
} if (!supportbot.AllowStaff) {
ticketChannel.permissionOverwrites.edit(Staff, {
} VIEW_CHANNEL: false,
READ_MESSAGE_HISTORY: false,
if (supportbot.TicketSubject === "description") { SEND_MESSAGES: false,
});
if (TicketSubject != 'No Reason Provided.') {
ticketChannel.setTopic(`Reason: ${TicketSubject} - User ID: ${message.author.id} - Ticket: ${ticketChannel.name}`)
}
}
if (supportbot.TicketDepartments) {
TicketMessage.addFields({ name: 'Departments', value: ` **${supportbot.DepartmentTitle_1}**\n **${supportbot.DepartmentTitle_2}**\n **${supportbot.DepartmentTitle_3}**` })
}
const CloseButton = new Discord.MessageButton()
.setCustomId('ticketclose')
.setLabel('Close')
.setStyle(supportbot.TicketCloseColour)
.setEmoji(supportbot.TicketCloseEmoji)
const LockButton = new Discord.MessageButton()
.setCustomId('ticketlock')
.setLabel('Lock')
.setStyle(supportbot.TicketLockColour)
.setEmoji(supportbot.TicketLockEmoji)
const row2 = new Discord.MessageActionRow()
.addComponents(CloseButton, LockButton)
if(supportbot.TicketDepartments) {
let DenyArr = [DeptRole1, DeptRole2, DeptRole3]
await asyncForEach(DenyArr, (index) => {
ticketChannel.permissionOverwrites.create(index, {VIEW_CHANNEL: false})
})
const Department1Button = new Discord.MessageButton()
.setCustomId('Department1')
.setLabel(`${supportbot.DepartmentTitle_1}`)
.setStyle(supportbot.TicketDept1Colour)
.setEmoji(supportbot.TicketDept1Emoji)
const Department2Button = new Discord.MessageButton()
.setCustomId('Department2')
.setLabel(`${supportbot.DepartmentTitle_2}`)
.setStyle(supportbot.TicketDept2Colour)
.setEmoji(supportbot.TicketDept2Emoji)
const Department3Button = new Discord.MessageButton()
.setCustomId('Department3')
.setLabel(`${supportbot.DepartmentTitle_3}`)
.setStyle(supportbot.TicketDept3Colour)
.setEmoji(supportbot.TicketDept3Emoji)
const row = new Discord.MessageActionRow()
.addComponents(Department1Button, Department2Button, Department3Button)
const m = await ticketChannel.send({embeds: [TicketMessage], components: [row]})
const filter = i => {
i.deferUpdate();
return i.user.id === message.author.id;
};
const collector = m.createMessageComponentCollector({ filter, max: 1, componentType: 'BUTTON', time: 60000 });
collector.on('collect',async (i) => {
if(i.customId === 'Department1') {
ticketChannel.permissionOverwrites.edit(DeptRole1, {
VIEW_CHANNEL: true,
READ_MESSAGE_HISTORY: true,
SEND_MESSAGES: true,
})
if(!supportbot.AllowStaff) {
ticketChannel.permissionOverwrites.edit(Staff, { VIEW_CHANNEL: false, READ_MESSAGE_HISTORY: false, SEND_MESSAGES: false })
}
const Department1 = new Discord.MessageEmbed()
.setDescription(`> Thank for reaching out to the **${supportbot.DepartmentTitle_1} Department**. Please provide us information regarding your query.`)
.setColor(supportbot.EmbedColour)
ticketChannel.send({ embeds: [Department1] });
if (supportbot.AllowTicketMentions) {
ticketChannel.send({content: `@here`})
}
}
i.message.edit({embeds: [TicketMessage], components: [row2]})
if(i.customId === 'Department2') {
ticketChannel.permissionOverwrites.edit(DeptRole2, {
VIEW_CHANNEL: true,
READ_MESSAGE_HISTORY: true,
SEND_MESSAGES: true,
})
if(!supportbot.AllowStaff) {
ticketChannel.permissionOverwrites.edit(Staff, { VIEW_CHANNEL: false, READ_MESSAGE_HISTORY: false, SEND_MESSAGES: false })
}
const Department2 = new Discord.MessageEmbed()
.setDescription(`> Thank for reaching out to the **${supportbot.DepartmentTitle_2} Department**. Please provide us information regarding your query.`)
.setColor(supportbot.EmbedColour)
ticketChannel.send({ embeds: [Department2] });
if (supportbot.AllowTicketMentions) {
ticketChannel.send({content: `@here`})
}
i.message.edit({embeds: [TicketMessage], components: [row2]})
}
if(i.customId === 'Department3') {
ticketChannel.permissionOverwrites.edit(DeptRole3, {
VIEW_CHANNEL: true,
READ_MESSAGE_HISTORY: true,
SEND_MESSAGES: true,
})
if(!supportbot.AllowStaff) {
ticketChannel.permissionOverwrites.edit(Staff, { VIEW_CHANNEL: false, READ_MESSAGE_HISTORY: false, SEND_MESSAGES: false })
}
const Department3 = new Discord.MessageEmbed()
.setDescription(`> Thank for reaching out to the **${supportbot.DepartmentTitle_3} Department**. Please provide us information regarding your query.`)
.setColor(supportbot.EmbedColour)
ticketChannel.send({ embeds: [Department3] });
if (supportbot.AllowTicketMentions) {
ticketChannel.send({content: `@here`})
}
i.message.edit({embeds: [TicketMessage], components: [row2]})
}
})
} else {
ticketChannel.send({embeds: [TicketMessage], components: [row2]})
} }
} const Department2 = new Discord.MessageEmbed()
.setDescription(
`> Thank for reaching out to the **${supportbot.DepartmentTitle_2} Department**. Please provide us information regarding your query.`
)
.setColor(supportbot.EmbedColour);
ticketChannel.send({ embeds: [Department2] });
if (supportbot.AllowTicketMentions) {
ticketChannel.send({ content: `@here` });
}
i.message.edit({ embeds: [TicketMessage], components: [row2] });
}
if (i.customId === "Department3") {
ticketChannel.permissionOverwrites.edit(DeptRole3, {
VIEW_CHANNEL: true,
READ_MESSAGE_HISTORY: true,
SEND_MESSAGES: true,
});
if (!supportbot.AllowStaff) {
ticketChannel.permissionOverwrites.edit(Staff, {
VIEW_CHANNEL: false,
READ_MESSAGE_HISTORY: false,
SEND_MESSAGES: false,
});
}
const Department3 = new Discord.MessageEmbed()
.setDescription(
`> Thank for reaching out to the **${supportbot.DepartmentTitle_3} Department**. Please provide us information regarding your query.`
)
.setColor(supportbot.EmbedColour);
ticketChannel.send({ embeds: [Department3] });
if (supportbot.AllowTicketMentions) {
ticketChannel.send({ content: `@here` });
}
i.message.edit({ embeds: [TicketMessage], components: [row2] });
}
});
} else {
ticketChannel.send({ embeds: [TicketMessage], components: [row2] });
}
},
}); });
+157 -143
View File
@@ -4,163 +4,177 @@
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const cmdconfig = yaml.load(fs.readFileSync('./Data/commands.yml', 'utf8')); const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8"));
const Event = require("../Structures/Event.js"); const Event = require("../Structures/Event.js");
module.exports = new Event("interactionCreate", (client, interaction) => { module.exports = new Event("interactionCreate", (client, interaction) => {
if (interaction.isCommand()) {
if (interaction.isCommand()) return; const command = client.commands.find(
(cmd) => cmd.name.toLowerCase() == interaction.commandName
const command = client.commands.find(cmd => cmd.name.toLowerCase() == interaction.commandName); );
if (interaction.user.bot || !interaction.isCommand() || !interaction.guild) if (interaction.user.bot || !interaction.isCommand() || !interaction.guild)
return; return;
const args = [
interaction.commandName,
...client.commands
.find(cmd => cmd.name.toLowerCase() == interaction.commandName)
.slashCommandOptions.map(v => `${interaction.options.get(v.name).value}`)
];
const NotValid = new Discord.MessageEmbed() const NotValid = new Discord.MessageEmbed()
.setDescription(`:x: \`Invalid Command\` `) .setDescription(`:x: \`Invalid Command\` `)
.setColor(supportbot.ErrorColour) .setColor(supportbot.ErrorColour);
if (!command) return interaction.reply({ if (!command)
embeds: [NotValid] return interaction.reply({
}); embeds: [NotValid],
});
const permission = interaction.member.permissions.has(command.permission); const permission = interaction.member.permissions.has(command.permission);
const ValidPerms = new Discord.MessageEmbed() const ValidPerms = new Discord.MessageEmbed()
.setDescription(":x: \`Invalid Permissions\` Do you have the correct permissions to execute this command?") .setDescription(
.setColor(supportbot.ErrorColour) ":x: `Invalid Permissions` Do you have the correct permissions to execute this command?"
)
.setColor(supportbot.ErrorColour);
if (!permission) if (!permission)
return interaction.reply({ return interaction.reply({
embeds: [ValidPerms] embeds: [ValidPerms],
}); });
interaction.user = interaction.user;
command.run(interaction, args, client); command.run(interaction);
}
if(interaction.isButton()) { if (interaction.isButton()) {
if(interaction.customId === 'openticket') { if (interaction.customId === "openticket") {
interaction.message.fetch() try {
interaction.deferUpdate() const cmd = client.commands.get(cmdconfig.OpenTicket);
let message = { if (!cmd) return;
guild: client.guilds.cache.get(interaction.message.guildId), cmd.run(interaction);
author: client.users.cache.get(interaction.user.id), } catch (error) {
content: "N/A", console.error(error);
channel: client.channels.cache.get(interaction.message.channelId) }
}
try {
const cmd = client.commands.get(cmdconfig.OpenTicket);
if(!cmd) return;
cmd.run(message, message.content)
}
catch (error){
console.error(error)
}
}
if(interaction.customId === 'ticketclose') {
if(interaction.channel.name.startsWith(`${supportbot.TicketChannel}-`)) {
interaction.message.fetch()
interaction.deferUpdate()
const DeleteTicketEmbed = new Discord.MessageEmbed()
.setDescription(supportbot.TicketDeleteMessage)
.setColor(supportbot.EmbedColour)
interaction.channel.send({embeds: [DeleteTicketEmbed]})
let logChannel = interaction.guild.channels.cache.find(channel => channel.name === supportbot.TranscriptLog) || interaction.guild.channels.cache.find(channel => channel.id === supportbot.TranscriptLog)
let user = interaction.user
let name = interaction.channel.name;
let ticketChannel = interaction.channel
let reason = "No Reason Provided."
interaction.channel.send({content: `**${supportbot.ClosingTicket}**`})
.then(() => {
const logEmbed = new Discord.MessageEmbed()
.setTitle(supportbot.TranscriptTitle)
.setColor(supportbot.EmbedColour)
.setFooter(supportbot.EmbedFooter)
.addField("Closed By", user.username)
.addField("Reason", reason)
interaction.channel.messages.fetch({limit: 100}).then(msgs => {
let html = ''
msgs = msgs.sort( ( a, b ) => a.createdTimestamp - b.createdTimestamp );
html += `<strong>Server Name:</strong> ${interaction.guild.name}<br>`
html += `<strong>Ticket:</strong> ${ticketChannel.name}<br>`
html += `<strong>Message:</strong> ${msgs.size} Messages<br><br><br>`
msgs.forEach(msg => {
if(msg.content) {
html += `<strong>User:</strong> ${msg.author.tag}<br>`;
html += `<strong>Message:</strong> ${msg.content}<br>`;
html += `-----<br><br>`;
}
})
const TranscriptSavedEmbed = new Discord.MessageEmbed()
.setDescription(supportbot.TranscriptSavedMessage)
.setColor(supportbot.SuccessColour)
interaction.channel.send({embeds: [TranscriptSavedEmbed]})
let file = new Discord.MessageAttachment( Buffer.from( html ), `${name}.html` )
logChannel.send({embeds: [logEmbed], files: [file]})
setTimeout(() => interaction.channel.delete(), supportbot.TicketDeleteTime)
})
})
}
}
if(interaction.customId === 'ticketlock') {
if(interaction.channel.name.startsWith(`${supportbot.TicketChannel}`)) {
interaction.message.fetch()
interaction.deferUpdate()
let Admin = interaction.guild.roles.cache.find(AdminUser => AdminUser.name === supportbot.Admin) || interaction.guild.roles.cache.find(AdminUser => AdminUser.id === supportbot.Admin)
let all = interaction.channel.permissionOverwrites.cache
let parent = interaction.guild.channels.cache.find(c => c.name === `${supportbot.LockTicketCategory}`) || interaction.guild.channels.cache.find(c => c.id === `${supportbot.LockTicketCategory}`)
if(parent) {
interaction.channel.setParent(parent.id)
}
all.forEach(perm => {
interaction.channel.permissionOverwrites.delete(perm.id)
})
interaction.channel.permissionOverwrites.create(Admin.id, {VIEW_CHANNEL: true})
interaction.channel.permissionOverwrites.create(interaction.guild.id, {VIEW_CHANNEL: false})
const ticketDeleteButton = new Discord.MessageButton()
.setCustomId('ticketclose')
.setLabel('Close')
.setStyle(supportbot.TicketDeleteColour)
.setEmoji(supportbot.TicketDeleteEmoji)
const row = new Discord.MessageActionRow()
.addComponents(ticketDeleteButton)
const ArchiveEmbed = new Discord.MessageEmbed()
.setTitle("Archived")
.setDescription(`Archived ${interaction.channel.name}`)
.setColor(`${supportbot.SuccessColour}`)
interaction.channel.send({embeds: [ArchiveEmbed]})
interaction.message.edit({components: [row]})
}
}
} }
}); if (interaction.customId === "ticketclose") {
if (interaction.channel.name.startsWith(`${supportbot.TicketChannel}-`)) {
interaction.message.fetch();
interaction.deferUpdate();
const DeleteTicketEmbed = new Discord.MessageEmbed()
.setDescription(supportbot.TicketDeleteMessage)
.setColor(supportbot.EmbedColour);
interaction.channel.send({ embeds: [DeleteTicketEmbed] });
let logChannel =
interaction.guild.channels.cache.find(
(channel) => channel.name === supportbot.TranscriptLog
) ||
interaction.guild.channels.cache.find(
(channel) => channel.id === supportbot.TranscriptLog
);
let user = interaction.user;
let name = interaction.channel.name;
let ticketChannel = interaction.channel;
let reason = "No Reason Provided.";
interaction.channel
.send({ content: `**${supportbot.ClosingTicket}**` })
.then(() => {
const logEmbed = new Discord.MessageEmbed()
.setTitle(supportbot.TranscriptTitle)
.setColor(supportbot.EmbedColour)
.setFooter(supportbot.EmbedFooter)
.addField("Closed By", user.username)
.addField("Reason", reason);
interaction.channel.messages.fetch({ limit: 100 }).then((msgs) => {
let html = "";
msgs = msgs.sort(
(a, b) => a.createdTimestamp - b.createdTimestamp
);
html += `<strong>Server Name:</strong> ${interaction.guild.name}<br>`;
html += `<strong>Ticket:</strong> ${ticketChannel.name}<br>`;
html += `<strong>Message:</strong> ${msgs.size} Messages<br><br><br>`;
msgs.forEach((msg) => {
if (msg.content) {
html += `<strong>User:</strong> ${msg.author.tag}<br>`;
html += `<strong>Message:</strong> ${msg.content}<br>`;
html += `-----<br><br>`;
}
});
const TranscriptSavedEmbed = new Discord.MessageEmbed()
.setDescription(supportbot.TranscriptSavedMessage)
.setColor(supportbot.SuccessColour);
interaction.channel.send({ embeds: [TranscriptSavedEmbed] });
let file = new Discord.MessageAttachment(
Buffer.from(html),
`${name}.html`
);
logChannel.send({ embeds: [logEmbed], files: [file] });
setTimeout(
() => interaction.channel.delete(),
supportbot.TicketDeleteTime
);
});
});
}
}
if (interaction.customId === "ticketlock") {
if (interaction.channel.name.startsWith(`${supportbot.TicketChannel}`)) {
interaction.message.fetch();
interaction.deferUpdate();
let Admin =
interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.name === supportbot.Admin
) ||
interaction.guild.roles.cache.find(
(AdminUser) => AdminUser.id === supportbot.Admin
);
let all = interaction.channel.permissionOverwrites.cache;
let parent =
interaction.guild.channels.cache.find(
(c) => c.name === `${supportbot.LockTicketCategory}`
) ||
interaction.guild.channels.cache.find(
(c) => c.id === `${supportbot.LockTicketCategory}`
);
if (parent) {
interaction.channel.setParent(parent.id);
}
all.forEach((perm) => {
interaction.channel.permissionOverwrites.delete(perm.id);
});
interaction.channel.permissionOverwrites.create(Admin.id, {
VIEW_CHANNEL: true,
});
interaction.channel.permissionOverwrites.create(interaction.guild.id, {
VIEW_CHANNEL: false,
});
const ticketDeleteButton = new Discord.MessageButton()
.setCustomId("ticketclose")
.setLabel("Close")
.setStyle(supportbot.TicketDeleteColour)
.setEmoji(supportbot.TicketDeleteEmoji);
const row = new Discord.MessageActionRow().addComponents(
ticketDeleteButton
);
const ArchiveEmbed = new Discord.MessageEmbed()
.setTitle("Archived")
.setDescription(`Archived ${interaction.channel.name}`)
.setColor(`${supportbot.SuccessColour}`);
interaction.channel.send({ embeds: [ArchiveEmbed] });
interaction.message.edit({ components: [row] });
}
}
}
});
-50
View File
@@ -1,50 +0,0 @@
// SupportBot | Emerald Services
// Message Create Event
const fs = require("fs");
const Discord = require("discord.js");
const yaml = require('js-yaml');
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8'));
const Event = require("../Structures/Event.js");
module.exports = new Event("messageCreate", (client, message) => {
if (message.author.bot) return;
if (!message.content.startsWith(client.prefix)) return;
const args = message.content.substring(client.prefix.length).split(/ +/);
const command = client.commands.find(cmd => cmd.name == args[0]);
const NotValid = new Discord.MessageEmbed()
.setDescription(`:x: \`${args[0]}\` is an Invalid Command `)
.setColor(supportbot.ErrorColour)
if (!command) return message.reply({
embeds: [NotValid]
});
const OnlySlashCmd = new Discord.MessageEmbed()
.setDescription(`:warning: That command is only useable as a \`Slash Command\` `)
.setColor(supportbot.WarnColour)
if (!["BOTH", "TEXT"].includes(command.type))
return message.reply({
embeds: [OnlySlashCmd]
})
const permission = message.member.permissions.has(command.permission, true);
const ValidPerms = new Discord.MessageEmbed()
.setDescription(":x: Do you have the \`${command.permission}\` permissions to execute this command?")
.setColor(supportbot.ErrorColour)
if (!permission)
return message.reply(
`You do not have the permission \`${command.permission}\` to run this command!`
);
command.run(message, args, client);
});
+112 -79
View File
@@ -4,90 +4,123 @@
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const panelconfig = yaml.load(fs.readFileSync('./Data/ticket-panel.yml', 'utf8')); const panelconfig = yaml.load(
fs.readFileSync("./Data/ticket-panel.yml", "utf8")
);
const Event = require("../Structures/Event.js"); const Event = require("../Structures/Event.js");
module.exports = new Event("ready", client => { module.exports = new Event("ready", (client) => {
client.user.setActivity(supportbot.BotActivity, { client.user.setActivity(supportbot.BotActivity, {
type: supportbot.ActivityType, type: supportbot.ActivityType,
url: supportbot.StreamingURL url: supportbot.StreamingURL,
}); });
console.log(`\u001b[32m`, `┏━━━┓╋╋╋╋╋╋╋╋╋╋╋╋╋┏┓┏━━┓╋╋╋┏┓`) console.log(`\u001b[32m`, `┏━━━┓╋╋╋╋╋╋╋╋╋╋╋╋╋┏┓┏━━┓╋╋╋┏┓`);
console.log(`\u001b[32m`, `┃┏━┓┃╋╋╋╋╋╋╋╋╋╋╋╋┏┛┗┫┏┓┃╋╋┏┛┗┓`) console.log(`\u001b[32m`, `┃┏━┓┃╋╋╋╋╋╋╋╋╋╋╋╋┏┛┗┫┏┓┃╋╋┏┛┗┓`);
console.log(`\u001b[32m`, `┃┗━━┳┓┏┳━━┳━━┳━━┳┻┓┏┫┗┛┗┳━┻┓┏┛`) console.log(`\u001b[32m`, `┃┗━━┳┓┏┳━━┳━━┳━━┳┻┓┏┫┗┛┗┳━┻┓┏┛`);
console.log(`\u001b[32m`, `┗━━┓┃┃┃┃┏┓┃┏┓┃┏┓┃┏┫┃┃┏━┓┃┏┓┃┃`) console.log(`\u001b[32m`, `┗━━┓┃┃┃┃┏┓┃┏┓┃┏┓┃┏┫┃┃┏━┓┃┏┓┃┃`);
console.log(`\u001b[32m`, `┃┗━┛┃┗┛┃┗┛┃┗┛┃┗┛┃┃┃┗┫┗━┛┃┗┛┃┗┓`) console.log(`\u001b[32m`, `┃┗━┛┃┗┛┃┗┛┃┗┛┃┗┛┃┃┃┗┫┗━┛┃┗┛┃┗┓`);
console.log(`\u001b[32m`, `┗━━━┻━━┫┏━┫┏━┻━━┻┛┗━┻━━━┻━━┻━┛`) console.log(`\u001b[32m`, `┗━━━┻━━┫┏━┫┏━┻━━┻┛┗━┻━━━┻━━┻━┛`);
console.log(`\u001b[32m`, `┗╋╋╋╋╋╋╋┃┃╋┃┃`) console.log(`\u001b[32m`, `┗╋╋╋╋╋╋╋┃┃╋┃┃`);
console.log(`\u001b[32m`, `╋╋╋╋╋╋╋┗┛╋┗┛`) console.log(`\u001b[32m`, `╋╋╋╋╋╋╋┗┛╋┗┛`);
console.log(` `) console.log(` `);
console.log(`\u001b[31m`, `――――――――――――――――――――――――――――――――――――――――――――`) console.log(`\u001b[31m`, `――――――――――――――――――――――――――――――――――――――――――――`);
console.log(` `) console.log(` `);
console.log(`\u001b[33m`, `${supportbot.Name} v${supportbot.SupportBot_Version}`, `\u001b[36m`, `Connected to Discord`) console.log(
console.log(`\u001b[33m`, `Resources:`, `\u001b[36m`, `https://emeraldsrv.dev/resources`) `\u001b[33m`,
console.log(`\u001b[33m`, `Documentation:`, `\u001b[36m`, `https://supportbot.emeraldsrv.dev`) `${supportbot.Name} v${supportbot.SupportBot_Version}`,
console.log(`\u001b[33m`, `Discord:`, `\u001b[36m`, `https://emeraldsrv.dev/discord`) `\u001b[36m`,
console.log(`\u001b[33m`, `Hosting:`, `\u001b[36m`, `https://emeraldsrv.dev/hosting`) `Connected to Discord`
console.log(` `) );
console.log(`\u001b[37m`, `SupportBot proudly created by Emerald Services`) console.log(
console.log(` `) `\u001b[33m`,
console.log(`\u001b[31m`, `――――――――――――――――――――――――――――――――――――――――――――`) `Resources:`,
`\u001b[36m`,
`https://emeraldsrv.dev/resources`
);
console.log(
`\u001b[33m`,
`Documentation:`,
`\u001b[36m`,
`https://supportbot.emeraldsrv.dev`
);
console.log(
`\u001b[33m`,
`Discord:`,
`\u001b[36m`,
`https://emeraldsrv.dev/discord`
);
console.log(
`\u001b[33m`,
`Hosting:`,
`\u001b[36m`,
`https://emeraldsrv.dev/hosting`
);
console.log(` `);
console.log(`\u001b[37m`, `SupportBot proudly created by Emerald Services`);
console.log(` `);
console.log(`\u001b[31m`, `――――――――――――――――――――――――――――――――――――――――――――`);
if (panelconfig.TicketPanel) { if (panelconfig.TicketPanel) {
let chan1 = client.channels.cache.find(channel => channel.name === panelconfig.Channel) let chan1 = client.channels.cache.find(
(channel) => channel.name === panelconfig.Channel
);
if (!chan1) { if (!chan1) {
console.log('\u001b[33m', "[WARN] Ticket reaction panel is not setup, You can do so via the configuration file!") console.log(
return false; "\u001b[33m",
} "[WARN] Ticket reaction panel is not setup, You can do so via the configuration file!"
);
const panelid = yaml.load(fs.readFileSync('./Data/ticket-panel-id.yml', 'utf8')); return false;
chan1.messages.fetch(panelid.TicketPanelID).catch(async r => {
let embed = new Discord.MessageEmbed()
.setTitle(`${panelconfig.PanelTitle}`)
.setColor(supportbot.SuccessColour)
.setFooter(supportbot.EmbedFooter);
if (panelconfig.TicketPanel_Description) {
embed.setDescription(panelconfig.PanelMessage)
}
if (panelconfig.TicketPanel_Thumbnail) {
embed.setThumbnail(panelconfig.PanelThumbnail)
}
if (panelconfig.TicketPanel_Image) {
embed.setImage(panelconfig.PanelImage)
}
let button = new Discord.MessageButton()
.setLabel(panelconfig.ButtonLabel)
.setCustomId('openticket')
.setStyle(panelconfig.ButtonColour)
let row = new Discord.MessageActionRow()
.addComponents(button)
await chan1.send({
embeds: [embed],
components: [row]
}).then(r => {
let data = {
"TicketPanelID": `${r.id}`
}
let yamlStr = yaml.dump(data);
fs.writeFileSync('./Data/ticket-panel-id.yml', yamlStr, 'utf8');
}).catch(e => {
console.log("Raw"+e)
})
})
} }
}); const panelid = yaml.load(
fs.readFileSync("./Data/ticket-panel-id.yml", "utf8")
);
chan1.messages.fetch(panelid.TicketPanelID).catch(async (r) => {
let embed = new Discord.MessageEmbed()
.setTitle(`${panelconfig.PanelTitle}`)
.setColor(supportbot.SuccessColour)
.setFooter(supportbot.EmbedFooter);
if (panelconfig.TicketPanel_Description) {
embed.setDescription(panelconfig.PanelMessage);
}
if (panelconfig.TicketPanel_Thumbnail) {
embed.setThumbnail(panelconfig.PanelThumbnail);
}
if (panelconfig.TicketPanel_Image) {
embed.setImage(panelconfig.PanelImage);
}
let button = new Discord.MessageButton()
.setLabel(panelconfig.ButtonLabel)
.setCustomId("openticket")
.setStyle(panelconfig.ButtonColour);
let row = new Discord.MessageActionRow().addComponents(button);
await chan1
.send({
embeds: [embed],
components: [row],
})
.then((r) => {
let data = {
TicketPanelID: `${r.id}`,
};
let yamlStr = yaml.dump(data);
fs.writeFileSync("./Data/ticket-panel-id.yml", yamlStr, "utf8");
})
.catch((e) => {
console.log("Raw" + e);
});
});
}
});
+7 -9
View File
@@ -1,8 +1,8 @@
// ___ _ ___ _ // ___ _ ___ _
// / __> _ _ ___ ___ ___ _ _ _| |_ | . > ___ _| |_ // / __> _ _ ___ ___ ___ _ _ _| |_ | . > ___ _| |_
// \__ \| | || . \| . \/ . \| '_> | | | . \/ . \ | | // \__ \| | || . \| . \/ . \| '_> | | | . \/ . \ | |
// <___/`___|| _/| _/\___/|_| |_| |___/\___/ |_| // <___/`___|| _/| _/\___/|_| |_| |___/\___/ |_|
// |_| |_| // |_| |_|
// //
// SupportBot created by Emerald Services // SupportBot created by Emerald Services
// Installed with MIT License // Installed with MIT License
@@ -13,12 +13,10 @@
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js"); const Discord = require("discord.js");
const yaml = require('js-yaml'); const yaml = require("js-yaml");
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8')); const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
const Client = require("./Structures/Client.js"); const Client = require("./Structures/Client.js");
const client = new Client({}); const client = new Client({});
client.start(supportbot.Token); client.start(supportbot.Token);
+7 -7
View File
@@ -1,21 +1,21 @@
{ {
"name": "supportbot", "name": "supportbot",
"version": "7.2.0", "version": "7.2.0",
"description": "an advanced discord ticket bot", "description": "SupportBot is an open-sourced support system for discord. It's completely free to use with high amounts of customization to match your own brand.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "start": "npm i && node index.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/1tzemerald/GlennBot.git" "url": "git+https://github.com/1tzemerald/SupportBot.git"
}, },
"author": "", "author": "Emerald Services",
"license": "ISC", "license": "MIT",
"bugs": { "bugs": {
"url": "https://github.com/1tzemerald/GlennBot/issues" "url": "https://github.com/1tzemerald/SupportBot/issues"
}, },
"homepage": "https://github.com/1tzemerald/GlennBot#readme", "homepage": "https://github.com/1tzemerald/SupportBot#readme",
"dependencies": { "dependencies": {
"discord.js": "^13.2.0", "discord.js": "^13.2.0",
"js-yaml": "^4.1.0" "js-yaml": "^4.1.0"