Feralheart
Feralheart
Explore posts from servers
SIASapphire - Imagine a framework
Created by Feralheart on 4/9/2024 in #sapphire-support
Variable parameter type based on the previous variable
I want to add a 'parametric' set subcommand to one of my commands For that command the values can be user, role or a string. Can I somehow change the option type (for example use addRoleOption instead of addStringOption) based on the value of the type option?
.addSubcommand((subcommand) => {
return subcommand
.setName('set')
.setDescription(i18next.t(`${this.translationPath}.subcommandDescription.settings`))
.addStringOption((option) => {
return option
.setName('name')
.setDescription(i18next.t(`${this.translationPath}.optionDescription.name`))
.setRequired(true)
.setAutocomplete(true);
})
.addStringOption((option) => {
return option
.setName('type')
.setDescription(i18next.t(`${this.translationPath}.optionDescription.type`))
.setRequired(true)
.setChoices(
{
name: 'name',
value: 'Name'
},
{
name: 'user',
value: 'User'
},
{
name: 'role',
value: 'Role'
}
);
})
.addStringOption((option) => {
return option
.setName('value')
.setDescription(i18next.t(`${this.translationPath}.optionDescription.value`))
.setRequired(true);
});
})
.addSubcommand((subcommand) => {
return subcommand
.setName('set')
.setDescription(i18next.t(`${this.translationPath}.subcommandDescription.settings`))
.addStringOption((option) => {
return option
.setName('name')
.setDescription(i18next.t(`${this.translationPath}.optionDescription.name`))
.setRequired(true)
.setAutocomplete(true);
})
.addStringOption((option) => {
return option
.setName('type')
.setDescription(i18next.t(`${this.translationPath}.optionDescription.type`))
.setRequired(true)
.setChoices(
{
name: 'name',
value: 'Name'
},
{
name: 'user',
value: 'User'
},
{
name: 'role',
value: 'Role'
}
);
})
.addStringOption((option) => {
return option
.setName('value')
.setDescription(i18next.t(`${this.translationPath}.optionDescription.value`))
.setRequired(true);
});
})
8 replies
SIASapphire - Imagine a framework
Created by Feralheart on 12/3/2023 in #sapphire-support
Linter errors in command options after upgrade
Hey there, After upgrading to the freshest Sapphire and Discord.js versions I've got error in every command where I parse the options. For example:
const channel = interaction.options.getChannel('channel');
const messageId = interaction.options.getString('messageid')!;
const channel = interaction.options.getChannel('channel');
const messageId = interaction.options.getString('messageid')!;
Here I got two errors in my linter: Inside .getChannel()
Expected 0 arguments, but got 1
And at .getString()
Property 'getString' does not exist on type 'Omit<CommandInteractionOptionResolver<CacheType>, "getMessage" | "getFocused">'
The interesting thing is the errors are only inside my linter and in CLI it builds without any warns or errors. Did I forgot to add something or remove something from my package.json?
18 replies
SIASapphire - Imagine a framework
Created by Feralheart on 5/23/2023 in #sapphire-support
Bot doesn't trigger error events
I want to add error reporting to my bot and to test it I added two errors to my bot: a manually thrown one (calling throw new Error('You've got an error!');) and an E500 (in this case checking a property of a null object) I've added the
client.on('error', (_error) => {
console.log("It's a client error");
});
process.on('uncaughtException', (_error) => {
console.log("It's an uncaught exception");
});
process.on('unhandledRejection', (_error) => {
console.log("It's an unhandled rejection");
});
client.on('error', (_error) => {
console.log("It's a client error");
});
process.on('uncaughtException', (_error) => {
console.log("It's an uncaught exception");
});
process.on('unhandledRejection', (_error) => {
console.log("It's an unhandled rejection");
});
But after triggering the "bad commands" there are no sign of these logs in console, just the errors After trying it I've added Sentry and Rollbar (not simultaneously) to the project as well but the errors doesn't appear on the dashboard Is there something in the framework what catches these errors?
9 replies
SIASapphire - Imagine a framework
Created by Feralheart on 1/22/2023 in #sapphire-support
@sapphire/result error in v4
After migrating to Sapphire v4 and D.js v14 and fixed all breaking changes, I've still got three errors from @sapphire/result One of the error is:
node_modules/@sapphire/result/dist/lib/Option.d.ts:45:46 - error TS2344: Type 'T[P]' does not satisfy the constraint 'Option<any>'.
Type 'T[keyof T]' is not assignable to type 'Option<any>'.
Type 'T[string] | T[number] | T[symbol]' is not assignable to type 'Option<any>'.
Type 'T[string]' is not assignable to type 'Option<any>'.
Type 'T[string]' is not assignable to type 'Some<any>'.
Type 'T[keyof T]' is not assignable to type 'Some<any>'.
Type 'T[P]' is not assignable to type 'Some<any>'.
Type 'T[keyof T]' is not assignable to type 'Some<any>'.
Type 'T[string] | T[number] | T[symbol]' is not assignable to type 'Some<any>'.
Type 'T[string]' is not assignable to type 'Some<any>'.

45 -readonly [P in keyof T]: UnwrapSome<T[P]>;
node_modules/@sapphire/result/dist/lib/Option.d.ts:45:46 - error TS2344: Type 'T[P]' does not satisfy the constraint 'Option<any>'.
Type 'T[keyof T]' is not assignable to type 'Option<any>'.
Type 'T[string] | T[number] | T[symbol]' is not assignable to type 'Option<any>'.
Type 'T[string]' is not assignable to type 'Option<any>'.
Type 'T[string]' is not assignable to type 'Some<any>'.
Type 'T[keyof T]' is not assignable to type 'Some<any>'.
Type 'T[P]' is not assignable to type 'Some<any>'.
Type 'T[keyof T]' is not assignable to type 'Some<any>'.
Type 'T[string] | T[number] | T[symbol]' is not assignable to type 'Some<any>'.
Type 'T[string]' is not assignable to type 'Some<any>'.

45 -readonly [P in keyof T]: UnwrapSome<T[P]>;
The other two looks the same but instead of UnwrapSome there's UnwrapOk and UnwrapErr in the last row How to fix this?
19 replies
SIASapphire - Imagine a framework
Created by Feralheart on 12/5/2022 in #sapphire-support
How to remove image from interaction reply when using a paginator?
When my bot replies with an embed and then edit it's reply to a paginator the image what was in the embed still remains above the paginator. How to remove it?
6 replies