Skip to content

Conditional deployment slash commands#17

Closed
Ntalcme wants to merge 5 commits into
mainfrom
conditional-deployment-slash-commands
Closed

Conditional deployment slash commands#17
Ntalcme wants to merge 5 commits into
mainfrom
conditional-deployment-slash-commands

Conversation

@Ntalcme

@Ntalcme Ntalcme commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Ntalcme added 5 commits June 6, 2026 00:55
* fix(handlers): wrap dynamic import in try/catch to skip broken files #5

* Fix cacth error #5
* feat(types): Add CommandAuthorization & CommandScope #12

* feat(types): add CommandRequirements, CommandValidation and permission types #12

* feat(lib): add command requirements checker #12

* feat(lib): add error container builder and permission error messages #12

* feat(components): add ephemeral option to Container.build() #12

* fix(client): wrap event listeners to handle async execute #12

* fix(handlers): remove unused imports #12

* feat(events): check command requirements before execution #12

* chore(config): add MAIN_GUILD_ID, OWNER_ID and PRIVILEGED_IDS to env.example #12

* Fix name #12
@Ntalcme Ntalcme added this to the v0.2.0 milestone Jun 6, 2026
@Ntalcme Ntalcme self-assigned this Jun 6, 2026
Copilot AI review requested due to automatic review settings June 6, 2026 18:24
@Ntalcme Ntalcme linked an issue Jun 6, 2026 that may be closed by this pull request
@Ntalcme Ntalcme closed this Jun 6, 2026
@Ntalcme Ntalcme deleted the conditional-deployment-slash-commands branch June 6, 2026 18:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a command “requirements” layer (scope + authorization) and applies it at runtime for both slash and new prefix commands, while also updating the deployment script to deploy “main guild only” slash commands differently in production.

Changes:

  • Add command requirement types + validation helpers (scope/authorization) and enforce them in interaction/message handlers.
  • Add prefix-command infrastructure (registry, loader, message-create event) and a prefix ping command.
  • Update command deployment to split production deployment into main-guild vs global commands, and update env vars accordingly.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/types/command.ts Adds requirements/permission types and extends SlashCommand/PrefixCommand shapes.
src/registries/prefix-registry.ts Introduces shared prefix command registry keyed by name and aliases.
src/lib/errors.ts Adds helper to build a permissions error container reply.
src/lib/components/container.ts Adds ephemeral option to Container.build(); refines discord.js imports.
src/lib/command-requirements.ts Adds scope/authorization requirement checking utilities.
src/lang/ping.ts Adds “calculating…” message and exports pingDescription.
src/lang/index.ts Exports pingDescription from the language index.
src/lang/errors.ts Adds localized permissions error message builder.
src/handlers/slash-handler.ts Simplifies loader setup (relies on shared base loader).
src/handlers/prefix-handler.ts Adds prefix command loader + runtime type guard + registry population.
src/handlers/event-handler.ts Simplifies loader setup (relies on shared base loader).
src/handlers/base-loader.ts Adds guarded dynamic import with error logging and skip behavior.
src/events/message-create.ts Adds prefix command dispatch + requirements enforcement.
src/events/interaction-create.ts Enforces requirements for slash commands and replies ephemerally on failure.
src/deploy-commands.ts Splits production deploy into main-guild-only vs global commands; renames dev guild env var.
src/commands/slash/ping.ts Uses pingDescription from lang exports.
src/commands/prefix/ping.ts Adds prefix ping implementation using components v2 rendering.
src/client/crownutils-client.ts Enables message intents, loads prefix commands, and wraps event execution in void.
.env.example Updates env var names and adds IDs used for authorization/scope.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/deploy-commands.ts
Comment on lines +16 to 18
if (!isProduction && !testGuildId) {
throw new Error('Missing DISCORD_GUILD_ID for development deployment');
}
Comment on lines +42 to +46
userId === process.env.OWNER_ID
? 'owner'
: process.env.PRIVILEGED_IDS?.split(',').filter(Boolean).includes(userId)
? 'privileged'
: 'public';
Comment on lines +10 to +13
const candidate = obj as Record<string, unknown>;
if (typeof candidate.name !== 'string') {
return false;
}
Comment on lines +29 to +34
prefixCommands.set(command.name, command);
if (command.aliases) {
for (const alias of command.aliases) {
prefixCommands.set(alias, command);
}
}
Comment on lines +50 to +52
this.discord.once(event.name, (...args) => {
void event.execute(...args);
});
Comment on lines +54 to +56
this.discord.on(event.name, (...args) => {
void event.execute(...args);
});
Comment on lines +68 to +71
private async loadPrefixCommands(): Promise<void> {
await loadPrefixCommands();
logger.info(`Loaded ${prefixCommands.size} prefix command(s).`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add conditional deployment for slash commands

2 participants