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
NNuxt
Created by f1fty on 4/22/2024 in #❓・help
Getting _auth/oauth/discord/authorize 404 Not found in production
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
DIAdiscord.js - Imagine an app
Created by f1fty on 4/17/2024 in #djs-questions
Fetch messages after a message with including initialMessage
let messages = await dmChannel.messages.fetch();
const initialMessage = messages.find(
(x) =>
x.components[0] &&
x.components[0].components &&
x.components[0].components.find(
(x) => x.type === ComponentType.StringSelect,
),
);

messages = new Collection([
[initialMessage.id, initialMessage],
...(await dmChannel.messages.fetch({ after: initialMessage.id })).reverse(),
]);
let messages = await dmChannel.messages.fetch();
const initialMessage = messages.find(
(x) =>
x.components[0] &&
x.components[0].components &&
x.components[0].components.find(
(x) => x.type === ComponentType.StringSelect,
),
);

messages = new Collection([
[initialMessage.id, initialMessage],
...(await dmChannel.messages.fetch({ after: initialMessage.id })).reverse(),
]);
I dont know if i can convert the collection to array. slice them and convert them back. this is the current way, but i think its not the best, because of duplicated fetch# maybe. someone heas
9 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
DIAdiscord.js - Imagine an app
Created by f1fty on 4/9/2024 in #djs-questions
Switch users screen view to current created channel on guild.
Hello, can i change thhe users screen/view to a created channel on ModalSubmitInteraction.
3 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