Subcommands Not Working

Hello, I am trying to make my subcommands "tidy" by using separate files, but the functions aren't even running. server.command.ts
import { Subcommand } from "@sapphire/plugin-subcommands";
import { ApplyOptions } from "@sapphire/decorators";
import { basename, dirname, parse } from "path";
import { PermissionFlagsBits } from "discord.js";
import { Time } from "@sapphire/time-utilities";
import { BucketScope } from "@sapphire/framework";

// Subcommand imports
import { ServerAddSubcommand } from "./server/_server.add.subcommand";
import { ServerRemoveSubcommand } from "./server/_server.remove.subcommand";
import { ServerEditSubcommand } from "./server/_server.edit.subcommand";
import { ServerViewSubcommand } from "./server/_server.view.subcommand";

@ApplyOptions<Subcommand.Options>({
name: parse(__filename).name.split(".")[0],
fullCategory: [basename(dirname(__filename))],
description: "Manage the rust servers in the database",
preconditions: ["OwnerOnly"],
requiredClientPermissions: [
PermissionFlagsBits.SendMessages,
PermissionFlagsBits.EmbedLinks,
],
cooldownDelay: Time.Second * 10,
cooldownLimit: 2,
cooldownScope: BucketScope.User,
cooldownFilteredUsers: process.env.DISCORD_APP_OWNERS.split(","),
runIn: ["GUILD_ANY", "DM"],
enabled: true,
subcommands: [
{
name: "add",
chatInputRun: "chatInputAdd",
},
{
name: "remove",
chatInputRun: "chatInputRemove",
},
{
name: "edit",
chatInputRun: "chatInputEdit",
},
{
name: "view",
chatInputRun: "chatInputView",
},
],
})
export class ServerCommands extends Subcommand {
/*
This method will be called to register the command as a chat input command.
*/
public override registerApplicationCommands(registry: Subcommand.Registry) {
registry.registerChatInputCommand((command) => {
command
.setName(this.name)
.setDescription(this.description)
.addSubcommand((command) =>
command
.setName("add")
.setDescription("Add a rust server to the database")
)
.addSubcommand((command) =>
command
.setName("remove")
.setDescription("Remove a rust server from the database")
.addStringOption((option) =>
option
.setName("server")
.setDescription("The server to remove")
.setRequired(true)
.setAutocomplete(true)
)
)
.addSubcommand((command) =>
command
.setName("edit")
.setDescription("Edit a rust server in the database")
.addStringOption((option) =>
option
.setName("server")
.setDescription("The server to edit")
.setRequired(true)
.setAutocomplete(true)
)
)
.addSubcommand((command) =>
command
.setName("view")
.setDescription("View a rust server in the database")
.addStringOption((option) =>
option
.setName("server")
.setDescription("The server to view")
.setRequired(false)
.setAutocomplete(true)
)
);
});
}

public chatInputAdd(interaction: Subcommand.ChatInputCommandInteraction) {
console.log("test");
return ServerAddSubcommand.chatInputRun(interaction);
}

public chatInputRemove(interaction: Subcommand.ChatInputCommandInteraction) {
return ServerRemoveSubcommand.chatInputRun(interaction);
}

public chatInputEdit(interaction: Subcommand.ChatInputCommandInteraction) {
return ServerEditSubcommand.chatInputRun(interaction);
}

public chatInputView(interaction: Subcommand.ChatInputCommandInteraction) {
return ServerViewSubcommand.chatInputRun(interaction);
}
}
import { Subcommand } from "@sapphire/plugin-subcommands";
import { ApplyOptions } from "@sapphire/decorators";
import { basename, dirname, parse } from "path";
import { PermissionFlagsBits } from "discord.js";
import { Time } from "@sapphire/time-utilities";
import { BucketScope } from "@sapphire/framework";

