Skip to content

Commit

Permalink
chore: update dependencies and some code (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
CarelessInternet authored May 5, 2024
1 parent 73ca979 commit ba827f3
Show file tree
Hide file tree
Showing 42 changed files with 4,503 additions and 3,225 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/bot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# If you need more help, visit the Dockerfile reference guide at
# https://docs.docker.com/engine/reference/builder/

ARG NODE_MAJOR_VERSION=21
ARG NODE_MAJOR_VERSION=22
# Necessary to run "pnpm install" when the Dev Container has started.
ARG PNPM_MAJOR_VERSION=8

FROM node:${NODE_MAJOR_VERSION}-alpine as base
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [21]
node-version: [22]
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v3
with:
version: 8
version: 9
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [21]
node-version: [22]
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v3
with:
version: 8
version: 9
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [21]
node-version: [22]
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v3
with:
version: 8
version: 9
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [21]
node-version: [22]
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v3
with:
version: 8
version: 9
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions apps/bot/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ module.exports = {
parserOptions: {
project: [join(__dirname, './tsconfig.json')],
},
rules: {
'unicorn/no-anonymous-default-export': 'off',
},
};
4 changes: 2 additions & 2 deletions apps/bot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# This problem has caused pain: https://github.com/pnpm/pnpm/issues/6088
# The solution? Do not use dependenciesMeta.injected (until further notice).

ARG NODE_MAJOR_VERSION=21
ARG PNPM_MAJOR_VERSION=8
ARG NODE_MAJOR_VERSION=22
ARG PNPM_MAJOR_VERSION=9
ARG TURBO_MAJOR_VERSION=1

FROM node:${NODE_MAJOR_VERSION}-alpine as base
Expand Down
4 changes: 2 additions & 2 deletions apps/bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
"@ticketer/djs-framework": "workspace:*",
"@ticketer/env": "workspace:*",
"chalk": "^5.3.0",
"discord.js": "^14.14.1",
"discord.js": "^14.15.2",
"tsx": "^3.13.0",
"typesafe-i18n": "^5.26.2"
},
"devDependencies": {
"@ticketer/eslint-config": "workspace:*",
"@types/node": "^20.11.28"
"@types/node": "^20.12.8"
}
}
8 changes: 4 additions & 4 deletions apps/bot/src/bot.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { GatewayIntentBits, Options } from 'discord.js';
import { dirname, resolve } from 'node:path';
import { Client } from '@ticketer/djs-framework';
import { environment } from '@ticketer/env/bot';
import { fileURLToPath } from 'node:url';
import path from 'node:path';

const interval = 60;
const filter = () => () => true;
Expand All @@ -23,9 +23,9 @@ const client = new Client({
},
});

const currentDirectory = dirname(fileURLToPath(import.meta.url));
const eventsFolder = resolve(currentDirectory, './events');
const commandsFolder = resolve(currentDirectory, './commands');
const currentDirectory = path.dirname(fileURLToPath(import.meta.url));
const eventsFolder = path.resolve(currentDirectory, './events');
const commandsFolder = path.resolve(currentDirectory, './commands');

await client.init(eventsFolder, commandsFolder);

