Skip to content

Commit

Permalink
chore: Add support for Slash command args
Browse files Browse the repository at this point in the history
  • Loading branch information
PartMan7 committed Oct 30, 2024
1 parent c2b7d3c commit 49d2c8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/discord/loaders/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export async function loadCommands(): Promise<void> {
const { command }: { command: DiscCommand } = await import(requirePath);
[command.name, ...(command.aliases ?? [])].forEach((commandName, isAlias) => {
const slash = new SlashCommandBuilder().setName(commandName).setDescription(command.desc);
if (command.flags.serverOnly) slash.setDMPermission(false);
if (command.flags?.serverOnly) slash.setDMPermission(false);
if (command.args) command.args(slash);

DiscCommands[commandName] = {
...command,
Expand Down
6 changes: 4 additions & 2 deletions src/types/chat.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import type { Perms } from '@/types/perms';
import { HTMLopts } from 'ps-client/classes/common';
import type { HTMLopts } from 'ps-client/classes/common';

import type { SlashCommandBuilder } from 'discord.js';

export type PSCommandContext = {
/**
Expand Down Expand Up @@ -159,6 +161,6 @@ export type DiscCommand = {
aliases?: string[];
perms?: 'admin' | ((interaction: DiscInteraction) => boolean);
servers?: string[];
args?: null; // TODO
args?: (slash: SlashCommandBuilder) => void;
run(interaction: DiscInteraction): Promise<any>;
};

0 comments on commit 49d2c8c

Please sign in to comment.