net-tech-
net-tech-
Explore posts from servers
SIASapphire - Imagine a framework
Created by net-tech- on 3/12/2024 in #sapphire-support
Using JSON to register application commands and add options
Hi there, Is there a way to add all of my application command options in the registerApplicationCommands method on the Command class without using builders? For example, a registerApplicationCommands method might look like this currently, to register options:
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder //
.setName(this.name)
.setDescription(this.description)
.addSubcommand((subcommand) =>
subcommand
.setName("register")
.setDescription(
"Registers your friend code so you can share it with others."
)
.addStringOption((option) =>
option
.setName("code")
.setDescription("Your friend code.")
.setRequired(true)
)
)
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder //
.setName(this.name)
.setDescription(this.description)
.addSubcommand((subcommand) =>
subcommand
.setName("register")
.setDescription(
"Registers your friend code so you can share it with others."
)
.addStringOption((option) =>
option
.setName("code")
.setDescription("Your friend code.")
.setRequired(true)
)
)
--- My use case is that I have a constant array of settings I'd like the user to be able to configure, and it would be nice if I could do something like automatically add a non-required slash command option for each setting. Then the command could look something like /settings set setting1 setting2 setting3 ...
6 replies
SIASapphire - Imagine a framework
Created by net-tech- on 12/23/2023 in #sapphire-support
Removing pagination buttons on last page
Hi there, what is the recommended way to remove the pagination buttons on the last page when using the paginator in sapphire djs utilities?
4 replies
SIASapphire - Imagine a framework
Created by net-tech- on 8/6/2023 in #sapphire-support
Unknown interaction with paginated message custom actions
Hi there, I'm using sapphire's paginated messages from @sapphire/discord.js-utilities. Before adding custom actions, a stop button worked fine. I recently set custom actions to:
leaderboard.setActions([
{
emoji: Emoji.LeftChevron,
customId: "x-previous",
type: ComponentType.Button,
style: ButtonStyle.Secondary,
run: ({ handler }) => {
if (handler.index === 0) {
handler.index = handler.pages.length - 1;
} else {
--handler.index;
}
},
},
{
emoji: Emoji.RightChevron,
customId: "x-next",
type: ComponentType.Button,
style: ButtonStyle.Secondary,
run: ({ handler }) => {
if (handler.index === handler.pages.length - 1) {
handler.index = 0;
} else {
++handler.index;
}
},
},
{
emoji: Emoji.Cross,
customId: "x-stop",
type: ComponentType.Button,
style: ButtonStyle.Secondary,
run: ({ collector }) => {
collector.stop("stopped");
},
},
]);
leaderboard.setActions([
{
emoji: Emoji.LeftChevron,
customId: "x-previous",
type: ComponentType.Button,
style: ButtonStyle.Secondary,
run: ({ handler }) => {
if (handler.index === 0) {
handler.index = handler.pages.length - 1;
} else {
--handler.index;
}
},
},
{
emoji: Emoji.RightChevron,
customId: "x-next",
type: ComponentType.Button,
style: ButtonStyle.Secondary,
run: ({ handler }) => {
if (handler.index === handler.pages.length - 1) {
handler.index = 0;
} else {
++handler.index;
}
},
},
{
emoji: Emoji.Cross,
customId: "x-stop",
type: ComponentType.Button,
style: ButtonStyle.Secondary,
run: ({ collector }) => {
collector.stop("stopped");
},
},
]);
Now, when I click the stop button. I get a djs error in the console:
DiscordAPIError[10062]: Unknown interaction
// other stack trace paths here

