fix: dont run interaction command when there's no run

This commit is contained in:
Jozef Steinhübl 2023-08-24 10:24:31 +02:00
parent 2a3bf141d9
commit 75003af03c
3 changed files with 5 additions and 5 deletions

View file

@ -1,11 +1,11 @@
import { defineCommand } from "../loaders/commands.ts"; import { defineCommand } from "../loaders/commands.ts";
import { COMMIT_HASH, PRODUCTION } from "../constants.ts"; import { COMMIT_HASH, PRODUCTION } from "../constants.ts";
import { CommandContext } from "../structs/context/CommandContext.ts"; import { InteractionCommandContext } from "../structs/context/CommandContext.ts";
export default defineCommand({ export default defineCommand({
name: "version", name: "version",
options: [], options: [],
run: (context: CommandContext) => { run: (context: InteractionCommandContext) => {
context.interaction.reply({ context.interaction.reply({
content: [ content: [
`[git-bun-discord-bot-${COMMIT_HASH}](<https://github.com/xHyroM/bun-discord-bot/tree/${COMMIT_HASH}>) ${!PRODUCTION ? "(dev)" : ""}`, `[git-bun-discord-bot-${COMMIT_HASH}](<https://github.com/xHyroM/bun-discord-bot/tree/${COMMIT_HASH}>) ${!PRODUCTION ? "(dev)" : ""}`,

View file

@ -15,7 +15,7 @@ defineListener({
function handleCommand(interaction: ChatInputCommandInteraction) { function handleCommand(interaction: ChatInputCommandInteraction) {
const command = COMMANDS.get(interaction.commandName); const command = COMMANDS.get(interaction.commandName);
if (!command) { if (!command || !command.run) {
interaction.reply({ interaction.reply({
content: "Hmm.. Invalid command :P", content: "Hmm.. Invalid command :P",
ephemeral: true, ephemeral: true,

View file

@ -11,10 +11,10 @@ interface StringOption extends SlashCommandStringOption {
export interface Command { export interface Command {
name: string; name: string;
options: Option[]; options: Option[];
run: ( run?: (
context: CommandContext<true> context: CommandContext<true>
) => any; ) => any;
runMessage: ( runMessage?: (
context: CommandContext<false> context: CommandContext<false>
) => any; ) => any;
} }