Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Commit 2dab293

Browse files
committed
fix: fix deepsource errors
1 parent d4bd6bf commit 2dab293

File tree

7 files changed

+36
-78
lines changed

7 files changed

+36
-78
lines changed

Dockerfile

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/core/CommandContext/PrefixContext.ts

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@
1818
import type BaseCommand from '#src/core/BaseCommand.js';
1919
import Context from '#src/core/CommandContext/Context.js';
2020
import Logger from '#src/utils/Logger.js';
21-
import {
22-
extractUserId,
23-
extractChannelId,
24-
extractRoleId,
25-
} from '#src/utils/Utils.js';
21+
import { extractUserId, extractChannelId, extractRoleId } from '#src/utils/Utils.js';
2622
import {
2723
type APIApplicationCommandBasicOption,
2824
type APIModalInteractionResponseCallbackData,
@@ -71,10 +67,7 @@ export default class PrefixContext extends Context<{
7167
// Split arguments with quote handling
7268
const commandOptions = new Map(
7369
// eslint-disable-next-line @typescript-eslint/no-unused-vars
74-
Object.entries(command.options).map(([_i, option]) => [
75-
option.name,
76-
option,
77-
]),
70+
Object.entries(command.options).map(([_i, option]) => [option.name, option]),
7871
);
7972

8073
// Store parsed arguments with resolved values
@@ -88,15 +81,13 @@ export default class PrefixContext extends Context<{
8881
private parseArguments(
8982
rawArgs: string[],
9083
definedOpts: Map<string, APIApplicationCommandBasicOption>,
91-
):
92-
| Collection<
93-
string,
94-
{
95-
value: string | number | boolean | null;
96-
type: ApplicationCommandOptionType;
97-
}
98-
>
99-
| undefined {
84+
): Collection<
85+
string,
86+
{
87+
value: string | number | boolean | null;
88+
type: ApplicationCommandOptionType;
89+
}
90+
> | null {
10091
const args = new Collection<
10192
string,
10293
{
@@ -114,21 +105,21 @@ export default class PrefixContext extends Context<{
114105
if (!option) {
115106
this.argumentValidationPassed = false;
116107
Logger.error(`Unknown option: ${name}`);
117-
return;
108+
return null;
118109
}
119110

120111
if (!value && option.required) {
121112
this.argumentValidationPassed = false;
122113
Logger.error(`Missing required option: ${option.name}`);
123-
return;
114+
return null;
124115
}
125116

126117
if (value) {
127118
const parsed = this.processArg(value, option.type);
128119
if (parsed === null) {
129120
this.argumentValidationPassed = false;
130121
Logger.error(`Invalid value for ${name}`);
131-
return;
122+
return null;
132123
}
133124
args.set(option.name, { value: parsed, type: option.type });
134125
definedOpts.delete(option.name);
@@ -146,21 +137,21 @@ export default class PrefixContext extends Context<{
146137
if (!option) {
147138
this.argumentValidationPassed = false;
148139
Logger.error(`Unknown option: ${value}`);
149-
return;
140+
return null;
150141
}
151142

152143
if (!value && option.required) {
153144
this.argumentValidationPassed = false;
154145
Logger.error(`Missing required option: ${option.name}`);
155-
return;
146+
return null;
156147
}
157148

158149
if (value) {
159150
const parsed = this.processArg(value, option.type);
160151
if (parsed === null) {
161152
this.argumentValidationPassed = false;
162153
Logger.error(`Invalid value for ${value}`);
163-
return;
154+
return null;
164155
}
165156
args.set(option.name, { value: parsed, type: option.type });
166157
}
@@ -205,9 +196,7 @@ export default class PrefixContext extends Context<{
205196

206197
public async reply(data: string | MessageReplyOptions) {
207198
this.lastReply = await this.interaction.reply(
208-
typeof data === 'string'
209-
? { content: data }
210-
: { ...data, content: data.content ?? '' },
199+
typeof data === 'string' ? { content: data } : { ...data, content: data.content ?? '' },
211200
);
212201
return this.lastReply;
213202
}
@@ -227,18 +216,16 @@ export default class PrefixContext extends Context<{
227216
public async editReply(data: string | MessageEditOptions) {
228217
return (
229218
(await this.lastReply?.edit(
230-
typeof data === 'string'
231-
? { content: data }
232-
: { ...data, content: data.content ?? '' },
219+
typeof data === 'string' ? { content: data } : { ...data, content: data.content ?? '' },
233220
)) ?? null
234221
);
235222
}
236223

237224
public async showModal(
238225
modal:
239-
| JSONEncodable<APIModalInteractionResponseCallbackData>
240-
| ModalComponentData
241-
| APIModalInteractionResponseCallbackData,
226+
| JSONEncodable<APIModalInteractionResponseCallbackData>
227+
| ModalComponentData
228+
| APIModalInteractionResponseCallbackData,
242229
) {
243230
const reply = await this.reply({
244231
content: 'Click button to enter data.',
@@ -254,8 +241,7 @@ export default class PrefixContext extends Context<{
254241

255242
const collector = reply?.createMessageComponentCollector({
256243
componentType: ComponentType.Button,
257-
filter: (i) =>
258-
i.customId === 'openForm' && i.user.id === this.interaction.author.id,
244+
filter: (i) => i.customId === 'openForm' && i.user.id === this.interaction.author.id,
259245
idle: 60000,
260246
});
261247

src/events/messageCreate.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ export default class MessageCreate extends BaseEventListener<'messageCreate'> {
6262

6363
private async handlePrefixCommand(message: Message): Promise<void> {
6464
const userData = await fetchUserData(message.author.id);
65-
if (!userData?.acceptedRules) return await showRulesScreening(message, userData);
65+
if (!userData?.acceptedRules) {
66+
await showRulesScreening(message, userData);
67+
return;
68+
}
6669

6770
const { command, prefixArgs } = resolveCommand(message);
6871
if (!command) return;

src/managers/AntiSpamManager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default class AntiSpamManager {
4343
});
4444
}
4545

46-
public async handleMessage(message: Message): Promise<UserMessageInfo | undefined> {
46+
public async handleMessage(message: Message): Promise<UserMessageInfo | null> {
4747
const userId = message.author.id;
4848
const currentTime = Date.now();
4949
const userInfo = await this.getUserInfo(userId);
@@ -60,6 +60,7 @@ export default class AntiSpamManager {
6060
}
6161

6262
this.setUserInfo(userId, { ...userInfo, lastMessage: currentTime });
63+
return null;
6364
}
6465

6566
private async getUserInfo(userId: string): Promise<UserMessageInfo> {

src/managers/HubLogManager.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@ export default class HubLogManager {
135135
}
136136

137137
async removeRoleId(type: RoleIdLogConfigs) {
138-
if (!this.config[type]) return await this.resetLog(type);
138+
if (!this.config[type]) {
139+
await this.resetLog(type);
140+
return;
141+
}
139142

140143
await this.updateLogConfig({
141144
[type]: { set: { channelId: this.config[type].channelId } },

src/services/MessageProcessor.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ export class MessageProcessor {
5151
const { hub, hubConnections, connection } = hubData;
5252

5353
const userData = await fetchUserData(message.author.id);
54-
if (!userData?.acceptedRules) return await showRulesScreening(message, userData);
54+
if (!userData?.acceptedRules) {
55+
await showRulesScreening(message, userData);
56+
return;
57+
}
5558

5659
const attachmentURL = await this.broadcastService.resolveAttachmentURL(message);
5760

src/utils/CommandUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function parseArgs(input: string): string[] {
8989
// Process matches to handle key-value pairs with quoted values
9090
return matches.map((match) => {
9191
// Check if the match is a key-value pair with a quoted value
92-
if (/=.+/.test(match)) {
92+
if (/[=].+/.test(match)) {
9393
const [key, value] = match.split('=');
9494
// Remove surrounding quotes from the value if present
9595
const cleanedValue = value.replace(quoteRegex, '');

0 commit comments

Comments
 (0)