// Subcommand imports
import { ServerAddSubcommand } from "./server/_server.add.subcommand";
import { ServerRemoveSubcommand } from "./server/_server.remove.subcommand";
import { ServerEditSubcommand } from "./server/_server.edit.subcommand";
import { ServerViewSubcommand } from "./server/_server.view.subcommand";

@ApplyOptions<Subcommand.Options>({
name: parse(__filename).name.split(".")[0],
fullCategory: [basename(dirname(__filename))],
description: "Manage the rust servers in the database",
preconditions: ["OwnerOnly"],
requiredClientPermissions: [
PermissionFlagsBits.SendMessages,
PermissionFlagsBits.EmbedLinks,
],
cooldownDelay: Time.Second * 10,
cooldownLimit: 2,
cooldownScope: BucketScope.User,
cooldownFilteredUsers: process.env.DISCORD_APP_OWNERS.split(","),
runIn: ["GUILD_ANY", "DM"],
enabled: true,
subcommands: [
{
name: "add",
chatInputRun: "chatInputAdd",
},
{
name: "remove",
chatInputRun: "chatInputRemove",
},
{
name: "edit",
chatInputRun: "chatInputEdit",
},
{
name: "view",
chatInputRun: "chatInputView",
},
],
})
export class ServerCommands extends Subcommand {
/*
This method will be called to register the command as a chat input command.
*/
public override registerApplicationCommands(registry: Subcommand.Registry) {
registry.registerChatInputCommand((command) => {
command
.setName(this.name)
.setDescription(this.description)
.addSubcommand((command) =>
command
.setName("add")
.setDescription("Add a rust server to the database")
)
.addSubcommand((command) =>
command
.setName("remove")
.setDescription("Remove a rust server from the database")
.addStringOption((option) =>
option
.setName("server")
.setDescription("The server to remove")
.setRequired(true)
.setAutocomplete(true)
)
)
.addSubcommand((command) =>
command
.setName("edit")
.setDescription("Edit a rust server in the database")
.addStringOption((option) =>
option
.setName("server")
.setDescription("The server to edit")
.setRequired(true)
.setAutocomplete(true)
)
)
.addSubcommand((command) =>
command
.setName("view")
.setDescription("View a rust server in the database")
.addStringOption((option) =>
option
.setName("server")
.setDescription("The server to view")
.setRequired(false)
.setAutocomplete(true)
)
);
});
}

public chatInputAdd(interaction: Subcommand.ChatInputCommandInteraction) {
console.log("test");
return ServerAddSubcommand.chatInputRun(interaction);
}

public chatInputRemove(interaction: Subcommand.ChatInputCommandInteraction) {
return ServerRemoveSubcommand.chatInputRun(interaction);
}

public chatInputEdit(interaction: Subcommand.ChatInputCommandInteraction) {
return ServerEditSubcommand.chatInputRun(interaction);
}

public chatInputView(interaction: Subcommand.ChatInputCommandInteraction) {
return ServerViewSubcommand.chatInputRun(interaction);
}
}
No description
Solution:
@Enrique I looked into the issue and I can run subcommands just fine. I created a PR with the changes I made https://github.com/b1nzeex/dvs-discord-bot-v2/pull/1 The notable ones are: - Reinstalling dependencies, part of updating to yarn v4 - Setting up the initial Prisma migration so the schema is created. You connect the database, so you need to make sure Prisma can actually interact with it. Without this the application should just crash at init anyway...
Jump to solution
70 Replies
b1nzee
b1nzeeOP•10mo ago
_server.add.subcommand.ts
import { Subcommand } from "@sapphire/plugin-subcommands";

export class ServerAddSubcommand {
public static chatInputRun(
interaction: Subcommand.ChatInputCommandInteraction
) {
return interaction.reply({ content: "Server Add Subcommand" });
}
}
import { Subcommand } from "@sapphire/plugin-subcommands";

