Skip to content

Commit

Permalink
feat: add templates for generate command
Browse files Browse the repository at this point in the history
  • Loading branch information
enxg committed Sep 21, 2021
1 parent b14a965 commit be6f535
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 0 deletions.
15 changes: 15 additions & 0 deletions templates/components/argument.js.sapphire
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ "category": "arguments" }
---
import { Argument } from "@sapphire/framework";

export class UserArgument extends Argument {
constructor(context, options) {
super(context, {
...options
});
}

async run(parameter) {
return this.ok(parameter);
}
}
11 changes: 11 additions & 0 deletions templates/components/argument.ts.sapphire
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{ "category": "arguments" }
---
import { ApplyOptions } from '@sapphire/decorators';
import { Argument, ArgumentOptions } from "@sapphire/framework";

@ApplyOptions<ArgumentOptions>({})
export class UserArgument extends Argument<string> {
async run(parameter: string) {
return this.ok(parameter);
}
}
17 changes: 17 additions & 0 deletions templates/components/command.js.sapphire
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{ "category": "commands" }
---
const { SubCommandPluginCommand } = require('@sapphire/plugin-subcommands');

class UserCommand extends SubCommandPluginCommand {
constructor(context, options) {
super(context, {
...options
});
}

async run(message) {
return msg.channel.send('Hello world!');
}
}

exports.UserCommand = UserCommand;
14 changes: 14 additions & 0 deletions templates/components/command.ts.sapphire
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{ "category": "commands" }
---
import { ApplyOptions } from '@sapphire/decorators';
import { SubCommandPluginCommand, SubCommandPluginCommandOptions } from '@sapphire/plugin-subcommands';
import { Message } from 'discord.js';

@ApplyOptions<SubCommandPluginCommandOptions>({
description: 'A basic command'
})
export class UserCommand extends SubCommandPluginCommand {
public async run(message: Message) {
return message.channel.send('Hello world!');
}
}
15 changes: 15 additions & 0 deletions templates/components/listener.js.sapphire
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ "category": "listeners" }
---
const { Listener } = require('@sapphire/framework');

class UserEvent extends Listener {
constructor(context, options = {}) {
super(context, {
...options
});
}

run() {}
}

exports.UserEvent = UserEvent;
9 changes: 9 additions & 0 deletions templates/components/listener.ts.sapphire
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{ "category": "listeners" }
---
import { ApplyOptions } from '@sapphire/decorators';
import { Listener, ListenerOptions } from '@sapphire/framework';

@ApplyOptions<ListenerOptions>({})
export class UserEvent extends Listener {
public run() {}
}
11 changes: 11 additions & 0 deletions templates/components/precondition.js.sapphire
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{ "category": "preconditions" }
---
const { Precondition } = require('@sapphire/framework');

class UserPrecondition extends Precondition {
run(message) {
return this.ok();
}
}

module.exports.UserPrecondition = UserPrecondition;
16 changes: 16 additions & 0 deletions templates/components/precondition.ts.sapphire
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{ "category": "preconditions" }
---
import { Precondition } from '@sapphire/framework';
import type { Message } from 'discord.js';

export class UserPrecondition extends Precondition {
public run(message: Message) {
return this.ok();
}
}

declare module '@sapphire/framework' {
interface Preconditions {
{{name}}: never;
}
}

0 comments on commit be6f535

Please sign in to comment.