extending Command class
How can i make a class called ModerationCommand which automatically checks if the user is a staff member and if not then returns an error so that i dont have to implement the checking in every moderation command file
Solution:Jump to solution
```ts
import { Command } from '@sapphire/framework';
export abstract class ModerationCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {...
11 Replies
Solution
@Favna How can i make an argument that converts durations like
2d
10m
to msuse a natural language processing library
there's many libs to do such a thing
no i mean how can i make the argument
whenever i try to make one
So this should work right
But when i try to use the argument i get
for
the error is correct. That is not valid code.
Hasn't been since Sapphire v3
not sure where you based it on
this is the proper code
oh
ok
Also is there a way to make the ModerationCommand check the database and see if
showOutput
is enabled if its not enabled then dont display and output like how Dyno does itYou're essentially asking basic JavaScript class questions. The answer is yes, you just need to be a bit incentive with your methods and their naming.
I can't get it to work in the messageRun function
Well no if you have a messageRun in the super class and in the child class then the child will overwrite the parent. This is basic class inheritance.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain
You'll have to do something else to get around this. There's many ways to do this. Like I said, this is JavaScript basics. Not sapphire related at all.
Inheritance and the prototype chain - JavaScript | MDN
JavaScript is a bit confusing for developers experienced in class-based languages (like Java or C++), as it is dynamic and does not have static types.