export class ServerAddSubcommand {
public static chatInputRun(
interaction: Subcommand.ChatInputCommandInteraction
) {
return interaction.reply({ content: "Server Add Subcommand" });
}
}
To clarify, my console.log("test") doesn't execute Still experiencing this issue :pepeFeelsBadMan: @Helpers
Favna
Favna•10mo ago
The parent and subcommands get properly registered on the discord API? I suspect not because I don't see a return statement from the builder. Note the difference between command => command.stuff and command => { command.stuff } in JavaScript arrow functions. The latter would have to be command => { return command.stuff } or command => { command.stuff; return command } What is the parsed name of the parent command? Seeing as you dynamically compute it. FYI category is automatically computed by sapphire based on directory structure. For example src/commands/general/other/my command.ts has a full category of ['general', 'other']
vladdy
vladdy•10mo ago
(you shouldnt neeeed to return but i dont remember)
b1nzee
b1nzeeOP•10mo ago
The commands are registering properly, they appear in my slash command list But didn't know the category part, thank you for the useful information there
Favna
Favna•10mo ago
You 100% do, we've had people face that issue before.
b1nzee
b1nzeeOP•10mo ago
No description
Favna
Favna•10mo ago
You're using bulk overwrite mode? Sure that what you see isn't old registered data? Checking because you're not using idHints
vladdy
vladdy•10mo ago
i thought i fixed that
Favna
Favna•10mo ago
Well I may be wrong but it's easily checked. Ofc I can't from where I am but be my guest.
b1nzee
b1nzeeOP•10mo ago
im using bulkOverwrite, yeah and when I add return to the registry.registerChatInputCommand(), I get this error:
Property 'registerApplicationCommands' in type 'ServerCommands' is not assignable to the same property in base type 'Subcommand<Args, SubcommandOptions>'.
Type '(registry: ApplicationCommandRegistry) => ApplicationCommandRegistry' is not assignable to type '(registry: ApplicationCommandRegistry) => Awaitable<void>'.
Type 'ApplicationCommandRegistry' is not assignable to type 'Awaitable<void>'
Property 'registerApplicationCommands' in type 'ServerCommands' is not assignable to the same property in base type 'Subcommand<Args, SubcommandOptions>'.
Type '(registry: ApplicationCommandRegistry) => ApplicationCommandRegistry' is not assignable to type '(registry: ApplicationCommandRegistry) => Awaitable<void>'.
Type 'ApplicationCommandRegistry' is not assignable to type 'Awaitable<void>'
vladdy
vladdy•10mo ago
not there in the registerChatInputCommand call
b1nzee
b1nzeeOP•10mo ago
no error, but command still not running for reference btw, I'm not returning in my ping command either and that works
vladdy
vladdy•10mo ago
hmmm
Favna
Favna•10mo ago
This is where vladdy and I meant btw. That should be return command
No description
b1nzee
b1nzeeOP•10mo ago
thought so, thats where i tried just now
Favna
Favna•10mo ago
what's the result of parse(__filename).name.split(".")[0]? And your bot has those permissions you're requiring? Also you can enable the error listeners to see logging hold on
vladdy
vladdy•10mo ago
yeah the name can be sus
b1nzee
b1nzeeOP•10mo ago
return interaction.reply(parse(__filename).name.split(".")[0]);
return interaction.reply(parse(__filename).name.split(".")[0]);
Just did this in my ping command, it returns "ping" - so same should work for my server command and yeah, it has admin perms
Favna
Favna•10mo ago
loadSubcommandErrorListeners to true in client options And set logger.loglevel to LogLevel.Debug Excuse any typos I'm on mobile
vladdy
vladdy•10mo ago
mmm it might not tho, unless the ping cmd has the same name structure
Favna
Favna•10mo ago
But you're using TS so intellisense can correct for me You can add a console.log above the class definition in the same file. It'll get logged when the bot starts when the file is loaded. Adding to that
b1nzee
b1nzeeOP•10mo ago
no errors
[INFO] ApplicationCommandRegistries: Initializing...
[INFO] Test Monkey is online and ready!
[DEBUG] ApplicationCommandRegistry[server] Preparing to process 1 possible command registrations / updates...
[DEBUG] ApplicationCommandRegistry[server] Checking if command "server" is identical with global chat input command with id "1215064126544547890"
[DEBUG] ApplicationCommandRegistry[server] Registering id "1215064126544547890" to internal chat input map
[DEBUG] ApplicationCommandRegistry[server] Took 1ms to process differences via fast compute differences
[DEBUG] ApplicationCommandRegistry[server] Command "server" is identical to command "server" (1215064126544547890)
[DEBUG] ApplicationCommandRegistry[ping] Preparing to process 1 possible command registrations / updates...
[DEBUG] ApplicationCommandRegistry[ping] Checking if command "ping" is identical with global chat input command with id "1143509676277895168"
[DEBUG] ApplicationCommandRegistry[ping] Registering id "1143509676277895168" to internal chat input map
[DEBUG] ApplicationCommandRegistry[ping] Took 0ms to process differences via fast compute differences
[DEBUG] ApplicationCommandRegistry[ping] Command "ping" is identical to command "ping" (1143509676277895168)
[INFO] ApplicationCommandRegistries: Took 2ms to initialize.
[INFO] ApplicationCommandRegistries: Initializing...
[INFO] Test Monkey is online and ready!
[DEBUG] ApplicationCommandRegistry[server] Preparing to process 1 possible command registrations / updates...
[DEBUG] ApplicationCommandRegistry[server] Checking if command "server" is identical with global chat input command with id "1215064126544547890"
[DEBUG] ApplicationCommandRegistry[server] Registering id "1215064126544547890" to internal chat input map
[DEBUG] ApplicationCommandRegistry[server] Took 1ms to process differences via fast compute differences
[DEBUG] ApplicationCommandRegistry[server] Command "server" is identical to command "server" (1215064126544547890)
[DEBUG] ApplicationCommandRegistry[ping] Preparing to process 1 possible command registrations / updates...
[DEBUG] ApplicationCommandRegistry[ping] Checking if command "ping" is identical with global chat input command with id "1143509676277895168"
[DEBUG] ApplicationCommandRegistry[ping] Registering id "1143509676277895168" to internal chat input map
[DEBUG] ApplicationCommandRegistry[ping] Took 0ms to process differences via fast compute differences
[DEBUG] ApplicationCommandRegistry[ping] Command "ping" is identical to command "ping" (1143509676277895168)
[INFO] ApplicationCommandRegistries: Took 2ms to initialize.
Favna
Favna•10mo ago
You're not using bulk overwrite.. those logs are not that.
vladdy
vladdy•10mo ago
even then it shows the name is correct
b1nzee
b1nzeeOP•10mo ago
just did that, it logged "server" oh shit, im using "Overwrite" my bad
vladdy
vladdy•10mo ago
doesnt matter
Favna
Favna•10mo ago
It's a safety sanity check really because for all we know id/name comparison is borked (wouldn't be the first time lol)
vladdy
vladdy•10mo ago
we also use names
b1nzee
b1nzeeOP•10mo ago
i normally use bulk overwrite, must have overlooked it, but new logs:
[INFO] ApplicationCommandRegistries: Initializing...
[INFO] Test Monkey is online and ready!
[DEBUG] ApplicationCommandRegistries(BulkOverwrite) Overwriting global application commands, now at 2 commands
[DEBUG] ApplicationCommandRegistry[server] Registering id "1215064126544547890" to internal chat input map
[DEBUG] ApplicationCommandRegistry[ping] Registering id "1143509676277895168" to internal chat input map
[INFO] ApplicationCommandRegistries(BulkOverwrite) Successfully overwrote global application commands. The application now has 2 global commands
[INFO] ApplicationCommandRegistries: Took 444ms to initialize.
[INFO] ApplicationCommandRegistries: Initializing...
[INFO] Test Monkey is online and ready!
[DEBUG] ApplicationCommandRegistries(BulkOverwrite) Overwriting global application commands, now at 2 commands
[DEBUG] ApplicationCommandRegistry[server] Registering id "1215064126544547890" to internal chat input map
[DEBUG] ApplicationCommandRegistry[ping] Registering id "1143509676277895168" to internal chat input map
[INFO] ApplicationCommandRegistries(BulkOverwrite) Successfully overwrote global application commands. The application now has 2 global commands
[INFO] ApplicationCommandRegistries: Took 444ms to initialize.
Favna
Favna•10mo ago
Right and I guess it still doesn't work?
vladdy
vladdy•10mo ago
same ids so as i said thats not it
b1nzee
b1nzeeOP•10mo ago
yeah still just "Application Didnt Respond" with 0 error
Favna
Favna•10mo ago
Did you enable this option? Any logging when you use the command?
b1nzee
b1nzeeOP•10mo ago
i know sapphire doesn't typically "support" subcommands in separate files, but the console.log("test") should fire at least right? and yeah i enabled that
vladdy
vladdy•10mo ago
yes to your question which reminds me i found an oversight on our part, we run code only on constructor not onLoad but unrelated to this
b1nzee
b1nzeeOP•10mo ago
just to make sure im correct here too, this is my constructor for the SapphireClient
public constructor() {
super({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessageReactions,
IntentsBitField.Flags.MessageContent,
],
partials: [Partials.Message, Partials.Reaction, Partials.User],
presence: {
status: PresenceUpdateStatus.DoNotDisturb,
},
logger: {
// instance: new DvSLogger(),
level: LogLevel.Debug,
},
allowedMentions: {
parse: ["users", "roles"],
repliedUser: true,
},
loadSubcommandErrorListeners: true,
});
}
public constructor() {
super({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessageReactions,
IntentsBitField.Flags.MessageContent,
],
partials: [Partials.Message, Partials.Reaction, Partials.User],
presence: {
status: PresenceUpdateStatus.DoNotDisturb,
},
logger: {
// instance: new DvSLogger(),
level: LogLevel.Debug,
},
allowedMentions: {
parse: ["users", "roles"],
repliedUser: true,
},
loadSubcommandErrorListeners: true,
});
}
vladdy
vladdy•10mo ago
looks fine
Favna
Favna•10mo ago
Can you implement listeners for each of these events for chat input and see what that gives? https://github.com/sapphiredev/plugins/blob/main/packages/subcommands/src/lib/types/Events.ts You can just log dump a test or something in the listener. We just need to know if they get emitted at all for now.
GitHub
plugins/packages/subcommands/src/lib/types/Events.ts at main · sapp...
Plugins for the Sapphire Framework. Contribute to sapphiredev/plugins development by creating an account on GitHub.
b1nzee
b1nzeeOP•10mo ago
sure, gimme a few mins
Favna
Favna•10mo ago
That's lines 7-10 and line 18 btw Oh other than the test also log the name/event of the listener ofc. We need to be able to tell them apart
vladdy
vladdy•10mo ago
also if this is an open source project, feel free to link us, we can take a look then too
Favna
Favna•10mo ago
I need to go now. Hopefully vladdy can help you further otherwise I'm back in like 4ish hours
b1nzee
b1nzeeOP•10mo ago
alright, think I did the listeners correctly but still not getting an output chatInputSubcommandDenied.listener.ts
import { Listener, type UserError } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";
import { ChatInputSubcommandDeniedPayload } from "@sapphire/plugin-subcommands";

