Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
acc37b1
Bump discord.js from 13.8.1 to 14.0.2
dependabot[bot] Jul 18, 2022
0585500
Bump @sapphire/shapeshift from 3.4.0 to 3.5.1
dependabot[bot] Jul 18, 2022
165be41
Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/discord.…
PythonCoderAS Jul 18, 2022
98c2eeb
Update to v14
PythonCoderAS Jul 18, 2022
9398896
Remove `@discordjs/builders` as direct dependency
PythonCoderAS Jul 18, 2022
3b9b132
Rename `MessageActionRow` and `MessageButton`
PythonCoderAS Jul 18, 2022
2586659
Fixes in progress
PythonCoderAS Jul 18, 2022
977f52f
Replace MessageEmbed with EmbedBuilder
PythonCoderAS Jul 18, 2022
f1de32f
Replace HTTPAttachmentData with AttachmentBuilder
PythonCoderAS Jul 18, 2022
363635b
Fix missing `type` on `send()#components`
PythonCoderAS Jul 18, 2022
43e8608
Add optional packages for speed
PythonCoderAS Jul 19, 2022
c848538
Change type to `ChatInputCommandInteraction` to fix options errors
PythonCoderAS Jul 19, 2022
4f718c2
Fix weird autocomplete bug
PythonCoderAS Jul 19, 2022
c5ce37e
Bump discord.js from 13.8.1 to 14.0.3
dependabot[bot] Jul 20, 2022
fbbb4fb
Fix invalid User resolution in autocomplete for `/command log view af…
PythonCoderAS Jul 20, 2022
fd301c2
Fix remaining instances
PythonCoderAS Jul 20, 2022
bd3ad57
Fix colors and cleanup last of userId problems
PythonCoderAS Jul 20, 2022
b372ef8
Cleanup embed issues in `/command log prune`
PythonCoderAS Jul 20, 2022
9c47e4a
Fix MessageSelectRow -> SelectRowBuilder and fix new button component…
PythonCoderAS Jul 20, 2022
0440f9b
Fix custom collector
PythonCoderAS Jul 20, 2022
0ee0a6a
Use good, future-proof practices
PythonCoderAS Jul 20, 2022
c316302
Fix paginator and button presets
PythonCoderAS Jul 20, 2022
526d7e0
Fix embed fields for `/command log view`
PythonCoderAS Jul 20, 2022
e571c96
Fix embed fields for `/command view`
PythonCoderAS Jul 20, 2022
283ba5d
Fix embed fields for `/command log prune`
PythonCoderAS Jul 20, 2022
2a69098
Fix embed fields for `/error log view`
PythonCoderAS Jul 20, 2022
438e850
Fix embed fields for `/error view`
PythonCoderAS Jul 20, 2022
16071e4
Fix embed fields for `/profile`
PythonCoderAS Jul 20, 2022
850ede9
Fix `/set` menu
PythonCoderAS Jul 20, 2022
de5b2e7
Fix `/stats` embeds
PythonCoderAS Jul 20, 2022
9f2d9d7
Fix `/testScreening` embeds
PythonCoderAS Jul 20, 2022
f1a114b
Fix screenshot generation
PythonCoderAS Jul 20, 2022
55422c3
Fix interaction serialization
PythonCoderAS Jul 20, 2022
91f22cb
Fix remaining errors
PythonCoderAS Jul 20, 2022
10841b6
Run autoformat
PythonCoderAS Jul 20, 2022
ec17aaf
Fix lint errors, and uninstall discord-api-types
PythonCoderAS Jul 20, 2022
0215fdc
Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/discord.…
PythonCoderAS Jul 20, 2022
b8a65ea
Update deps
PythonCoderAS Jul 20, 2022
ca3624d
Merge remote-tracking branch 'origin/master' into v14
PythonCoderAS Jul 20, 2022
f23929a
Version bump
PythonCoderAS Jul 20, 2022
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
607 changes: 312 additions & 295 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "healthscreeningbot",
"version": "2.11.1",
"version": "2.12.0",
"author": {
"email": "sarkaraoyan@gmail.com",
"name": "Aoyan Sarkar"
Expand Down Expand Up @@ -39,27 +39,31 @@
"nyc"
],
"dependencies": {
"@discordjs/builders": "1.0.0",
"@discordjs/rest": "1.0.0",
"@healthscreening/complete-screening": "1.0.6",
"@healthscreening/generate-screenshot": "1.1.4",
"@healthscreening/screening-types": "1.0.0",
"array-string-map": "3.0.0",
"axios": "0.27.2",
"bufferutil": "4.0.6",
"concurrent-priority-worker-queue": "2.0.0",
"discord-api-types": "0.33.5",
"discord.js": "13.8.1",
"discord.js": "14.0.3",
"erlpack": "github:discord/erlpack",
"lodash": "4.17.21",
"luxon": "3.0.1",
"pg": "8.7.3",
"pg-hstore": "2.3.4",
"puppeteer": "15.4.0",
"sequelize": "6.21.3",
"sleep-promise": "9.1.0",
"uuid": "8.3.2"
"title-case": "^3.0.3",
"utf-8-validate": "5.0.9",
"uuid": "8.3.2",
"zlib-sync": "0.1.7"
},
"devDependencies": {
"@healthscreening/sequelize-lazy-migrations": "2.0.0",
"@sapphire/shapeshift": "3.5.1",
"@trivago/prettier-plugin-sort-imports": "3.3.0",
"@types/lodash": "4.14.182",
"@types/luxon": "3.0.0",
Expand All @@ -69,8 +73,7 @@
"eslint-config-pythoncoderas-combo": "1.1.3",
"prettier": "2.7.1",
"sequelize-cli": "6.4.1",
"typescript": "4.7.4",
"@sapphire/shapeshift": "3.4.0"
"typescript": "4.7.4"
},
"scripts": {
"start": "node src/client.js",
Expand Down
2 changes: 1 addition & 1 deletion src/buttons/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async function deleteMessage(interaction: HSBMessageComponentInteraction) {
return message.delete();
}

export default async function deleteButton(
export default async function deleteButtonBuilder(
interaction: HSBMessageComponentInteraction
) {
const { message } = interaction;
Expand Down
12 changes: 6 additions & 6 deletions src/buttons/goToDM.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { MessageActionRow, MessageButton } from "discord.js";
import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";

import { HSBMessageComponentInteraction } from "../discordjs-overrides";

/**
* Provides a shortcut to go to DMs with the bot.
*/
export default async function goToDMButton(
export default async function goToDMButtonBuilder(
interaction: HSBMessageComponentInteraction
) {
const user = await interaction.client.users.fetch(interaction.user.id);
Expand Down Expand Up @@ -33,12 +33,12 @@ export default async function goToDMButton(
"Click the button below to go to your direct message channel with the bot.",
ephemeral: true,
components: [
new MessageActionRow().addComponents(
new MessageButton()
new ActionRowBuilder().setComponents([
new ButtonBuilder()
.setURL(`https://discord.com/channels/@me/${dmChannel.id}`)
.setLabel("Click to Open DM")
.setStyle("LINK")
),
.setStyle(ButtonStyle.Link),
]) as ActionRowBuilder<ButtonBuilder>,
],
});
}
17 changes: 8 additions & 9 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Intents } from "discord.js";
import { GatewayIntentBits, Partials } from "discord.js";
import process from "process";

