From 75fae620bddef6d19c6d32005362503bfddac874 Mon Sep 17 00:00:00 2001 From: zhiyan114 Date: Sat, 11 May 2024 13:03:28 -0400 Subject: [PATCH] Fix discordjs latest breaking changes --- package.json | 4 +- src/commands/add.ts | 162 ++++++++++++++++++++++---------------------- 2 files changed, 83 insertions(+), 83 deletions(-) diff --git a/package.json b/package.json index 74fbb1d1..79e15f74 100644 --- a/package.json +++ b/package.json @@ -46,8 +46,8 @@ "@types/node": "^20.8.6", "@types/pg": "^8.10.7", "@types/websocket": "^1.0.8", - "@typescript-eslint/eslint-plugin": "^6.8.0", - "@typescript-eslint/parser": "^6.8.0", + "@typescript-eslint/eslint-plugin": "^7.8.0", + "@typescript-eslint/parser": "^7.8.0", "eslint": "^8.51.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-prettier": "^9.0.0", diff --git a/src/commands/add.ts b/src/commands/add.ts index 5ac8f2b4..13100f0f 100644 --- a/src/commands/add.ts +++ b/src/commands/add.ts @@ -1,81 +1,81 @@ -import {BaseCommand, ExtendedClient} from "../structure"; -import {CommandInteraction, SlashCommandBuilder, TextChannel} from "discord.js"; -import {log} from "../utils/logs"; - -/* -Copyright 2023 Sayrix (github.com/Sayrix) - -Licensed under the Creative Commons Attribution 4.0 International -please check https://creativecommons.org/licenses/by/4.0 for more informations. -*/ - -export default class AddCommand extends BaseCommand { - public static data: SlashCommandBuilder = new SlashCommandBuilder() - .setName("add") - .setDescription("Add someone to the ticket") - .addUserOption((input) => input.setName("user").setDescription("The user to add").setRequired(true)); - constructor(client: ExtendedClient) { - super(client); - } - - async execute(interaction: CommandInteraction) { - - const added = interaction.options.getUser("user", true); - const ticket = await this.client.prisma.tickets.findUnique({ - select: { - id: true, - invited: true, - }, - where: { - channelid: interaction.channel?.id - } - }); - - if (!ticket) return interaction.reply({ content: "Ticket not found", ephemeral: true }).catch((e) => console.log(e)); - - const invited = JSON.parse(ticket.invited) as string[]; - if (invited.includes(added.id)) return interaction.reply({ content: "User already added", ephemeral: true }).catch((e) => console.log(e)); - - if (invited.length >= 25) - return interaction.reply({ content: "You can't add more than 25 users", ephemeral: true }).catch((e) => console.log(e)); - - invited.push(added.id); - await this.client.prisma.tickets.update({ - data: { - invited: JSON.stringify(invited) - }, - where: { - channelid: interaction.channel?.id - } - }); - - await (interaction.channel as TextChannel | null)?.permissionOverwrites - .edit(added, { - SendMessages: true, - AddReactions: true, - ReadMessageHistory: true, - AttachFiles: true, - ViewChannel: true, - }); - - await interaction.reply({ content: `> Added <@${added.id}> to the ticket` }).catch((e) => console.log(e)); - - log( - { - LogType: "userAdded", - user: interaction.user, - ticketId: ticket.id.toString(), - ticketChannelId: interaction.channel?.id, - target: added, - }, - this.client - ); - } -} - -/* -Copyright 2023 Sayrix (github.com/Sayrix) - -Licensed under the Creative Commons Attribution 4.0 International -please check https://creativecommons.org/licenses/by/4.0 for more informations. -*/ +import {BaseCommand, ExtendedClient} from "../structure"; +import {CommandInteraction, SlashCommandBuilder, TextChannel, User} from "discord.js"; +import {log} from "../utils/logs"; + +/* +Copyright 2023 Sayrix (github.com/Sayrix) + +Licensed under the Creative Commons Attribution 4.0 International +please check https://creativecommons.org/licenses/by/4.0 for more informations. +*/ + +export default class AddCommand extends BaseCommand { + public static data: SlashCommandBuilder = new SlashCommandBuilder() + .setName("add") + .setDescription("Add someone to the ticket") + .addUserOption((input) => input.setName("user").setDescription("The user to add").setRequired(true)); + constructor(client: ExtendedClient) { + super(client); + } + + async execute(interaction: CommandInteraction) { + + const added = interaction.options.get("user", true).user as User; + const ticket = await this.client.prisma.tickets.findUnique({ + select: { + id: true, + invited: true, + }, + where: { + channelid: interaction.channel?.id + } + }); + + if (!ticket) return interaction.reply({ content: "Ticket not found", ephemeral: true }).catch((e) => console.log(e)); + + const invited = JSON.parse(ticket.invited) as string[]; + if (invited.includes(added.id)) return interaction.reply({ content: "User already added", ephemeral: true }).catch((e) => console.log(e)); + + if (invited.length >= 25) + return interaction.reply({ content: "You can't add more than 25 users", ephemeral: true }).catch((e) => console.log(e)); + + invited.push(added.id); + await this.client.prisma.tickets.update({ + data: { + invited: JSON.stringify(invited) + }, + where: { + channelid: interaction.channel?.id + } + }); + + await (interaction.channel as TextChannel | null)?.permissionOverwrites + .edit(added, { + SendMessages: true, + AddReactions: true, + ReadMessageHistory: true, + AttachFiles: true, + ViewChannel: true, + }); + + await interaction.reply({ content: `> Added <@${added.id}> to the ticket` }).catch((e) => console.log(e)); + + log( + { + LogType: "userAdded", + user: interaction.user, + ticketId: ticket.id.toString(), + ticketChannelId: interaction.channel?.id, + target: added, + }, + this.client + ); + } +} + +/* +Copyright 2023 Sayrix (github.com/Sayrix) + +Licensed under the Creative Commons Attribution 4.0 International +please check https://creativecommons.org/licenses/by/4.0 for more informations. +*/