Skip to content

Commit 43e0c20

Browse files
Fix npm test issues
1 parent 0f19cfb commit 43e0c20

File tree

8 files changed

+29
-24
lines changed

8 files changed

+29
-24
lines changed

package-lock.json

Lines changed: 4 additions & 4 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
@@ -30,7 +30,7 @@
3030
"eslint-plugin-sonarjs": "0.23.0",
3131
"eslint-plugin-unicorn": "50.0.1",
3232
"pino-pretty": "10.3.1",
33-
"prettier": "3.1.1",
33+
"prettier": "3.7.4",
3434
"shx": "0.3.4",
3535
"typescript": "5.3.3"
3636
},

src/commands/carsized/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default session;
2929

3030
export const compareCarsUi = async (
3131
context: Context,
32-
interaction: Interaction
32+
interaction: Interaction,
3333
) => {
3434
// "perspective" was wrongly spelled "prospective" initially
3535
// Use new spelling while supporting older sessions

src/commands/settings/index.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import assert from "node:assert";
66
import { SupportedChannelTypes } from "../../creators";
77
import discord, { registerCommand } from "../../shared/discord";
88
import Environment from "../../shared/environment";
9+
import * as observability from "../../shared/observability";
910
import onCreators, { Subcommand as CreatorsSubcommand } from "./creators";
1011
import { Option as ChannelMentionRoleOption } from "./creators/channel-mention-role";
1112
import * as database from "./database";
@@ -83,13 +84,19 @@ registerCommand(json, onCommand);
8384
// endregion
8485

8586
// region Initialize Guilds
86-
discord.on(Events.ClientReady, async ({ guilds: guildManager }) => {
87+
const logger = observability.logger(module);
88+
89+
discord.on(Events.ClientReady, ({ guilds: guildManager }) => {
8790
const guilds = guildManager.valueOf();
8891
const guildIds = [...guilds.keys()];
89-
await database.initializeGuilds(guildIds);
92+
database.initializeGuilds(guildIds).catch((error) => {
93+
logger.error(error, "SETTINGS_CLIENT_READY_ERROR");
94+
});
9095
});
9196

92-
discord.on(Events.GuildCreate, async ({ id: guildId }) => {
93-
await database.initializeGuilds([guildId]);
97+
discord.on(Events.GuildCreate, ({ id: guildId }) => {
98+
database.initializeGuilds([guildId]).catch((error) => {
99+
logger.error(error, "SETTINGS_GUILD_CREATE_ERROR");
100+
});
94101
});
95102
// endregion

src/commands/surveys/ui/results/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export const getAnswersPng = async (context: Context) => {
105105
export const resultsUi = async (
106106
context: Context,
107107
interaction: Interaction,
108-
files: BaseMessageOptions["files"] = []
108+
files: BaseMessageOptions["files"] = [],
109109
) => {
110110
const { survey } = context;
111111
const { message } = interaction;

src/creators/subscribe/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ export const subscribe = async ({
9696

9797
webhookId = webhook.id;
9898
webhookToken = webhook.token;
99-
assert(webhookToken !== null);
10099
} else {
101100
webhookId = creatorChannel.webhookId;
102101
webhookToken = creatorChannel.webhookToken;
@@ -108,7 +107,6 @@ export const subscribe = async ({
108107

109108
webhookId = webhook.id;
110109
webhookToken = webhook.token;
111-
assert(webhookToken !== null);
112110
}
113111

114112
creatorChannel = {

src/shared/discord.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ const commands = new Map<string, Command>();
125125
export const registerCommand = (
126126
json: CommandJson,
127127
onCommand: OnCommand,
128-
onAutocomplete?: OnAutocomplete
128+
onAutocomplete?: OnAutocomplete,
129129
) =>
130130
void commands.set(json.name, {
131131
json,

src/shared/redis.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ declare module "ioredis" {
9191
lockKey: string, // KEYS[1]
9292
lockToken: string, // ARGV[1]
9393
expireInMilliseconds: number, // ARGV[2]
94-
callback?: Callback<string>
94+
callback?: Callback<string>,
9595
): Result<number, Context>;
9696
unlock(
9797
lockKey: string, // KEYS[1]
9898
lockToken: string, // ARGV[1]
99-
callback?: Callback<string>
99+
callback?: Callback<string>,
100100
): Result<number, Context>;
101101
}
102102
}
@@ -114,7 +114,7 @@ const tryLock = async (lockKey: string, expireInMilliseconds: number) => {
114114
"PX",
115115
expireInMilliseconds,
116116
"NX",
117-
"GET"
117+
"GET",
118118
);
119119
} catch (error) {
120120
logger.error(error, "TRY_LOCK_ERROR");
@@ -150,7 +150,7 @@ const lock = async (key: string, expireInMilliseconds: number) => {
150150

151151
const extendLock = async (
152152
{ key, token }: Lock,
153-
expireInMilliseconds: number
153+
expireInMilliseconds: number,
154154
) => {
155155
try {
156156
await redis.extendLock(key, token, expireInMilliseconds);
@@ -170,7 +170,7 @@ const unlock = async ({ key, token }: Lock) => {
170170
const useLock = async <T>(
171171
key: string,
172172
callback: (lock: Lock) => NonNullable<T> | Promise<NonNullable<T>>,
173-
expireInMilliseconds = 1000
173+
expireInMilliseconds = 1000,
174174
) => {
175175
const lockObject = await lock(key, expireInMilliseconds);
176176

@@ -232,7 +232,7 @@ declare module "ioredis" {
232232
lockToken: string, // ARGV[1]
233233
value: string, // ARGV[2]
234234
expireInMilliseconds: number, // ARGV[3]
235-
callback?: Callback<string>
235+
callback?: Callback<string>,
236236
): Result<null | string, Context>;
237237
}
238238
}
@@ -241,15 +241,15 @@ const atomicSet = async (
241241
lock: Lock,
242242
key: string,
243243
value: string,
244-
expireInMilliseconds: number
244+
expireInMilliseconds: number,
245245
) => {
246246
try {
247247
await redis.atomicSet(
248248
lock.key,
249249
key,
250250
lock.token,
251251
value,
252-
expireInMilliseconds
252+
expireInMilliseconds,
253253
);
254254
} catch (error) {
255255
logger.error(error, "ATOMIC_SET_ERROR");
@@ -273,7 +273,7 @@ export const computeIfAbsent = async <T>(
273273
key: string,
274274
callback: () => Promise<NonNullable<T>>,
275275
cacheExpirationInMilliseconds = Number.MAX_VALUE,
276-
lockExpirationInMilliseconds = 1000
276+
lockExpirationInMilliseconds = 1000,
277277
) => {
278278
let value = await get<NonNullable<T>>(key);
279279

@@ -291,7 +291,7 @@ export const computeIfAbsent = async <T>(
291291

292292
return value;
293293
},
294-
lockExpirationInMilliseconds
294+
lockExpirationInMilliseconds,
295295
);
296296
}
297297

0 commit comments

Comments
 (0)