Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions commands/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,15 @@ module.exports = {
data: new SlashCommandBuilder()
.setName("add")
.setDescription("Add someone to the ticket")
.addUserOption((input) =>
input.setName("user").setDescription("The user to add").setRequired(true)
),
.addUserOption((input) => input.setName("user").setDescription("The user to add").setRequired(true)),
async execute(interaction, client) {
const added = interaction.options.getUser("user");
const ticket = await client.db.get(`tickets_${interaction.channel.id}`);
if (!ticket)
return interaction
.reply({ content: "Ticket not found", ephemeral: true })
.catch((e) => console.log(e));
if (ticket.invited.includes(added.id))
return interaction
.reply({ content: "User already added", ephemeral: true })
.catch((e) => console.log(e));
if (!ticket) return interaction.reply({ content: "Ticket not found", ephemeral: true }).catch((e) => console.log(e));
if (ticket.invited.includes(added.id)) return interaction.reply({ content: "User already added", ephemeral: true }).catch((e) => console.log(e));

if (ticket.invited.lenght >= 25)
return interaction
.reply({ content: "You can't add more than 25 users", ephemeral: true })
.catch((e) => console.log(e));
return interaction.reply({ content: "You can't add more than 25 users", ephemeral: true }).catch((e) => console.log(e));

client.db.push(`tickets_${interaction.channel.id}.invited`, added.id);

Expand All @@ -52,9 +42,7 @@ module.exports = {
})
.catch((e) => console.log(e));

interaction
.reply({ content: `> Added <@${added.id}> to the ticket` })
.catch((e) => console.log(e));
interaction.reply({ content: `> Added <@${added.id}> to the ticket` }).catch((e) => console.log(e));

client.log(
"userAdded",
Expand Down
4 changes: 1 addition & 3 deletions commands/claim.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ limitations under the License.
*/

module.exports = {
data: new SlashCommandBuilder()
.setName("claim")
.setDescription("Set the ticket as claimed."),
data: new SlashCommandBuilder().setName("claim").setDescription("Set the ticket as claimed."),
async execute(interaction, client) {
const { claim } = require("../utils/claim.js");
claim(interaction, client);
Expand Down
8 changes: 2 additions & 6 deletions commands/close.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@ limitations under the License.
*/

module.exports = {
data: new SlashCommandBuilder()
.setName("close")
.setDescription("Close the ticket"),
data: new SlashCommandBuilder().setName("close").setDescription("Close the ticket"),
async execute(interaction, client) {
if (
client.config.whoCanCloseTicket === "STAFFONLY" &&
!interaction.member.roles.cache.some((r) =>
client.config.rolesWhoHaveAccessToTheTickets.includes(r.id)
)
!interaction.member.roles.cache.some((r) => client.config.rolesWhoHaveAccessToTheTickets.includes(r.id))
)
return interaction
.reply({
Expand Down
24 changes: 5 additions & 19 deletions commands/remove.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
const {
SlashCommandBuilder,
ActionRowBuilder,
StringSelectMenuBuilder,
} = require("discord.js");
const { SlashCommandBuilder, ActionRowBuilder, StringSelectMenuBuilder } = require("discord.js");

/*
Copyright 2023 Sayrix (github.com/Sayrix)
Expand All @@ -21,27 +17,17 @@ limitations under the License.
*/

module.exports = {
data: new SlashCommandBuilder()
.setName("remove")
.setDescription("Remove someone from the ticket"),
data: new SlashCommandBuilder().setName("remove").setDescription("Remove someone from the ticket"),
async execute(interaction, client) {
const ticket = await client.db.get(`tickets_${interaction.channel.id}`);
if (!ticket)
return interaction
.reply({ content: "Ticket not found", ephemeral: true })
.catch((e) => console.log(e));
if (ticket.invited.length < 1)
return interaction
.reply({ content: "There are no users to remove", ephemeral: true })
.catch((e) => console.log(e));
if (!ticket) return interaction.reply({ content: "Ticket not found", ephemeral: true }).catch((e) => console.log(e));
if (ticket.invited.length < 1) return interaction.reply({ content: "There are no users to remove", ephemeral: true }).catch((e) => console.log(e));

for (let i = 0; i < ticket.invited.length; i++) {
await client.users.fetch(ticket.invited[i]);
}

const addedUsers = ticket.invited.map((user) =>
client.users.cache.get(user)
);
const addedUsers = ticket.invited.map((user) => client.users.cache.get(user));

const row = new ActionRowBuilder().addComponents(
new StringSelectMenuBuilder()
Expand Down
18 changes: 6 additions & 12 deletions config/config.example.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"closeTicketCategoryId": "", // The id of the category where a closed ticket will be moved to. Leave blank to disable this feature

"openTicketChannelId": "1111111111111111111", // The id of the channel where the message to create a ticket will be sent

"ticketTypes": [ // You have a limit of 25 types (the limit of Discord)

"ticketTypes": [
// You have a limit of 25 types (the limit of Discord)
{
"codeName": "category-one", // The name need to be in lowercase
"name": "Category One", // The name that will be displayed in the ticket
Expand All @@ -27,9 +28,7 @@
"categoryId": "1111111111111111111", // The category id where the tickets will be created
"ticketNameOption": "💡-TICKETCOUNT", // Here is all parameter: USERNAME, USERID, TICKETCOUNT (set to blank to use the default name)
"customDescription": "", // The custom description of the ticket type, here is all parameter: USERNAME, USERID, TICKETCOUNT, REASON1, 2, ect (set to blank to use the default description)
"cantAccess": [
"1111111111111111111"
], // The roles who can't access to this ticket type
"cantAccess": ["1111111111111111111"], // The roles who can't access to this ticket type
"askQuestions": false, // If the bot should ask the reason of the ticket
"questions": [] // Leave blank if you don't want to ask questions
},
Expand All @@ -42,9 +41,7 @@
"categoryId": "1111111111111111111", // The category id where the tickets will be created
"ticketNameOption": "", // Here is all parameter: USERNAME, USERID, TICKETCOUNT (set to blank to use the default name)
"customDescription": "Please explain your report in detail. If you have any images, please attach them to your message.", // The custom description of the ticket type, here is all parameter: USERNAME, USERID, TICKETCOUNT, REASON1, 2, ect (set to blank to use the default description)
"cantAccess": [
"2222222222222222222"
], // The roles who can't access to this ticket type
"cantAccess": ["2222222222222222222"], // The roles who can't access to this ticket type
"askQuestions": false, // If the bot should ask the reason of the ticket
"questions": [] // Leave blank if you don't want to ask questions
},
Expand All @@ -71,10 +68,7 @@
],
"ticketNameOption": "Ticket-TICKETCOUNT", // Here is all parameter: USERNAME, USERID, TICKETCOUNT

"rolesWhoHaveAccessToTheTickets": [
"1111111111111111111",
"2222222222222222222"
], // Roles who can access to the tickets
"rolesWhoHaveAccessToTheTickets": ["1111111111111111111", "2222222222222222222"], // Roles who can access to the tickets

"rolesWhoCanNotCreateTickets": [], // Roles who can not create a tickets (Like a blacklist)

Expand Down
2 changes: 1 addition & 1 deletion config/token.example.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"token": "my.discord.bot.token"
}
}
8 changes: 2 additions & 6 deletions deploy-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ const { token } = require("./config/token.json");

const commands = [];
const commandsPath = path.join(__dirname, "commands");
const commandFiles = fs
.readdirSync(commandsPath)
.filter((file) => file.endsWith(".js"));
const commandFiles = fs.readdirSync(commandsPath).filter((file) => file.endsWith(".js"));

const { clientId, guildId } = jsonc.parse(
fs.readFileSync(path.join(__dirname, "config/config.jsonc"), "utf8")
);
const { clientId, guildId } = jsonc.parse(fs.readFileSync(path.join(__dirname, "config/config.jsonc"), "utf8"));

for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
Expand Down
Loading