edenn!
edenn!
SIASapphire - Imagine a framework
Created by edenn! on 10/27/2023 in #sapphire-support
Does plugin-api support parameters? If so, how can I get tem?
So basically I want to try and have some routes have optional url parameters, I know how this works with express as you can use and get them like this:
const router = express.Router();

router.get('/:id', (request: Request, response: Response) => {
response.status(200).json(request.params['id']);
})
const router = express.Router();

router.get('/:id', (request: Request, response: Response) => {
response.status(200).json(request.params['id']);
})
But I would like to do something like this with my sapphire plugin-api routes, are they like the same and how do I use these? Do sapphire's plugin-api package not support this or do they? Example below of what I intend to achieve:
import { methods, Route, type ApiRequest, type ApiResponse } from '@sapphire/plugin-api';

export class StatusRoute extends Route {
public constructor(context: Route.Context, options: Route.Options) {
super(context, {
...options,
route: 'user/:id',
});
}

public [methods.GET](request: ApiRequest, response: ApiResponse) {
return response.status(200).json(request.params['id']);
}
}
import { methods, Route, type ApiRequest, type ApiResponse } from '@sapphire/plugin-api';

export class StatusRoute extends Route {
public constructor(context: Route.Context, options: Route.Options) {
super(context, {
...options,
route: 'user/:id',
});
}

public [methods.GET](request: ApiRequest, response: ApiResponse) {
return response.status(200).json(request.params['id']);
}
}
6 replies
SIASapphire - Imagine a framework
Created by edenn! on 2/18/2023 in #sapphire-support
How can I create a listener for @discordjs/voice states?
Title kinda explains itself lol, but how can I convert things like
const { VoiceConnectionStatus, AudioPlayerStatus } = require('@discordjs/voice');

connection.on(VoiceConnectionStatus.Ready, (oldState, newState) => {
console.log('Connection is in the Ready state!');
});

player.on(AudioPlayerStatus.Playing, (oldState, newState) => {
console.log('Audio player is in the Playing state!');
});
const { VoiceConnectionStatus, AudioPlayerStatus } = require('@discordjs/voice');

connection.on(VoiceConnectionStatus.Ready, (oldState, newState) => {
console.log('Connection is in the Ready state!');
});

player.on(AudioPlayerStatus.Playing, (oldState, newState) => {
console.log('Audio player is in the Playing state!');
});
into Sapphire Listeners to put in my listeners folder? I've already got some Listeners set up for default discordjs events but I'm just unsure of how to do it for the voice status events.
29 replies
SIASapphire - Imagine a framework
Created by edenn! on 11/29/2022 in #sapphire-support
Can you have folders for commands in SapphireJS
Hey there, by any chance is it possible to have folders for different types of commands on my bot? What I mean: So you see how you have the commands folder in your root/whatever-folder-you-are-using is it possible to store commands in different folders within the commands folder? e.g: Commands > infoCommands > userInfo.ts serverInfo.ts moderationCommands > ban.ts kick.ts timeout.ts By now I hope you get the gist of what I'm trying to do/say here, so any help would be appreciated. Thanks in advance!! (By the way if you need help with what type of version of sapphire I'm using, I'm on framework beta pr-512)
6 replies