@ApplyOptions<Listener.Options>({
name: __filename.split(".")[0],
enabled: true,
})
export class ChatInputSubcommandDeniedListener extends Listener {
public run(error: UserError, payload: ChatInputSubcommandDeniedPayload) {
console.log("ChatInputSubcommandDeniedListener", error, payload);
}
}
import { Listener, type UserError } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";
import { ChatInputSubcommandDeniedPayload } from "@sapphire/plugin-subcommands";

@ApplyOptions<Listener.Options>({
name: __filename.split(".")[0],
enabled: true,
})
export class ChatInputSubcommandDeniedListener extends Listener {
public run(error: UserError, payload: ChatInputSubcommandDeniedPayload) {
console.log("ChatInputSubcommandDeniedListener", error, payload);
}
}
chatInputSubcommandRun.listener.ts
import { Listener } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";
import {
ChatInputCommandSubcommandMappingMethod,
ChatInputSubcommandRunPayload,
} from "@sapphire/plugin-subcommands";
import { ChatInputCommandInteraction } from "discord.js";

@ApplyOptions<Listener.Options>({
name: __filename.split(".")[0],
enabled: true,
})
export class ChatInputSubcommandRunListener extends Listener {
public run(
interaction: ChatInputCommandInteraction,
subcommand: ChatInputCommandSubcommandMappingMethod,
payload: ChatInputSubcommandRunPayload
) {
console.log("ChatInputSubcommandRunListener", payload);
}
}
import { Listener } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";
import {
ChatInputCommandSubcommandMappingMethod,
ChatInputSubcommandRunPayload,
} from "@sapphire/plugin-subcommands";
import { ChatInputCommandInteraction } from "discord.js";