import {
Expand All @@ -12,15 +12,14 @@ import { init, sequelize } from "./orm";
import { loadAllGuides } from "./utils/guides";
import logError from "./utils/logError";

const myIntents = new Intents();
myIntents.add(Intents.FLAGS.GUILDS);
myIntents.add(Intents.FLAGS.GUILD_MEMBERS);
myIntents.add(Intents.FLAGS.GUILD_MESSAGES);
myIntents.add(Intents.FLAGS.DIRECT_MESSAGES);

const client: HealthScreeningBotClient = new HealthScreeningBotClient({
intents: myIntents,
partials: ["CHANNEL"],
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.DirectMessages,
],
partials: [Partials.Channel],
});

async function shutdown(errcode = 1) {
Expand Down
13 changes: 7 additions & 6 deletions src/client/command/baseCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ import { PreCommandChecks } from "./preCommandChecks";

// eslint-disable-next-line import/prefer-default-export -- Some nasty export errors occur when making this a default.
export abstract class BaseCommand implements PreCommandChecks {
/**
* The function that will run whenever this command is used as a slash command.
* @param interaction The interaction object.
*/
execute?(interaction: CommandInteraction): Promise<void>;

/**
* A mapping of fields that will support autocomplete to the functions that will
* be executed when said fields are autocompleted.
Expand All @@ -23,7 +17,14 @@ export abstract class BaseCommand implements PreCommandChecks {
(interaction: AutocompleteInteraction) => Promise<void>
> = new Collection();

/**
* The function that will run whenever this command is used as a slash command.
* @param interaction The interaction object.
*/
execute?(interaction: CommandInteraction): Promise<void>;

// Hack to silence typescript
beforeExecute?(interaction: CommandInteraction): Promise<boolean>;

beforeAutocomplete?(interaction: AutocompleteInteraction): Promise<boolean>;
}
3 changes: 1 addition & 2 deletions src/client/command/command.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SlashCommandBuilder } from "@discordjs/builders";
import { Collection } from "discord.js";
import { Collection, SlashCommandBuilder } from "discord.js";

