Teixeira
Teixeira
Explore posts from servers
SIASapphire - Imagine a framework
Created by Teixeira on 6/2/2024 in #sapphire-support
Validation error in `SlashCommandBuilder.addSubcommand`
Full stack trace in case it helps and version info - @sapphire/plugin-subcommands@6.0.3 @sapphire/framework@5.2.1 discord.js@14.15.2
21 replies
SIASapphire - Imagine a framework
Created by Teixeira on 6/2/2024 in #sapphire-support
Validation error in `SlashCommandBuilder.addSubcommand`
/**
* Adds a new subcommand to this command.
*
* @param input - A function that returns a subcommand builder or an already built builder
*/
addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): TypeAfterAddingSubcommands;
/**
* Adds a new subcommand to this command.
*
* @param input - A function that returns a subcommand builder or an already built builder
*/
addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): TypeAfterAddingSubcommands;
TS types say it should accept the instance directly so I assumed I could
21 replies
SIASapphire - Imagine a framework
Created by Teixeira on 6/2/2024 in #sapphire-support
Validation error in `SlashCommandBuilder.addSubcommand`
Yeah this is it... Why do TS types accept the respective builder instances though? By the way @Answer Overflow isn't working atm
21 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/14/2024 in #sapphire-support
Globally setting the guild in which to register commands by default
Thank you!
114 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/14/2024 in #sapphire-support
Globally setting the guild in which to register commands by default
After updating the package I'm getting a TS error:
node_modules/@sapphire/framework/dist/esm/index.d.mts:1:22 - error TS2307: Cannot find module 'src' or its corresponding type declarations.

1 import * as src from 'src';
node_modules/@sapphire/framework/dist/esm/index.d.mts:1:22 - error TS2307: Cannot find module 'src' or its corresponding type declarations.

1 import * as src from 'src';
I ran npm update @sapphire/framework
114 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/14/2024 in #sapphire-support
Globally setting the guild in which to register commands by default
One last thing, should I mark any of the messages here as the solution, to @Answer Overflow? Feels like I shouldn't but not sure
114 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/14/2024 in #sapphire-support
Globally setting the guild in which to register commands by default
Okay thank you both for the help!
114 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/14/2024 in #sapphire-support
Globally setting the guild in which to register commands by default
So I'll have to wait for the update to be pushed to sapphire and then I can npm update my version and should be good to go?
114 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/14/2024 in #sapphire-support
Globally setting the guild in which to register commands by default
Yep I can confirm I was using idHints
114 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/17/2024 in #sapphire-support
"ChatInputCommandError" listener not firing for subcommands
Got it, thank you!
8 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/17/2024 in #sapphire-support
"ChatInputCommandError" listener not firing for subcommands
The command with a subcommand:
import { Subcommand } from '@sapphire/plugin-subcommands';
import {
ActionRowBuilder,
ChannelType,
ModalActionRowComponentBuilder,
ModalBuilder,
TextInputBuilder,
TextInputStyle,
channelMention,
inlineCode
} from 'discord.js';
import CustomEmbed, { CustomEmbedType } from '../lib/CustomEmbed.js';
import Utils from '../lib/Utils.js';
import { PaginatedMenuResponse } from '../lib/PaginatedMenuResponse.js';

/**
* Adds usable quotes.
*/
export class QuotesSubcommandGroup extends Subcommand {
public constructor(context: Subcommand.LoaderContext, options: Subcommand.Options) {
super(context, {
...options,
name: 'quotes',
subcommands: [
{
name: 'add',
chatInputRun: 'chatInputAdd'
},
]
});
}

public override registerApplicationCommands(registry: Subcommand.Registry) {
registry.registerChatInputCommand(
(builder) =>
builder
.setName('quotes') //
.setDescription('Manages the list of quotes.')
.setDefaultMemberPermissions('0')
.addSubcommand((subCommand) => {
return subCommand //
.setName('add')
.setDescription('Add quotes to the list.');
})
{
idHints: ['1217906420926644305'],
guildIds: this.container.environment.GUILD_IDS.split(',')
}
);
}

public async chatInputAdd(interaction: Subcommand.ChatInputCommandInteraction) {
throw new Error("Test");
}
}
import { Subcommand } from '@sapphire/plugin-subcommands';
import {
ActionRowBuilder,
ChannelType,
ModalActionRowComponentBuilder,
ModalBuilder,
TextInputBuilder,
TextInputStyle,
channelMention,
inlineCode
} from 'discord.js';
import CustomEmbed, { CustomEmbedType } from '../lib/CustomEmbed.js';
import Utils from '../lib/Utils.js';
import { PaginatedMenuResponse } from '../lib/PaginatedMenuResponse.js';