@ApplyOptions<Listener.Options>({
name: __filename.split(".")[0],
enabled: true,
})
export class ChatInputSubcommandRunListener extends Listener {
public run(
interaction: ChatInputCommandInteraction,
subcommand: ChatInputCommandSubcommandMappingMethod,
payload: ChatInputSubcommandRunPayload
) {
console.log("ChatInputSubcommandRunListener", payload);
}
}
chatInputSubcommandSuccess.listener.ts
import { Listener } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";
import {
ChatInputCommandSubcommandMappingMethod,
ChatInputSubcommandRunPayload,
} from "@sapphire/plugin-subcommands";
import { ChatInputCommandInteraction } from "discord.js";

@ApplyOptions<Listener.Options>({
name: __filename.split(".")[0],
enabled: true,
})
export class ChatInputSubcommandSuccessListener extends Listener {
public run(
interaction: ChatInputCommandInteraction,
subcommand: ChatInputCommandSubcommandMappingMethod,
payload: ChatInputSubcommandRunPayload
) {
console.log("ChatInputSubcommandSuccessListener", payload);
}
}
import { Listener } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";
import {
ChatInputCommandSubcommandMappingMethod,
ChatInputSubcommandRunPayload,
} from "@sapphire/plugin-subcommands";
import { ChatInputCommandInteraction } from "discord.js";

