Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed discord.js latest breaking change #359

Merged
merged 1 commit into from
May 11, 2024
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
162 changes: 81 additions & 81 deletions src/commands/add.ts
Original file line number Diff line number Diff line change
@@ -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 = <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 = <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.
*/
Loading