import { BaseCommand } from "./baseCommand";
import { Subcommand } from "./subcommand";
Expand Down
2 changes: 1 addition & 1 deletion src/client/command/subcommand.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { SlashCommandSubcommandBuilder } from "discord.js";

import { BaseCommand } from "./baseCommand";

Expand Down
6 changes: 4 additions & 2 deletions src/client/command/subcommandGroup.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders";
import {
AutocompleteInteraction,
Collection,
CommandInteraction,
SlashCommandSubcommandGroupBuilder,
} from "discord.js";

import { Subcommand } from ".";
Expand All @@ -13,11 +13,13 @@ import { SubcommandContainer } from "./subcommandContainer";
export abstract class SubcommandGroup
implements PreCommandChecks, SubcommandContainer
{
public subcommands: Collection<string, Subcommand> = new Collection();

abstract registerSubcommandGroup(
subcommandGroup: SlashCommandSubcommandGroupBuilder
): SlashCommandSubcommandGroupBuilder;

public subcommands: Collection<string, Subcommand> = new Collection();
beforeExecute?(interaction: CommandInteraction): Promise<boolean>;

beforeAutocomplete?(interaction: AutocompleteInteraction): Promise<boolean>;
}
21 changes: 11 additions & 10 deletions src/client/extraClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import {
Client,
ClientOptions,
Collection,
EmbedBuilder,
Interaction,
InteractionType,
Message,
MessageEmbed,
TextChannel,
} from "discord.js";

import deleteButton from "../buttons/delete";
import goToDMButton from "../buttons/goToDM";
import deleteButtonBuilder from "../buttons/delete";
import goToDMButtonBuilder from "../buttons/goToDM";
import CommandCommand from "../commands/command";
import DeleteAuto from "../commands/deleteAuto";
import ErrorCommand from "../commands/error";
Expand Down Expand Up @@ -87,13 +88,13 @@ export default class HealthScreeningBotClient extends Client {
limit: 1,
});

public readonly globalButtons: Collection<
public readonly globalButtonBuilders: Collection<
string,
(interaction: HSBMessageComponentInteraction) => Promise<void>
> = new Collection(
Object.entries({
delete: deleteButton,
go_to_dm: goToDMButton,
delete: deleteButtonBuilder,
go_to_dm: goToDMButtonBuilder,
})
);