@ApplyOptions<Listener.Options>({
name: __filename.split(".")[0],
enabled: true,
})
export class ChatInputSubcommandSuccessListener extends Listener {
public run(
interaction: ChatInputCommandInteraction,
subcommand: ChatInputCommandSubcommandMappingMethod,
payload: ChatInputSubcommandRunPayload
) {
console.log("ChatInputSubcommandSuccessListener", payload);
}
}
chatInputSubcommandError.listener.ts
import { Listener } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";
import { ChatInputSubcommandErrorPayload } from "@sapphire/plugin-subcommands";

@ApplyOptions<Listener.Options>({
name: __filename.split(".")[0],
enabled: true,
})
export class ChatInputSubcommandErrorListener extends Listener {
public run(error: unknown, payload: ChatInputSubcommandErrorPayload) {
console.log("ChatInputSubcommandErrorListener", error, payload);
}
}
import { Listener } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";
import { ChatInputSubcommandErrorPayload } from "@sapphire/plugin-subcommands";

@ApplyOptions<Listener.Options>({
name: __filename.split(".")[0],
enabled: true,
})
export class ChatInputSubcommandErrorListener extends Listener {
public run(error: unknown, payload: ChatInputSubcommandErrorPayload) {
console.log("ChatInputSubcommandErrorListener", error, payload);
}
}
subcommandMappingIsMissingChatInputCommandHandler.listener.ts
import { Listener } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";
import {
ChatInputSubcommandAcceptedPayload,
SubcommandMappingMethod,
} from "@sapphire/plugin-subcommands";
import { ChatInputCommandInteraction } from "discord.js";

