Skip to content

Commit 3a6ff2c

Browse files
Bump undici and discord.js (#474)
* Bump undici and discord.js Bumps [undici](https://github.com/nodejs/undici) to 6.21.3 and updates ancestor dependency [discord.js](https://github.com/discordjs/discord.js/tree/HEAD/packages/discord.js). These dependencies need to be updated together. Updates `undici` from 6.19.8 to 6.21.3 - [Release notes](https://github.com/nodejs/undici/releases) - [Commits](nodejs/undici@v6.19.8...v6.21.3) Updates `discord.js` from 14.15.3 to 14.21.0 - [Release notes](https://github.com/discordjs/discord.js/releases) - [Changelog](https://github.com/discordjs/discord.js/blob/14.21.0/packages/discord.js/CHANGELOG.md) - [Commits](https://github.com/discordjs/discord.js/commits/14.21.0/packages/discord.js) --- updated-dependencies: - dependency-name: undici dependency-version: 6.21.3 dependency-type: indirect - dependency-name: discord.js dependency-version: 14.21.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * Fix types * Fix a last type error --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Carl Vitullo <[email protected]>
1 parent 26b6251 commit 3a6ff2c

File tree

8 files changed

+138
-114
lines changed

8 files changed

+138
-114
lines changed

package-lock.json

Lines changed: 106 additions & 98 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@fastify/swagger": "^9.4.0",
2828
"date-fns": "3.6.0",
2929
"dedent": "1.5.3",
30-
"discord.js": "14.15.3",
30+
"discord.js": "14.21.0",
3131
"dotenv": "16.4.5",
3232
"fastify": "^5.3.2",
3333
"gists": "2.0.0",

src/features/commands.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
ChannelType,
66
EmbedType,
77
Message,
8+
OmitPartialGroupDMChannel,
9+
PartialGroupDMChannel,
810
TextChannel,
911
} from "discord.js";
1012
import cooldown from "./cooldown.js";
@@ -25,7 +27,7 @@ type Command = {
2527
words: string[];
2628
help: string;
2729
category: Categories;
28-
handleMessage: (msg: Message) => void;
30+
handleMessage: (msg: OmitPartialGroupDMChannel<Message>) => void;
2931
cooldown?: number;
3032
};
3133

@@ -1349,12 +1351,15 @@ const createCommandsMessage = () => {
13491351

13501352
const commands: ChannelHandlers = {
13511353
handleMessage: async ({ msg: maybeMessage }) => {
1352-
if (!maybeMessage.guild && maybeMessage.channel.type !== ChannelType.DM) {
1354+
if (
1355+
(!maybeMessage.inGuild() &&
1356+
maybeMessage.channel.type !== ChannelType.DM) ||
1357+
maybeMessage.channel instanceof PartialGroupDMChannel
1358+
) {
13531359
return;
13541360
}
1355-
const msg = maybeMessage.partial
1356-
? await maybeMessage.fetch()
1357-
: maybeMessage;
1361+
1362+
const msg = await maybeMessage.fetch();
13581363

13591364
commandsList.forEach((command) => {
13601365
const keyword = command.words.find((word) => {

src/features/jobs-moderation.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,13 @@ const validationRepl = async (message: Message) => {
230230
const posts = parseContent(message.content);
231231
const errors = validate(posts, message);
232232

233+
if (
234+
message.channel.type !== ChannelType.GuildText &&
235+
message.channel.type !== ChannelType.PublicThread
236+
) {
237+
return;
238+
}
239+
233240
await message.channel.send(
234241
errors.length > 0
235242
? errors.map((e) => `- ${getValidationMessage(e)}`).join("\n")

src/features/resume.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,18 @@ configure();
6565

6666
export const resumeResources = async (bot: Client) => {
6767
bot.on("interactionCreate", async (interaction) => {
68+
const { channel } = interaction;
6869
if (
6970
interaction.type !== InteractionType.MessageComponent ||
7071
interaction.componentType !== ComponentType.Button ||
71-
!interaction.channel ||
72-
interaction.channel.type !== ChannelType.PublicThread ||
73-
interaction.channel.parentId !== CHANNELS.resumeReview
72+
!channel ||
73+
channel.type !== ChannelType.PublicThread ||
74+
channel.parentId !== CHANNELS.resumeReview
7475
) {
7576
return;
7677
}
7778

78-
if (interaction.user.id !== interaction.channel.ownerId) {
79+
if (interaction.user.id !== channel.ownerId) {
7980
interaction.reply({
8081
ephemeral: true,
8182
content:
@@ -92,8 +93,7 @@ export const resumeResources = async (bot: Client) => {
9293
if (interaction.customId === REVIEW_COMMAND) {
9394
const deferred = await interaction.deferReply({ ephemeral: true });
9495
deferred.edit("Looking for a resume…");
95-
const messages = await interaction.channel.messages.fetch();
96-
const channel = interaction.channel;
96+
const messages = await channel.messages.fetch();
9797

9898
let firstMessage: Message<true> | null = null;
9999
try {
@@ -173,7 +173,7 @@ export const resumeResources = async (bot: Client) => {
173173
);
174174

175175
run.on("textCreated", () => {
176-
interaction.channel?.sendTyping();
176+
channel?.sendTyping();
177177
});
178178

179179
run.on("textDone", (content) => {
@@ -189,7 +189,7 @@ export const resumeResources = async (bot: Client) => {
189189
content: "Done!",
190190
});
191191

192-
interaction.channel?.send(content.value);
192+
channel?.send(content.value);
193193
});
194194
} catch (e) {
195195
// recover

src/features/scheduled-messages.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ const MESSAGE_SCHEDULE: MessageConfig[] = [
4040
{ interval: FREQUENCY.moreThanWeekly, channelId: CHANNELS.jobBoard },
4141
],
4242
message: async (channel) => {
43+
if (channel.type !== ChannelType.GuildText) {
44+
return;
45+
}
4346
const msg = await channel.send({
4447
content: `Messages must start with [FORHIRE]/[HIRING]. Check the channel description for a full list of tags and rules!
4548

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ const handleMessage = async (message: Message) => {
138138
if (message.system) {
139139
return;
140140
}
141-
const msg = message.partial ? await message.fetch() : message;
141+
const msg = await message.fetch();
142142

143143
const channel = msg.channel;
144144
const channelId = channel.isThread()

src/types/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import {
66
PartialMessageReaction,
77
PartialUser,
88
VoiceState,
9+
OmitPartialGroupDMChannel,
910
} from "discord.js";
1011

1112
type CommonArgs = {
1213
bot: Client;
1314
};
1415

1516
export type HandleMessageArgs = CommonArgs & {
16-
msg: Message;
17+
msg: OmitPartialGroupDMChannel<Message>;
1718
};
1819

1920
export type HandleReactionArgs = CommonArgs & {

0 commit comments

Comments
 (0)