Best Approach on separating Commands from their "run" file to a separate Folder
For context, I am super new to discordjs and this framework so apologizes if this question sounds odd.
I really dislike the approach that all examples in the example repository and docs are giving of having the command definition (if you call it like this) and the execution code of the command in the same file.
What is the best way to separate them both? Or is it even possible?
Solution:Jump to solution
```ts
import { myRunFunction } from '../lib/commands/my-command';
import { Command } from '@sapphire/framework';
export class MyCommand extends Command {...
6 Replies
Solution
Other than that, it's not possible. Sapphire aims to be Object Oriented which means that code is encapsulated and highly coupled to the origin object, the command class. It sounds like you're rather looking for something following a more FP style which Sapphire doesn't offer.
In fact I'd argue that modern JS in general, while allowing FP, isn't the best language for actual FP because there is a large focus on classes.
I see, what does FP stand for?
functional programming
it's the total opposite of object oriented
ahh yes, I see.
Thank you
OOP combines data and its associated behavior into an object. This helps software programmers to easier understand how the program works, although the code is much longer than in FP. FP, on the other hand, clearly distinguishes data and behavior, keeping them separately.source: https://scand.com/company/blog/functional-programming-vs-oop/#:~:text=OOP%20combines%20data%20and%20its,and%20behavior,%20keeping%20them%20separately. that pretty much describes what you were asking