@ApplyOptions<Listener.Options>({
name: __filename.split(".")[0],
enabled: true,
})
export class SubcommandMappingIsMissingChatInputCommandHandlerListener extends Listener {
public run(
message: ChatInputCommandInteraction,
subcommand: SubcommandMappingMethod,
payload: ChatInputSubcommandAcceptedPayload
) {
console.log(
"SubcommandMappingIsMissingChatInputCommandHandlerListener",
payload
);
}
}
import { Listener } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";
import {
ChatInputSubcommandAcceptedPayload,
SubcommandMappingMethod,
} from "@sapphire/plugin-subcommands";
import { ChatInputCommandInteraction } from "discord.js";

@ApplyOptions<Listener.Options>({
name: __filename.split(".")[0],
enabled: true,
})
export class SubcommandMappingIsMissingChatInputCommandHandlerListener extends Listener {
public run(
message: ChatInputCommandInteraction,
subcommand: SubcommandMappingMethod,
payload: ChatInputSubcommandAcceptedPayload
) {
console.log(
"SubcommandMappingIsMissingChatInputCommandHandlerListener",
payload
);
}
}
Favna
Favna•10mo ago
The names are invalid this way. The name has to be the exact event name OR you need to specify the event as a separate config property. In your case that's what you want to do. So add event: SubcommandPluginEvents. ChatInputSubcommandDenied and so on. (this is the case for all listeners, subcommands or otherwise) Oh and also enabled is true by default Oh wait the way you parse the name it matches doesn't it. It's so confusing the way you name files lol
vladdy
vladdy•10mo ago
no thats not gonna work
vladdy
vladdy•10mo ago
No description
b1nzee
b1nzeeOP•10mo ago
the snippets I provided just now are wrong, I forgot to use parse etc, but I have hardcoded it now
import { Listener, type UserError } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";
import { ChatInputSubcommandDeniedPayload } from "@sapphire/plugin-subcommands";
import { parse } from "path";

@ApplyOptions<Listener.Options>({
name: "chatInputSubcommandDenied",
enabled: true,
})
export class ChatInputSubcommandDeniedListener extends Listener {
public run(error: UserError, payload: ChatInputSubcommandDeniedPayload) {
console.log("ChatInputSubcommandDeniedListener", error, payload);
}
}
import { Listener, type UserError } from "@sapphire/framework";
import { ApplyOptions } from "@sapphire/decorators";
import { ChatInputSubcommandDeniedPayload } from "@sapphire/plugin-subcommands";
import { parse } from "path";

@ApplyOptions<Listener.Options>({
name: "chatInputSubcommandDenied",
enabled: true,
})
export class ChatInputSubcommandDeniedListener extends Listener {
public run(error: UserError, payload: ChatInputSubcommandDeniedPayload) {
console.log("ChatInputSubcommandDeniedListener", error, payload);
}
}
still nothing
vladdy
vladdy•10mo ago
didddd you calll registerrr in your entrypoint?
b1nzee
b1nzeeOP•10mo ago
yes index.ts
import dotenv from "dotenv";
dotenv.config();

import { DvSClient } from "./client";
import "@sapphire/plugin-api/register";
import "@sapphire/plugin-subcommands/register";

new DvSClient().login(process.env.DISCORD_APP_TOKEN!);
import dotenv from "dotenv";
dotenv.config();

import { DvSClient } from "./client";
import "@sapphire/plugin-api/register";
import "@sapphire/plugin-subcommands/register";

