f1fty
f1fty
Explore posts from servers
SIASapphire - Imagine a framework
Created by f1fty on 4/30/2024 in #sapphire-support
Question to Plugin i18next
I would like to start using @sapphire/plugin-i18next. Can i fetch language files from a another repository (or from my own npm module)?
5 replies
SIASapphire - Imagine a framework
Created by f1fty on 4/28/2024 in #sapphire-support
eslint autofix problems
No description
6 replies
SIASapphire - Imagine a framework
Created by f1fty on 4/20/2024 in #sapphire-support
Caching Problems
Hey, i have some problems with caching, on discord.js they sad All Guilds are cached if you have the intent, and the client is ready. While using intents like GuildMembers & Guilds. i dont know if it fits into this forum, i tough because sapphire initates the listeners.... sometimes when i do this here it doesnt show up some guild... and when i restart the application it doesnt show up.
this.container.client.guilds.cache.filter(x => !x.members.cache.get(message.author.id)).forEach(guild => {
selectMenu.addOptions(new StringSelectMenuOptionBuilder()
.setLabel(guild.name)
.setEmoji({ id: getEmojiIdByName(this.container.client, DefaultEmojis.HELIX_ARROW) })
.setValue(guild.id.toString())
);
});
this.container.client.guilds.cache.filter(x => !x.members.cache.get(message.author.id)).forEach(guild => {
selectMenu.addOptions(new StringSelectMenuOptionBuilder()
.setLabel(guild.name)
.setEmoji({ id: getEmojiIdByName(this.container.client, DefaultEmojis.HELIX_ARROW) })
.setValue(guild.id.toString())
);
});
with this one i have no problems
const guilds = await Promise.all((await this.container.client.guilds.fetch()).map((guild) => guild.fetch()));

guilds.forEach(async (guild) => {
selectMenu.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel(guild.name)
.setEmoji({ id: getEmojiIdByName(this.container.client, DefaultEmojis.HELIX_ARROW) })
.setValue(guild.id.toString())
);
});
const guilds = await Promise.all((await this.container.client.guilds.fetch()).map((guild) => guild.fetch()));

guilds.forEach(async (guild) => {
selectMenu.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel(guild.name)
.setEmoji({ id: getEmojiIdByName(this.container.client, DefaultEmojis.HELIX_ARROW) })
.setValue(guild.id.toString())
);
});
12 replies
SIASapphire - Imagine a framework
Created by f1fty on 4/12/2024 in #sapphire-support
multiplie registered handlers
Hi, is it better to split for example the button interactions for different buttons to different files? Or does it have any complications with the general performance? e.g. if i put everything in one file and fire functions to other files is that better? or does that make no difference
5 replies
SIASapphire - Imagine a framework
Created by f1fty on 4/6/2024 in #sapphire-support
Working with Emoji's on SelectMenu Options
No description
12 replies
SIASapphire - Imagine a framework
Created by f1fty on 4/5/2024 in #sapphire-support
Cant get bot to work when put bot related files to another folder in src
No description
28 replies
SIASapphire - Imagine a framework
Created by f1fty on 4/5/2024 in #sapphire-support
Nested Router with @sapphire/plugin-api
Hello guys, iam really new to this framework. i would like to integrate my express to my sapphire project. In my old project i was using nested routers. Here are some references from my old project: This was registering all my controllers like /servers or /users, i know the plugin-api does this automatically.
this.controllers.forEach(controller => {
let router = express.Router();
router.use(controller.path, controller.router);
this.app.use("/api", router);
console.log("Initialized Controller for /api" + controller.path)
})
this.controllers.forEach(controller => {
let router = express.Router();
router.use(controller.path, controller.router);
this.app.use("/api", router);
console.log("Initialized Controller for /api" + controller.path)
})
Then i used a paramRouter to pass other routes after :param(like serverId) for example (/api/servers/99999/config
export default class ServerController implements Controller {
public path = "/servers";
public router = Router();

private paramRouter = Router({ mergeParams: true });

constructor() {
this.router.use("/:id", this.paramRouter)
this.initializeRoutes();
}

private initializeRoutes() {
this.router.get("/", checkAuthorization, this.getAllServers);
this.router.post("/", [checkAuthorization, checkValidation(asRequestSchema({ body: serverSchema }))], this.addServer);

this.paramRouter.get("/config", checkAuthorization, this.getConfigOfServer);
this.paramRouter.patch("/config", [checkAuthorization, checkValidation(asRequestSchema({ body: serverConfigSchema }))], this.updateConfigOfServer)
}
export default class ServerController implements Controller {
public path = "/servers";
public router = Router();

private paramRouter = Router({ mergeParams: true });

constructor() {
this.router.use("/:id", this.paramRouter)
this.initializeRoutes();
}

private initializeRoutes() {
this.router.get("/", checkAuthorization, this.getAllServers);
this.router.post("/", [checkAuthorization, checkValidation(asRequestSchema({ body: serverSchema }))], this.addServer);

this.paramRouter.get("/config", checkAuthorization, this.getConfigOfServer);
this.paramRouter.patch("/config", [checkAuthorization, checkValidation(asRequestSchema({ body: serverConfigSchema }))], this.updateConfigOfServer)
}
so my question is can i do this with the plugin-api?
5 replies