Expand All @@ -102,7 +103,7 @@ export default class HealthScreeningBotClient extends Client {
* If providing paths, they must be relative to the root of the guides folder at the
* root of the project, not the root of the source.
*/
public guideData: Collection<string, MessageEmbed[]>;
public guideData: Collection<string, EmbedBuilder[]>;

constructor(options: ClientOptions) {
super(options);
Expand Down Expand Up @@ -164,15 +165,15 @@ export default class HealthScreeningBotClient extends Client {
private async oninteractionCreate(interaction: Interaction): Promise<void> {
try {
switch (interaction.type) {
case "APPLICATION_COMMAND":
case InteractionType.ApplicationCommand:
await commandInteraction(interaction as HSBCommandInteraction);
break;
case "APPLICATION_COMMAND_AUTOCOMPLETE":
case InteractionType.ApplicationCommandAutocomplete:
await commandInteractionAutocomplete(
interaction as HSBAutocompleteInteraction
);
break;
case "MESSAGE_COMPONENT":
case InteractionType.MessageComponent:
await messageComponentInteraction(
interaction as HSBMessageComponentInteraction
);
Expand Down
18 changes: 11 additions & 7 deletions src/client/interactions/messageComponentInteraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export default async function messageComponentInteraction(
return;
}

if (!interaction.client.globalButtons.has(customId)) {
if (!interaction.client.globalButtonBuilders.has(customId)) {
await logError(
new Error(`Global Button ${customId} not found`),
"interaction::globalButton::buttonNotFound",
new Error(`Global ButtonBuilder ${customId} not found`),
"interaction::globalButtonBuilder::buttonNotFound",
serializeMessageComponentInteraction(interaction)
);
await sendMessage({
Expand All @@ -34,15 +34,15 @@ export default async function messageComponentInteraction(
return;
}

const buttonAction = interaction.client.globalButtons.get(customId)!;
const buttonAction = interaction.client.globalButtonBuilders.get(customId)!;
try {
await buttonAction(interaction);
} catch (error) {
// Skipped because no better way to do this
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const metadata: { [k: string]: any } =
serializeMessageComponentInteraction(interaction);
await logError(error, "interaction::globalButton", metadata);
await logError(error, "interaction::globalButtonBuilder", metadata);
try {
await sendMessage({
itemType: ItemType.interaction,
Expand All @@ -55,13 +55,17 @@ export default async function messageComponentInteraction(
} catch (e2) {
metadata.deferred = interaction.deferred;
metadata.replied = interaction.replied;
await logError(e2, "interaction::globalButton::errorReply", metadata);
await logError(
e2,
"interaction::globalButtonBuilder::errorReply",
metadata
);
}
}
} catch (e) {
await logError(
e,
"interaction::globalButton::processing",
"interaction::globalButtonBuilder::processing",
serializeMessageComponentInteraction(interaction)
);
}
Expand Down
8 changes: 5 additions & 3 deletions src/commands/command/delete.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { CommandInteraction } from "discord.js";
import {
ChatInputCommandInteraction,
SlashCommandSubcommandBuilder,
} from "discord.js";
import { Op } from "sequelize";

import { Subcommand } from "../../client/command";
Expand All @@ -26,7 +28,7 @@ export default class CommandDeleteCommand extends Subcommand {
);
}

async execute(interaction: CommandInteraction): Promise<void> {
async execute(interaction: ChatInputCommandInteraction): Promise<void> {
const id: number = interaction.options.getInteger("id", true);
const ephemeral =
interaction.options.getBoolean("ephemeral", false) ?? true;
Expand Down
3 changes: 1 addition & 2 deletions src/commands/command/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SlashCommandBuilder } from "@discordjs/builders";
import { Collection } from "discord.js";
import { Collection, SlashCommandBuilder } from "discord.js";

import { Command, Subcommand, SubcommandGroup } from "../../client/command";
import checkOwner from "../../utils/checkOwner";
Expand Down
3 changes: 1 addition & 2 deletions src/commands/command/log/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders";
import { Collection } from "discord.js";
import { Collection, SlashCommandSubcommandGroupBuilder } from "discord.js";

import { Subcommand, SubcommandGroup } from "../../../client/command";
import CommandLogPruneCommand from "./prune";
Expand Down
Loading