new DvSClient().login(process.env.DISCORD_APP_TOKEN!);
has there been an update at all to the subcommands plugin that may have broke anything? shall I try a previous version?
drainpixie
drainpixie•10mo ago
unrelated but dotenv is built-in the stable version of node, about 20>
vladdy
vladdy•10mo ago
you should be using latest version if you're on latest sapphire
b1nzee
b1nzeeOP•10mo ago
fair, thank you for informing me yeah, all of these are fresh installs, the day I made this thread
vladdy
vladdy•10mo ago
is this open source?
b1nzee
b1nzeeOP•10mo ago
not rn, but I can make a repo quick if you want
vladdy
vladdy•10mo ago
uhh, it might help yea
b1nzee
b1nzeeOP•10mo ago
GitHub
GitHub - b1nzeex/dvs-discord-bot-v2
Contribute to b1nzeex/dvs-discord-bot-v2 development by creating an account on GitHub.
Favna
Favna•10mo ago
FYI you're right but that only extends to dotenv, not dotenv-expand or some of the more advanced options of dotenv.
drainpixie
drainpixie•10mo ago
I’m aware
Favna
Favna•10mo ago
This one won't be called OwnerOnly when loaded at runtime but ownerOnly.precondition @Enrique https://github.com/b1nzeex/dvs-discord-bot-v2/blob/main/src/preconditions/ownerOnly.precondition.ts And can you validate what vladdy said about __filename?
GitHub
dvs-discord-bot-v2/src/preconditions/ownerOnly.precondition.ts at m...
Contribute to b1nzeex/dvs-discord-bot-v2 development by creating an account on GitHub.
b1nzee
b1nzeeOP•10mo ago
The __filename stuff has been logging correctly But in the listeners I did hardcode for debugging purposes
Favna
Favna•10mo ago
I'm stumped honestly. I guess I'll have to run the bot myself. Alternatively if you want you can use a vscode debugger session and set breakpoints in your node_modules in the JS files of sapphire to see where the execution goes. I'll be doing the same.
b1nzee
b1nzeeOP•10mo ago
I have only ever used the debugger like once xD you'd probably find better results doing it, i dont really know what im doing with the debugger
Teryl
Teryl•10mo ago
Created a new public reminder with ID xYiwjwtIwWc_qyFGsHUHQ, I will send you a message on <t:1711206286:F>. Click on the button to (un)subscribe to the reminder.
debug this issue
xYiwjwtIwWc_qyFGsHUHQ
Favna
Favna•10mo ago
I won't have time before then
Solution
Favna
Favna•10mo ago
@Enrique I looked into the issue and I can run subcommands just fine. I created a PR with the changes I made https://github.com/b1nzeex/dvs-discord-bot-v2/pull/1 The notable ones are: - Reinstalling dependencies, part of updating to yarn v4 - Setting up the initial Prisma migration so the schema is created. You connect the database, so you need to make sure Prisma can actually interact with it. Without this the application should just crash at init anyway - Adding that return we mentioned before in server.command.ts - Specifying that the ownerOnly.precondition.ts should have a name of OwnerOnly to match line 17 in server.command.ts And ofc I also added my own local .env file with my token, an owner ID and a database url (DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres?schema=public) https://cdn.discordapp.com/attachments/838895947052089366/1217946610496045169/ishare-1710451491.PNG?ex=6605e02c&is=65f36b2c&hm=1a193ae6611761ad54472e1c5cff2078ff2af4b0d945aa45a26e15725a9f85cf&
Favna
Favna•10mo ago
@Enrique
b1nzee
b1nzeeOP•10mo ago
thank you, it was the precondition that was failing me 😫 thank you for the other noticed changes though too! how come the file name HAS to be that?
Teryl
Teryl•10mo ago
On <t:1710443086>, @Favna and @Enrique asked me to remind you of this:
debug this issue
Favna
Favna•10mo ago
Ohwell :kekw:
Want results from more Discord servers?
Add your server