Expand Down
10 changes: 7 additions & 3 deletions apps/bot/src/commands/staff/configuration-ticket-threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ export default class extends Command.Interaction {
.userEmbed(user)
.setTitle('Updated the Thead Ticket Configuration')
.setDescription(
`${user.toString()} updated the amount of active tickets a user may have at once to ${activeTickets}.`,
`${user.toString()} updated the amount of active tickets a user may have at once to ${activeTickets.toString()}.`,
);

return interaction.editReply({ embeds: [embed] });
Expand Down Expand Up @@ -472,7 +472,9 @@ export default class extends Command.Interaction {
const embed = super
.userEmbed(interaction.user)
.setTitle('Deleted the Thread Ticket Category')
.setDescription(`${interaction.user.toString()} deleted the category with the following title: ${title}.`);
.setDescription(
`${interaction.user.toString()} deleted the category with the following title: ${title ?? 'No Title Found'}.`,
);

return interaction.editReply({ embeds: [embed] });
} catch (error) {
Expand Down Expand Up @@ -863,7 +865,9 @@ export class ModalInteraction extends Modal.Interaction {
embeds: [
super
.userEmbedError(user)
.setDescription(`There are too many categories, you may not have more than ${MAXIMUM_CATEGORY_AMOUNT}.`),
.setDescription(
`There are too many categories, you may not have more than ${MAXIMUM_CATEGORY_AMOUNT.toString()}.`,
),
],
});
}
Expand Down
7 changes: 4 additions & 3 deletions apps/bot/src/commands/staff/configuration-welcome-farewell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,12 @@ export class ComponentInteraction extends Component.Interaction {
private async welcomeAndFarewellConfigurationChannel({ interaction }: Component.Context<'channel'>) {
const { channels, customId: id, guildId, user } = interaction;
const { customId } = super.extractCustomId(id);
const channel = channels.at(0);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const channel = channels.at(0)!;

const type = customId.includes('welcome') ? 'welcome' : 'farewell';
const channelDatabaseValue: InsertWithoutGuildId =
type === 'welcome' ? { welcomeChannelId: channel?.id } : { farewellChannelId: channel?.id };
type === 'welcome' ? { welcomeChannelId: channel.id } : { farewellChannelId: channel.id };

await database
.insert(welcomeAndFarewell)
Expand All @@ -319,7 +320,7 @@ export class ComponentInteraction extends Component.Interaction {
const embed = super
.userEmbed(user)
.setTitle('Updated the Welcome/Farewell Configuration')
.setDescription(`${user.toString()} updated the ${type} channel to ${channel?.toString()}`);
.setDescription(`${user.toString()} updated the ${type} channel to ${channel.toString()}`);

return interaction.editReply({ embeds: [embed], components: [] });
}
Expand Down
4 changes: 2 additions & 2 deletions apps/bot/src/commands/thread-ticketing/show-tickets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ async function viewTickets(

const components = messageWithPagination({
previous: {
customId: this.customId('ticket_threads_categories_view_tickets_previous', `${page}_${state ?? ''}`),
customId: this.customId('ticket_threads_categories_view_tickets_previous', `${page.toString()}_${state ?? ''}`),
disabled: page === 0,
label: translations.buttons.previous.label(),
},
next: {
customId: this.customId('ticket_threads_categories_view_tickets_next', `${page}_${state ?? ''}`),
customId: this.customId('ticket_threads_categories_view_tickets_next', `${page.toString()}_${state ?? ''}`),
disabled: tickets.length < PAGE_SIZE,
label: translations.buttons.next.label(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,21 @@ async function viewCategoryTickets(
);
const components = messageWithPagination({
previous: {
customId: this.customId('ticket_threads_categories_view_category_previous', `${page}_${categoryId ?? ''}`),
customId: this.customId(
'ticket_threads_categories_view_category_previous',
`${page.toString()}_${categoryId ?? ''}`,
),
disabled: page === 0,
},
next: {
customId: this.customId('ticket_threads_categories_view_category_next', `${page}_${categoryId ?? ''}`),
customId: this.customId('ticket_threads_categories_view_category_next', `${page.toString()}_${categoryId ?? ''}`),
disabled: tickets.length < PAGE_SIZE,
},
});

return interaction.editReply({
components,
content: `Total amount of tickets in the server: ${globalAmount ?? 0}.`,
content: `Total amount of tickets in the server: ${String(globalAmount ?? 0)}.`,
embeds,
});
}
Expand Down
6 changes: 3 additions & 3 deletions apps/bot/src/commands/thread-ticketing/view-global-tickets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,18 @@ async function viewGlobalTickets(
);
const components = messageWithPagination({
previous: {
customId: this.customId('ticket_threads_categories_view_global_previous', `${page}_${state ?? ''}`),
customId: this.customId('ticket_threads_categories_view_global_previous', `${page.toString()}_${state ?? ''}`),
disabled: page === 0,
},
next: {
customId: this.customId('ticket_threads_categories_view_global_next', `${page}_${state ?? ''}`),
customId: this.customId('ticket_threads_categories_view_global_next', `${page.toString()}_${state ?? ''}`),
disabled: tickets.length < PAGE_SIZE,
},
});

return interaction.editReply({
components,
content: `Total amount of tickets in the server: ${globalAmount ?? 0}.`,
content: `Total amount of tickets in the server: ${String(globalAmount ?? 0)}.`,
embeds,
});
}
Expand Down
4 changes: 2 additions & 2 deletions apps/bot/src/commands/utility/bot-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export default class extends Command.Interaction {
const shardsStatsAsString = shardsStats.reduce((accumulator, shard, index) => {
let value = `# Shard ${index.toLocaleString()}\n\n`;
value += `* Ping: ${shard.ping.toLocaleString()} ms\n`;
value += `* RAM Usage: ${shard.ramInMegabytes} MB\n`;
value += `* RAM Usage: ${shard.ramInMegabytes.toString()} MB\n`;
value += `* Servers: ${shard.servers.toLocaleString()}\n`;
value += `* Status: ${Status[shard.status]}\n`;
value += `* Status: ${Status[shard.status].toString()}\n`;
value += `* Up Since: ${shard.uptime ? formatDateLong(new Date(Date.now() - shard.uptime)) : 'Unknown'}\n`;
value += `* Users: ${shard.users.toLocaleString()}\n\n`;

Expand Down
8 changes: 4 additions & 4 deletions apps/bot/src/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { dirname, resolve } from 'node:path';
import { Client } from '@ticketer/djs-framework';
import chalk from 'chalk';
import { environment } from '@ticketer/env/bot';
import { exit } from 'node:process';
import { fileURLToPath } from 'node:url';
import path from 'node:path';

const client = new Client({
intents: [],
});

const currentDirectory = dirname(fileURLToPath(import.meta.url));
const eventsFolder = resolve(currentDirectory, './events');
const commandsFolder = resolve(currentDirectory, './commands');
const currentDirectory = path.dirname(fileURLToPath(import.meta.url));
const eventsFolder = path.resolve(currentDirectory, './events');
const commandsFolder = path.resolve(currentDirectory, './commands');

await client.init(eventsFolder, commandsFolder);

Expand Down
4 changes: 2 additions & 2 deletions apps/bot/src/events/client/ClientReady.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export default class extends Event.Handler {
@LogExceptions
public execute([client]: Event.ArgumentsOf<this['name']>) {
client.user.setPresence({
activities: [{ name: `Playing 🏌️‍♂️ | Shard #${client.shard?.ids.at(0) ?? 0}`, type: ActivityType.Custom }],
activities: [{ name: `Playing 🏌️‍♂️ | Shard #${String(client.shard?.ids.at(0) ?? 0)}`, type: ActivityType.Custom }],
status: PresenceUpdateStatus.Online,
});

console.log(
chalk.blue('[Client]'),
`Logged in as ${chalk.blueBright(client.user.tag)} on ${formatDateLong(new Date())} on`,
chalk.yellow(`shard #${client.shard?.ids.at(0)}.`),
chalk.yellow(`shard #${String(client.shard?.ids.at(0) ?? 0)}.`),
);
}
}
10 changes: 5 additions & 5 deletions apps/bot/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { dirname, resolve } from 'node:path';
import { ShardingManager } from 'discord.js';
import chalk from 'chalk';
import { environment } from '@ticketer/env/bot';
import { fileURLToPath } from 'node:url';
import { formatDateLong } from '@/utils';
import path from 'node:path';

const currentDirectory = dirname(fileURLToPath(import.meta.url));
const botFilePath = resolve(currentDirectory, './bot.ts');
const currentDirectory = path.dirname(fileURLToPath(import.meta.url));
const botFilePath = path.resolve(currentDirectory, './bot.ts');

// https://github.com/esbuild-kit/tsx/issues/354
const sharder = new ShardingManager(botFilePath, {
Expand All @@ -19,11 +19,11 @@ sharder.on('shardCreate', (shard) => {
console.log(
chalk.green('[Sharding]'),
'Created',
chalk.yellow(`shard #${shard.id}`),
chalk.yellow(`shard #${shard.id.toString()}`),
`on ${formatDateLong(new Date())}.`,
);
shard.once('ready', () => {
console.log(chalk.yellow(`[Shard #${shard.id}]`), 'This shard has become ready.');
console.log(chalk.yellow(`[Shard #${shard.id.toString()}]`), 'This shard has become ready.');
});
});

Expand Down
5 changes: 4 additions & 1 deletion apps/bot/src/utils/thread-ticketing/ticketModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ export function ticketModal(this: BaseInteraction.Interaction, { categoryId, loc

return new ModalBuilder()
.setCustomId(
this.customId('ticket_threads_categories_create_ticket', userId ? `${categoryId}_${userId}` : categoryId),
this.customId(
'ticket_threads_categories_create_ticket',
userId ? `${categoryId.toString()}_${userId}` : categoryId,
),
)
.setTitle(translations.modalTitle())
.setComponents(titleRow, descriptionRow);
Expand Down
6 changes: 3 additions & 3 deletions apps/bot/src/utils/thread-ticketing/viewUserTickets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ export async function viewUserTickets(
);
const components = messageWithPagination({
previous: {
customId: this.customId('ticket_threads_categories_view_user_previous', `${page}_${user.id}`),
customId: this.customId('ticket_threads_categories_view_user_previous', `${page.toString()}_${user.id}`),
disabled: page === 0,
},
next: {
customId: this.customId('ticket_threads_categories_view_user_next', `${page}_${user.id}`),
customId: this.customId('ticket_threads_categories_view_user_next', `${page.toString()}_${user.id}`),
disabled: tickets.length < PAGE_SIZE,
},
});
Expand All @@ -82,7 +82,7 @@ export async function viewUserTickets(
parse: [],
},
components,
content: `Total amount of tickets by ${user.toString()} in the server: ${globalAmount ?? 0}.`,
content: `Total amount of tickets by ${user.toString()} in the server: ${String(globalAmount ?? 0)}.`,
embeds,
});
}
28 changes: 14 additions & 14 deletions apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@
"@radix-ui/react-tooltip": "^1.0.7",
"@vercel/analytics": "^1.2.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"lucide-react": "^0.358.0",
"next": "14.1.3",
"clsx": "^2.1.1",
"lucide-react": "^0.378.0",
"next": "14.2.3",
"next-themes": "^0.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tailwind-merge": "^2.2.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@ticketer/eslint-config": "workspace:*",
"@types/node": "^20.11.28",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"autoprefixer": "^10.4.18",
"@types/node": "^20.12.8",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"autoprefixer": "^10.4.19",
"eslint": "^8.57.0",
"eslint-config-next": "14.1.3",
"postcss": "^8.4.35",
"tailwindcss": "^3.4.1",
"typescript": "^5.4.2"
"eslint-config-next": "14.2.3",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.3",
"typescript": "^5.4.5"
}
}
Loading

0 comments on commit ba827f3

Please sign in to comment.