feat: update deps and breaking changes

This commit is contained in:
Anthony Berg 2025-01-15 16:07:21 +01:00
parent fc8c12b346
commit 2fbb6c9265
7 changed files with 379 additions and 364 deletions

View File

@ -34,30 +34,30 @@
"pnpm": ">=9" "pnpm": ">=9"
}, },
"dependencies": { "dependencies": {
"@prisma/client": "^5.18.0", "@prisma/client": "^5.22.0",
"@sapphire/discord.js-utilities": "^7.3.0", "@sapphire/discord.js-utilities": "^7.3.2",
"@sapphire/framework": "^5.2.1", "@sapphire/framework": "^5.3.2",
"@sapphire/plugin-logger": "^4.0.2", "@sapphire/plugin-logger": "^4.0.2",
"@sapphire/plugin-scheduled-tasks": "^10.0.1", "@sapphire/plugin-scheduled-tasks": "^10.0.2",
"@sapphire/plugin-subcommands": "^6.0.3", "@sapphire/plugin-subcommands": "^6.0.3",
"@sapphire/stopwatch": "^1.5.2", "@sapphire/stopwatch": "^1.5.4",
"@sapphire/time-utilities": "^1.7.12", "@sapphire/time-utilities": "^1.7.14",
"@sapphire/ts-config": "^5.0.1", "@sapphire/ts-config": "^5.0.1",
"@sapphire/utilities": "^3.17.0", "@sapphire/utilities": "^3.18.1",
"bullmq": "^5.12.10", "bullmq": "^5.34.10",
"discord.js": "^14.15.3", "discord.js": "^14.17.3",
"ioredis": "^5.4.1", "ioredis": "^5.4.2",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "~5.4.5" "typescript": "~5.4.5"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.16.1", "@types/node": "^20.17.13",
"@typescript-eslint/eslint-plugin": "^6.21.0", "@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0", "@typescript-eslint/parser": "^6.21.0",
"eslint": "8.56.0", "eslint": "8.56.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"prettier": "3.2.4", "prettier": "3.2.4",
"prisma": "^5.18.0" "prisma": "^5.22.0"
}, },
"packageManager": "pnpm@9.12.2+sha512.22721b3a11f81661ae1ec68ce1a7b879425a1ca5b991c975b074ac220b187ce56c708fe5db69f4c962c989452eee76c82877f4ee80f474cebd61ee13461b6228" "packageManager": "pnpm@9.12.2+sha512.22721b3a11f81661ae1ec68ce1a7b879425a1ca5b991c975b074ac220b187ce56c708fe5db69f4c962c989452eee76c82877f4ee80f474cebd61ee13461b6228"
} }