/**
* Adds usable quotes.
*/
export class QuotesSubcommandGroup extends Subcommand {
public constructor(context: Subcommand.LoaderContext, options: Subcommand.Options) {
super(context, {
...options,
name: 'quotes',
subcommands: [
{
name: 'add',
chatInputRun: 'chatInputAdd'
},
]
});
}

public override registerApplicationCommands(registry: Subcommand.Registry) {
registry.registerChatInputCommand(
(builder) =>
builder
.setName('quotes') //
.setDescription('Manages the list of quotes.')
.setDefaultMemberPermissions('0')
.addSubcommand((subCommand) => {
return subCommand //
.setName('add')
.setDescription('Add quotes to the list.');
})
{
idHints: ['1217906420926644305'],
guildIds: this.container.environment.GUILD_IDS.split(',')
}
);
}

public async chatInputAdd(interaction: Subcommand.ChatInputCommandInteraction) {
throw new Error("Test");
}
}
8 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/17/2024 in #sapphire-support
"ChatInputCommandError" listener not firing for subcommands
It successfully catches errors from "normal" commands, used this one to test it out:
import { Command } from '@sapphire/framework';

export class TestCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, { ...options });
}

/**
* Registers this slash command.
*
* @param registry - The {@link Command.Registry} instance associated with this command.
*/
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) =>
builder
.setName('test') //
.setDescription('TBD')
);
}

/**
* Handler for executions of this command.
*
* @param interaction - The {@link Command.ChatInputCommandInteraction} object received.
*/
public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
throw new Error('Test');
}
}
import { Command } from '@sapphire/framework';

export class TestCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, { ...options });
}

/**
* Registers this slash command.
*
* @param registry - The {@link Command.Registry} instance associated with this command.
*/
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) =>
builder
.setName('test') //
.setDescription('TBD')
);
}

/**
* Handler for executions of this command.
*
* @param interaction - The {@link Command.ChatInputCommandInteraction} object received.
*/
public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
throw new Error('Test');
}
}
8 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/14/2024 in #sapphire-support
Globally setting the guild in which to register commands by default
Here's the uncut command that extends Subcommand instead of Command (doesn't fit on a Discord message): https://pastebin.com/c8dkpBbs Just in case I'm accidentally doing something that causes this issue
114 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/14/2024 in #sapphire-support
Globally setting the guild in which to register commands by default
When ApplicationCommandRegistries.setDefaultGuildIds(guildIds); is set it registers it in the specified guild, and when it is not set it registers it globally, as it should work
114 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/14/2024 in #sapphire-support
Globally setting the guild in which to register commands by default
import { Command } from '@sapphire/framework';

/**
* TODO
*/
export class TestCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, { ...options });
}

/**
* Registers this slash command.
*
* @param registry - The {@link Command.Registry} instance associated with this command.
*/
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) =>
builder
.setName('test') //
.setDescription('TBD')
);
}

/**
* Handler for executions of this command.
*
* @param interaction - The {@link Command.ChatInputCommandInteraction} object received.
*/
public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
// TODO
}
}
import { Command } from '@sapphire/framework';

/**
* TODO
*/
export class TestCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, { ...options });
}

/**
* Registers this slash command.
*
* @param registry - The {@link Command.Registry} instance associated with this command.
*/
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) =>
builder
.setName('test') //
.setDescription('TBD')
);
}

/**
* Handler for executions of this command.
*
* @param interaction - The {@link Command.ChatInputCommandInteraction} object received.
*/
public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
// TODO
}
}
114 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/14/2024 in #sapphire-support
Globally setting the guild in which to register commands by default
I just tried it and it works as expected with normal commands
114 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/14/2024 in #sapphire-support
Globally setting the guild in which to register commands by default
I haven't tried it with a "normal" one yet will do that and see if it persists
114 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/14/2024 in #sapphire-support
Globally setting the guild in which to register commands by default
Could it have anything to do with the fact the command in question extends the Subcommand class from @sapphire/plugin-subcommands@6.0.3 instead of the "normal" Command one?
114 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/14/2024 in #sapphire-support
Globally setting the guild in which to register commands by default
const guildIds = this._environment.GUILD_IDS.split(',');
this.logger.debug(guildIds);
ApplicationCommandRegistries.setDefaultGuildIds(guildIds);
await this.client.login(this._environment.DISCORD_TOKEN);
const guildIds = this._environment.GUILD_IDS.split(',');
this.logger.debug(guildIds);
ApplicationCommandRegistries.setDefaultGuildIds(guildIds);
await this.client.login(this._environment.DISCORD_TOKEN);
2024-03-14 17:42:23 - DEBUG - [ '1217485244840677546' ]
2024-03-14 17:42:23 - DEBUG - [ '1217485244840677546' ]
114 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/14/2024 in #sapphire-support
Globally setting the guild in which to register commands by default
Ah of course makes sense
114 replies