Skip to content

Commit 703e69e

Browse files
committed
Move some utils to #common/general
1 parent 73791e7 commit 703e69e

File tree

8 files changed

+10
-16
lines changed

8 files changed

+10
-16
lines changed

backend/src/common/discord/permissions.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { requireExhaustiveSwitch } from "#common/types.ts";
21
import { bot } from "#discord/index.ts";
32
import { type AnyGuildChannel, ChannelTypes, GuildMemberFlags, Member, Permissions, Role } from "oceanic.js";
43

@@ -62,7 +61,7 @@ export function canWriteInChannel(channel: AnyGuildChannel, member: Member): boo
6261
return false;
6362
}
6463

65-
requireExhaustiveSwitch(channel);
64+
(channel satisfies never);
6665

6766
return false;
6867
}

backend/src/common/discord/testing/mockMember.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/explicit-function-return-type */
22

33

4-
import { todo } from "#common/errors.ts";
4+
import { todo } from "#common/general.ts";
55
import { bot } from "#discord/index.ts";
66
import { Base, Permission, type Member } from "oceanic.js";
77

backend/src/common/errors.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
// NOTE: not needed in ES2025
12
export function* mapIterable<I, O>(iterable: Iterable<I>, transformer: (value: I) => O): Generator<O> {
23
for (const value of iterable)
34
yield transformer(value);
45
}
6+
7+
export function todo(): never {
8+
throw new Error("Function not implemented");
9+
}

backend/src/common/types.ts

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

backend/src/plugin/core/commandEngine/handler/slashHandler.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { debugFormatPermissionContext } from "#common/discord/debugFormat.ts";
22
import { moduleLogger } from "#common/logger/index.ts";
3-
import { requireExhaustiveSwitch } from "#common/types.ts";
43
import { onBotInit } from "#discord/extensionPoints.ts";
54
import { bot } from "#discord/index.ts";
65
import { CACHE_PATH } from "#environment.ts";
@@ -177,7 +176,7 @@ function mapOptionType(type: OptionType) {
177176
return ApplicationCommandOptionTypes.STRING;
178177
}
179178

180-
requireExhaustiveSwitch(type);
179+
(type satisfies never);
181180
}
182181

183182
class SlashContext implements CommandContext {

backend/src/plugin/core/commandEngine/safeArgs.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { isSnowflake } from "#common/snowflake.ts";
2-
import { requireExhaustiveSwitch } from "#common/types.ts";
32
import { INTERNAL_TYPE_INTEGRITY } from "#environment.ts";
43
import { OptionType, type AnyArgsValue, type AnyArgsValueItem, type Option } from "#plugin/core/public/command.ts";
54

@@ -162,7 +161,7 @@ function validateType(type: OptionType, value: unknown): void {
162161

163162
break;
164163
default:
165-
requireExhaustiveSwitch(type);
164+
(type satisfies never);
166165
break;
167166
}
168167
}

backend/src/plugin/core/configSync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { debugFormatGuildByID } from "#common/discord/debugFormat.ts";
2-
import { mapIterable } from "#common/iterators.ts";
2+
import { mapIterable } from "#common/general.ts";
33
import { moduleLogger } from "#common/logger/index.ts";
44
import { getPlugin } from "#loader/index.ts";
55
import { CoreConfig } from "#plugin/core/config.ts";

0 commit comments

Comments
 (0)