at async safelyReplyToInteraction (file:///Users/net-tech-/Developer/anime-interlink-typescript/node_modules/.pnpm/@[email protected]/node_modules/@sapphire/discord.js-utilities/dist/index.mjs:664:7)
DiscordAPIError[10062]: Unknown interaction
// other stack trace paths here

at async safelyReplyToInteraction (file:///Users/net-tech-/Developer/anime-interlink-typescript/node_modules/.pnpm/@[email protected]/node_modules/@sapphire/discord.js-utilities/dist/index.mjs:664:7)
Am I not stopping the paginator correctly?
7 replies
SIASapphire - Imagine a framework
Created by net-tech- on 7/16/2023 in #sapphire-support
Trouble with telling typescript the return type of fetch when using @sapphire/result
Hi there, I have a function that fetches an API using the native fetch function. The fetch is wrapped in Result.fromAsync(), and I wanted to do Result.fromAsync<Promise<APIResponse>> since I know what the API will return. The problem is, when doing Result.fromAsync<Promise<APIResponse>> Typescript says that Response is missing certain properties that I know the API will return. How would I tell Typescript I know that the fetch will return this?
Result.fromAsync<Promise<OMGLOLAPIResponse>>(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Argument of type 'Promise<Response>' is not assignable to parameter of type 'Awaitable<Resolvable<Promise<OMGLOLAPIResponse>, unknown>> | (() => Awaitable<Resolvable<Promise<OMGLOLAPIResponse>, unknown>>)'.
Type 'Promise<Response>' is not assignable to type 'Promise<OMGLOLAPIResponse>'.
Type 'Response' is missing the following properties from type 'OMGLOLAPIResponse': request, response ts(2345)

fetch(`${OMGLOL_API_URL}/address/${ADDRESS}/purl`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.OMGLOL_API_KEY}`
},
body: JSON.stringify({
name: path,
url: destination,
listed: true
})
})
)
Result.fromAsync<Promise<OMGLOLAPIResponse>>(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Argument of type 'Promise<Response>' is not assignable to parameter of type 'Awaitable<Resolvable<Promise<OMGLOLAPIResponse>, unknown>> | (() => Awaitable<Resolvable<Promise<OMGLOLAPIResponse>, unknown>>)'.
Type 'Promise<Response>' is not assignable to type 'Promise<OMGLOLAPIResponse>'.
Type 'Response' is missing the following properties from type 'OMGLOLAPIResponse': request, response ts(2345)

fetch(`${OMGLOL_API_URL}/address/${ADDRESS}/purl`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.OMGLOL_API_KEY}`
},
body: JSON.stringify({
name: path,
url: destination,
listed: true
})
})
)
15 replies
SIASapphire - Imagine a framework
Created by net-tech- on 7/13/2023 in #sapphire-support
'Can't find the template.' on a template listed in the docs
When running sapphire generate buttoninteractionhandler customRole I get the error Can't find the template., however, https://www.sapphirejs.dev/docs/Guide/CLI/generating-components lists buttoninteractionhandler as a component.
4 replies
SIASapphire - Imagine a framework
Created by net-tech- on 4/20/2023 in #sapphire-support
What does sapphire's logger use on the backend?
Winston, pino, something else?
10 replies
SIASapphire - Imagine a framework
Created by net-tech- on 4/2/2023 in #sapphire-support
Proper pnpm support
I keep getting
The inferred type of 'parse' cannot be named without a reference to '../../node_modules/.pnpm/@[email protected]/node_modules/@sapphire/result/dist/lib/Option/Some.js'. This is likely not portable. A type annotation is necessary.
The inferred type of 'parse' cannot be named without a reference to '../../node_modules/.pnpm/@[email protected]/node_modules/@sapphire/result/dist/lib/Option/Some.js'. This is likely not portable. A type annotation is necessary.
in any situation where I use
public override parse(
public override parse(
which the docs use in multiple examples. A quick search reveals that the suggested solution is adding
public-hoist-pattern[]=*@sapphire*
public-hoist-pattern[]=*@sapphire*
however this does not resolve the issue. If the issue is indeed from pnpm's side, couldn't a maintainer of sapphire open an issue in pnpm's git repo about this since it's a pretty big thing? It seems a bit ignorant to tell the user to "switch to yarn" if they use pnpm. pnpm is a pretty popular choice, with over 3 million weekly downloads. Normally I would open an issue on pnpm's repo. However, I don't really have deep enough technical knowledge as to what exactly is happening to open a good bug report.
6 replies
SIASapphire - Imagine a framework
Created by net-tech- on 3/14/2023 in #sapphire-support
Monorepos
Does Sapphire work and play nice with monorepos?
6 replies
SIASapphire - Imagine a framework
Created by net-tech- on 3/6/2023 in #sapphire-support
Interaction Handlers
Am I required to specify to sapphire where my interaction handlers directory is? A interaction-handlers directory doesn't seem to be detected. - ├─ Loaded 0 interaction-handlers.
29 replies
SIASapphire - Imagine a framework
Created by net-tech- on 1/9/2023 in #sapphire-support
ChatInputCommandError Event not firing
I'm having trouble with this code https://hst.sh/odutopaniv.typescript in that the event is not firing when a command errors and this is being logged by sapphire natively https://hst.sh/ivezicirex.apache
6 replies
SIASapphire - Imagine a framework
Created by net-tech- on 1/9/2023 in #sapphire-support
What does commandError emit?
I'm struggling to find what commandError emits when fired by sapphire.
12 replies
SIASapphire - Imagine a framework
Created by net-tech- on 1/9/2023 in #sapphire-support
Am I doing this wrong? I feel like I'm doing this wrong.
Hey there, In my ping command I'm doing void interaction.reply(await resolveKey(interaction, "ping:success", { ping })) because I'm using eslint and it is screaming
Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator.
Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator.
when not using void. Is this a good way of handling the eslint error or is there a better one. resolveKey is from @sapphire/plugin-i18next and the eslint config is from @sapphire/eslint-config.
5 replies
SIASapphire - Imagine a framework
Created by net-tech- on 1/8/2023 in #sapphire-support
Namespace 'Command' has no exported member 'ChatInputInteraction'.
Hey there, I'm following the guide at https://www.sapphirejs.dev/docs/Guide/getting-started/creating-a-basic-app-command, and I'm getting the error Namespace 'Command' has no exported member 'ChatInputInteraction'. on this line.
public async chatInputRun(interaction: Command.ChatInputInteraction)
public async chatInputRun(interaction: Command.ChatInputInteraction)
Intellisense offers me autocomplete for Command.ChatInputCommandInteraction. Is this a mistake in the guide?
8 replies
SIASapphire - Imagine a framework
Created by net-tech- on 1/8/2023 in #sapphire-support
Dockerfile - CLI Template
5 replies
SIASapphire - Imagine a framework
Created by net-tech- on 12/31/2022 in #sapphire-support
Does sapphire work only with DJS?
Would sapphire be compatible with something like Eris?
24 replies
SIASapphire - Imagine a framework
Created by net-tech- on 11/30/2022 in #sapphire-support
Type 'DeveloperOnly' is not assignable to type 'PreconditionEntryResolvable'.
Type '"DeveloperOnly"' is not assignable to type 'PreconditionEntryResolvable'.
Type '"DeveloperOnly"' is not assignable to type 'PreconditionEntryResolvable'.
in src/commands/eval.ts. With a precondition file at src/preconditions/DeveloperOnly.ts with the content https://hst.sh/ufunolenip.typescript . index.d.ts exists with the following content https://hst.sh/gikuhixani.typescript . Eval starts with the content https://hst.sh/sagivaqahe.typescript . Version @sapphire/framework@pr-512
34 replies