From 7e291590117c3d9c5c50914fe821f06afee75754 Mon Sep 17 00:00:00 2001 From: Peter-MJ-Parker <34216187+Peter-MJ-Parker@users.noreply.github.com> Date: Sat, 20 Jul 2024 20:35:29 -0500 Subject: [PATCH] edit: catch up website with package --- packages/publisher/index.mdx | 46 +++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/packages/publisher/index.mdx b/packages/publisher/index.mdx index d4bf5d7..b71d023 100644 --- a/packages/publisher/index.mdx +++ b/packages/publisher/index.mdx @@ -13,7 +13,7 @@ import { makeDependencies } from '@sern/handler'; import { Publisher } from '@sern/publisher'; await makeDependencies(({ add }) => { - add('publisher', new Publisher()); + add('publisher', (deps) => new Publisher(deps['@sern/modules'], deps['@sern/emitter'], deps['@sern/logger'])); }); ``` ## Implicits @@ -36,17 +36,23 @@ Each command file can have an extra plugin `publishConfig` that follows `ValidPu ## Config ```ts +enum IntegrationContextType { + GUILD = 0, + BOT_DM = 1, + PRIVATE_CHANNEL = 2 +} + +type Contexts = IntegrationContextType | 0 | 1 | 2; + type ValidMemberPermissions = - | typeof PermissionFlagBits //discord.js enum - | typeof PermissionFlagBits[] //array of discord.js enum - | string //must be a stringified number - | bigint + | typeof PermissionFlagsBits //discord.js enum + | Array interface PublishConfig { guildIds?: string[]; defaultMemberPermissions?: ValidMemberPermissions; - integrationTypes?: Array<'Guild'|'User'> - contexts: number[] + integrationTypes?: Array<'Guild'|'User'>; + contexts?: Array; } type ValidPublishOptions = | PublishConfig @@ -96,7 +102,7 @@ export default commandModule( { guildIds: ["889026545715400705"] }) ], - description: `hello worl`, + description: `hello world`, execute: (ctx) => { ctx.reply('pong') } @@ -104,3 +110,27 @@ export default commandModule( { ``` +### Explanation of each property in the plugin + +:::tip +Not everyone likes to look at Discords Docs, so here you go +::: + +- `guildIds`: Commands will be published to guilds specified. + - Can have more than one guild id to publish certain commands in + - These commands cannot be used in dms. + +- `defaultMemberPermissions`: Only members with specified permissions can view the command + - If you specify more than one, all perms are required! + +- `integrationTypes`: able to specify guild install or user install commands + - 'Guild': Command is only able to be used in guilds + - 'User': Command can be installed to a users profile to be used everywhere (with limitations) + - Guilds with less than 200 members, developer can specify if the command should be invisible to others (ephemeral) + - Guild with >= 200 members, commands will be forced to be invisible by the Discord API. + +- `contexts`: specify where the user installed commands can be used. + - 0: Only available to be used by the user in GUILDS. + - 1: Only available in Bot dms. + - 2: Any private channel, such as a group dm outside of bots dms. + - Also able to use IntegrationContextType enum from `@sern/publisher` if you don't want to use numbers.