Tony
Tony
Explore posts from servers
NNuxt
Created by Tony on 6/4/2024 in #❓・help
useFetch refresh failing to recognise new query params
I have a simple page with this useFetch code at the start:
const { data, refresh } = await useFetch(`/api/images`, {
query: {
q: query.value
}
});

watch(() => route.query.q, async () => {
await refreshNuxtData();
await refresh();
});
const { data, refresh } = await useFetch(`/api/images`, {
query: {
q: query.value
}
});

watch(() => route.query.q, async () => {
await refreshNuxtData();
await refresh();
});
However refresh() won't use the new route query param. If I put {{ route.query.q }} in the page it shows the new query param but refreshing through the watch OR a button with refresh() manually shows the API as recieving the old query param What's happening???
7 replies
SIASapphire - Imagine a framework
Created by Tony on 2/24/2024 in #sapphire-support
Throwing errors in commands/subcommands
Just curious if there is a way to throw an error in an application command/subcommand and have it handled by the chatInputCommandDenied listener, similar to how preconditions work. Some kind of this.error that can be sent and handled by the listener. Does this exist or can I write something to do that?
17 replies
SIASapphire - Imagine a framework
Created by Tony on 2/23/2024 in #sapphire-support
Limit command to specified roles?
I honestly haven't done this in a while (not since pre-application commands) and am new to using Sapphire. Looking to restrict a command to only be visible/usable by the server's owner and any roles they define. How is this best handled with Sapphire and application commands? The bot in question has a database to store roles if that's needed. Using TypeScript, here's a basic command I wrote that I want to restrict as described:
// commands/example.ts
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';

@ApplyOptions<Command.Options>({
description: 'An example command, that should only be accessed by server owner and users with roles defined'
})

export class UserCommand extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder
.setName(this.name)
.setDescription(this.description)
);
}

public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
return interaction.reply(`Command example!`);
}
}
// commands/example.ts
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';

@ApplyOptions<Command.Options>({
description: 'An example command, that should only be accessed by server owner and users with roles defined'
})

export class UserCommand extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder
.setName(this.name)
.setDescription(this.description)
);
}

public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
return interaction.reply(`Command example!`);
}
}
Already looked over docs and previous questions, though maybe I've missed something, call me out if I have haha
16 replies
NNuxt
Created by Tony on 4/29/2023 in #❓・help
Server /api returning 404, but still working
I have a server route in /server/api/download.post.ts. When fetching it, the route seems to return a 404 Cannot find any route matching /api/download. However, this makes no sense as the route works fine and the code inside the route actually works - just when it finishes (it's non-sync code I believe, tried promisify-ing it to no luck) the event.node.res.end won't work. Any help?
9 replies
NNuxt
Created by Tony on 2/10/2023 in #❓・help
useLazyFetch errors not resolving
No description
3 replies
NNuxt
Created by Tony on 11/26/2022 in #❓・help
Changing pages keeping the original page content until refresh
No description
6 replies