chore: update publish.ts to use backwards compatible service (#96)

This commit is contained in:
Jacob Nguyen
2023-08-11 11:44:39 -05:00
committed by GitHub
parent 74088031f5
commit 502deeff30

View File

@@ -23,6 +23,7 @@ import {
controller,
SernOptionsData,
SlashCommand,
Service,
} from "@sern/handler";
import {
ApplicationCommandData,
@@ -30,7 +31,6 @@ import {
ApplicationCommandOptionType,
PermissionResolvable,
} from "discord.js";
import { useContainer } from "../index.js";
export const CommandTypeRaw = {
[CommandType.Both]: ApplicationCommandType.ChatInput,
@@ -48,7 +48,13 @@ export function publish<
>(options?: PublishOptions) {
return CommandInitPlugin<T>(async ({ module }) => {
// Users need to provide their own useContainer function.
const [client] = useContainer("@sern/client");
let client;
try {
client = (await import('@sern/handler')).Service('@sern/client')
} catch {
const { useContainer } = await import('../index.js')
client = useContainer("@sern/client")[0];
}
const defaultOptions = {
guildIds: [],
dmPermission: undefined,