618
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,7 @@
*/ */
import { Args, Command, RegisterBehavior } from '@sapphire/framework'; import { Args, Command, RegisterBehavior } from '@sapphire/framework';
import type { Message } from 'discord.js'; import { Message, MessageFlagsBitField } from 'discord.js';
import { ChannelType, TextChannel } from 'discord.js'; import { ChannelType, TextChannel } from 'discord.js';
export class AnonymousCommand extends Command { export class AnonymousCommand extends Command {
@ -67,8 +67,8 @@ export class AnonymousCommand extends Command {
if (guild === null) { if (guild === null) {
await interaction.reply({ await interaction.reply({
content: 'Error fetching guild!', content: 'Error fetching guild!',
ephemeral: true, flags: MessageFlagsBitField.Flags.Ephemeral,
fetchReply: true, withResponse: true,
}); });
return; return;
} }
@ -77,8 +77,17 @@ export class AnonymousCommand extends Command {
if (interaction.channel === null) { if (interaction.channel === null) {
await interaction.reply({ await interaction.reply({
content: 'Error getting the channel!', content: 'Error getting the channel!',
ephemeral: true, flags: MessageFlagsBitField.Flags.Ephemeral,
fetchReply: true, withResponse: true,
});
return;
}
if (!interaction.channel.isSendable()) {
await interaction.reply({
content: `I do not have sufficient permissions to send a message in ${interaction.channel}!`,
flags: MessageFlagsBitField.Flags.Ephemeral,
withResponse: true,
}); });
return; return;
} }
@ -86,8 +95,8 @@ export class AnonymousCommand extends Command {
await interaction.channel.send(message); await interaction.channel.send(message);
await interaction.reply({ await interaction.reply({
content: 'Sent the message', content: 'Sent the message',
ephemeral: true, flags: MessageFlagsBitField.Flags.Ephemeral,
fetchReply: true, withResponse: true,
}); });
return; return;
} }
@ -95,8 +104,8 @@ export class AnonymousCommand extends Command {
if (channel.type !== ChannelType.GuildText) { if (channel.type !== ChannelType.GuildText) {
await interaction.reply({ await interaction.reply({
content: 'Could not send, unsupported text channel!', content: 'Could not send, unsupported text channel!',
ephemeral: true, flags: MessageFlagsBitField.Flags.Ephemeral,
fetchReply: true, withResponse: true,
}); });
} }
@ -105,8 +114,8 @@ export class AnonymousCommand extends Command {
await interaction.reply({ await interaction.reply({
content: 'Sent the message', content: 'Sent the message',
ephemeral: true, flags: MessageFlagsBitField.Flags.Ephemeral,
fetchReply: true, withResponse: true,
}); });
} }
@ -121,7 +130,7 @@ export class AnonymousCommand extends Command {
return; return;
} }
if (channel.isTextBased()) { if (channel.isSendable()) {
await channel.send(text); await channel.send(text);
} else { } else {
await message.react('❌'); await message.react('❌');

View File

@ -30,9 +30,9 @@ import {
TextChannel, TextChannel,
GuildMember, GuildMember,
Snowflake, Snowflake,
MessageFlagsBitField,
} from 'discord.js'; } from 'discord.js';
import type { Message } from 'discord.js'; import type { Message } from 'discord.js';
import { isMessageInstance } from '@sapphire/discord.js-utilities';
import { import {
addSusNoteDB, addSusNoteDB,
findNotes, findNotes,
@ -407,16 +407,21 @@ export class SusCommand extends Subcommand {
const message = await interaction.reply({ const message = await interaction.reply({
embeds: [noteEmbed], embeds: [noteEmbed],
components: [buttons], components: [buttons],
ephemeral: true, flags: MessageFlagsBitField.Flags.Ephemeral,
fetchReply: true, withResponse: true,
}); });
// Checks if the message is not an APIMessage // Checks if the message is not an APIMessage
if (!isMessageInstance(message)) { if (message.resource === null) {
await interaction.editReply('Failed to retrieve the message :('); await interaction.editReply('Failed to retrieve the message :(');
return; return;
} }
if (!channel.isSendable()) {
await interaction.editReply('Cannot send messages in this channel!');
return;
}
// Listen for the button presses // Listen for the button presses
const collector = channel.createMessageComponentCollector({ const collector = channel.createMessageComponentCollector({
max: 1, // Maximum of 1 button press max: 1, // Maximum of 1 button press
@ -519,8 +524,8 @@ export class SusCommand extends Subcommand {
if (guild === null || channel === null) { if (guild === null || channel === null) {
await interaction.reply({ await interaction.reply({
content: 'Error fetching guild or channel!', content: 'Error fetching guild or channel!',
ephemeral: true, flags: MessageFlagsBitField.Flags.Ephemeral,
fetchReply: true, withResponse: true,
}); });
return; return;
} }
@ -531,8 +536,8 @@ export class SusCommand extends Subcommand {
if (member === undefined) { if (member === undefined) {
await interaction.reply({ await interaction.reply({
content: 'Error fetching user!', content: 'Error fetching user!',
ephemeral: true, flags: MessageFlagsBitField.Flags.Ephemeral,
fetchReply: true, withResponse: true,
}); });
return; return;
} }
@ -545,8 +550,8 @@ export class SusCommand extends Subcommand {
if (notes.length === 0) { if (notes.length === 0) {
await interaction.reply({ await interaction.reply({
content: `${user} had no notes!`, content: `${user} had no notes!`,
ephemeral: true, flags: MessageFlagsBitField.Flags.Ephemeral,
fetchReply: true, withResponse: true,
}); });
return; return;
} }
@ -596,16 +601,21 @@ export class SusCommand extends Subcommand {
const message = await interaction.reply({ const message = await interaction.reply({
embeds: [noteEmbed], embeds: [noteEmbed],
components: [buttons], components: [buttons],
ephemeral: true, flags: MessageFlagsBitField.Flags.Ephemeral,
fetchReply: true, withResponse: true,
}); });
// Checks if the message is not an APIMessage // Checks if the message is not an APIMessage
if (!isMessageInstance(message)) { if (message.resource === null) {
await interaction.editReply('Failed to retrieve the message :('); await interaction.editReply('Failed to retrieve the message :(');
return; return;
} }
if (!channel.isSendable()) {
await interaction.editReply('Cannot send messages in this channel!');
return;
}
// Listen for the button presses // Listen for the button presses
const collector = channel.createMessageComponentCollector({ const collector = channel.createMessageComponentCollector({
max: 1, // Maximum of 1 button press max: 1, // Maximum of 1 button press

View File

@ -17,9 +17,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { isMessageInstance } from '@sapphire/discord.js-utilities';
import { Command } from '@sapphire/framework'; import { Command } from '@sapphire/framework';
import type { Message } from 'discord.js'; import { Message, MessageFlagsBitField } from 'discord.js';
export class PingCommand extends Command { export class PingCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) { public constructor(context: Command.LoaderContext, options: Command.Options) {
@ -41,12 +40,13 @@ export class PingCommand extends Command {
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
const msg = await interaction.reply({ const msg = await interaction.reply({
content: 'Ping?', content: 'Ping?',
ephemeral: true, flags: MessageFlagsBitField.Flags.Ephemeral,
fetchReply: true, withResponse: true,
}); });
if (isMessageInstance(msg)) { if (msg.resource !== null && msg.resource.message !== null) {
const diff = msg.createdTimestamp - interaction.createdTimestamp; const diff =
msg.resource.message.createdTimestamp - interaction.createdTimestamp;
const ping = Math.round(this.container.client.ws.ping); const ping = Math.round(this.container.client.ws.ping);
return interaction.editReply( return interaction.editReply(
`Pong 🏓! (Round trip took: ${diff}ms. Heartbeat: ${ping}ms.)`, `Pong 🏓! (Round trip took: ${diff}ms. Heartbeat: ${ping}ms.)`,
@ -57,6 +57,11 @@ export class PingCommand extends Command {
} }
public async messageRun(message: Message) { public async messageRun(message: Message) {
if (!message.channel.isSendable()) {
// TODO manage logging/errors properly
return;
}
const msg = await message.channel.send('Ping?'); const msg = await message.channel.send('Ping?');
const diff = msg.createdTimestamp - message.createdTimestamp; const diff = msg.createdTimestamp - message.createdTimestamp;

View File

@ -49,6 +49,11 @@ export class XpListener extends Listener {
// If no counts exist on the database, then create the first count from the bot // If no counts exist on the database, then create the first count from the bot
if (lastCount === null) { if (lastCount === null) {
if (this.container.client.id === null) { if (this.container.client.id === null) {
if (!message.channel.isSendable()) {
// TODO manage logging/errors properly
return;
}
message.channel.send( message.channel.send(
'An unexpected error occurred trying to set up the counting channel, please contact a developer!', 'An unexpected error occurred trying to set up the counting channel, please contact a developer!',
); );
@ -63,6 +68,11 @@ export class XpListener extends Listener {
lastCount = await getLastCount(); lastCount = await getLastCount();
if (lastCount === null) { if (lastCount === null) {
if (!message.channel.isSendable()) {
// TODO manage logging/errors properly
return;
}
message.channel.send( message.channel.send(
'An unexpected error occurred, please contact a developer!', 'An unexpected error occurred, please contact a developer!',
); );

View File

@ -83,6 +83,11 @@ export class Suggestions extends Listener {
return; return;
} }
if (!mailbox.isSendable()) {
// TODO manage logging/errors properly
return;
}
const sent = await mailbox.send({ const sent = await mailbox.send({
embeds: [suggestion], embeds: [suggestion],
content: message.author.toString(), content: message.author.toString(),