Skip to content

Commit f6bdb48

Browse files
committed
Refactor imports, enhance Modmail thread handling, and extend BigInt support
- Reformatted imports for readability and consistency across modules. - Improved Modmail thread handling with validation for accessible thread channels and enhanced error logging. - Added `escape` method in `RealBigInt` to support proper string representation of BigInt values. - Fixed return behavior in Starboard listener to prevent redundant executions.
1 parent 1d3b2d7 commit f6bdb48

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/modules/modmail/modmail.listener.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,14 @@ const handleDMMessage = async (
9494

9595
try {
9696
const guild = await client.guilds.fetch(config.guildId);
97-
const thread = await guild.channels.fetch(modMail.threadId.toString());
97+
const threadChannel = await guild.channels.fetch(config.modmail.channel);
98+
if (!threadChannel || threadChannel.type !== ChannelType.GuildText) {
99+
logger.warn(`Modmail channel ${config.modmail.channel} not found`);
100+
return;
101+
}
102+
const thread = await threadChannel.threads.fetch(
103+
modMail.threadId.toString(),
104+
);
98105

99106
// Check if thread exists, is accessible, and is not archived
100107
if (!thread?.isThread()) {

src/modules/starboard/starboard.listener.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ export const StarboardListener: EventListener = {
196196
member,
197197
count,
198198
);
199+
return;
199200
}
200201

201202
const starboardMessageContent = await createStarboardMessageFromMessage(

src/store/RealBigInt.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ export class RealBigInt extends DataTypes.ABSTRACT<bigint> {
2626
}
2727
}
2828

29+
override escape(value: unknown): string {
30+
if (this.nativeBigIntSupport()) {
31+
// For native bigint support, return the value as string
32+
return value?.toString() ?? "0";
33+
} else {
34+
// For string representation, escape as a string literal
35+
return `'${value}'`;
36+
}
37+
}
38+
2939
override sanitize(value: unknown): unknown {
3040
if (value instanceof BigInt || typeof value === "bigint") {
3141
return value;

0 commit comments

Comments
 (0)