From be6f53583ecba3d959a76a12310ff3d80cbd52dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enes=20Gen=C3=A7?= Date: Wed, 22 Sep 2021 00:23:38 +0300 Subject: [PATCH] feat: add templates for `generate` command --- templates/components/argument.js.sapphire | 15 +++++++++++++++ templates/components/argument.ts.sapphire | 11 +++++++++++ templates/components/command.js.sapphire | 17 +++++++++++++++++ templates/components/command.ts.sapphire | 14 ++++++++++++++ templates/components/listener.js.sapphire | 15 +++++++++++++++ templates/components/listener.ts.sapphire | 9 +++++++++ templates/components/precondition.js.sapphire | 11 +++++++++++ templates/components/precondition.ts.sapphire | 16 ++++++++++++++++ 8 files changed, 108 insertions(+) create mode 100644 templates/components/argument.js.sapphire create mode 100644 templates/components/argument.ts.sapphire create mode 100644 templates/components/command.js.sapphire create mode 100644 templates/components/command.ts.sapphire create mode 100644 templates/components/listener.js.sapphire create mode 100644 templates/components/listener.ts.sapphire create mode 100644 templates/components/precondition.js.sapphire create mode 100644 templates/components/precondition.ts.sapphire diff --git a/templates/components/argument.js.sapphire b/templates/components/argument.js.sapphire new file mode 100644 index 0000000..b361c6b --- /dev/null +++ b/templates/components/argument.js.sapphire @@ -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); + } +} diff --git a/templates/components/argument.ts.sapphire b/templates/components/argument.ts.sapphire new file mode 100644 index 0000000..ec74284 --- /dev/null +++ b/templates/components/argument.ts.sapphire @@ -0,0 +1,11 @@ +{ "category": "arguments" } +--- +import { ApplyOptions } from '@sapphire/decorators'; +import { Argument, ArgumentOptions } from "@sapphire/framework"; + +@ApplyOptions({}) +export class UserArgument extends Argument { + async run(parameter: string) { + return this.ok(parameter); + } +} diff --git a/templates/components/command.js.sapphire b/templates/components/command.js.sapphire new file mode 100644 index 0000000..46b922d --- /dev/null +++ b/templates/components/command.js.sapphire @@ -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; diff --git a/templates/components/command.ts.sapphire b/templates/components/command.ts.sapphire new file mode 100644 index 0000000..e1ce567 --- /dev/null +++ b/templates/components/command.ts.sapphire @@ -0,0 +1,14 @@ +{ "category": "commands" } +--- +import { ApplyOptions } from '@sapphire/decorators'; +import { SubCommandPluginCommand, SubCommandPluginCommandOptions } from '@sapphire/plugin-subcommands'; +import { Message } from 'discord.js'; + +@ApplyOptions({ + description: 'A basic command' +}) +export class UserCommand extends SubCommandPluginCommand { + public async run(message: Message) { + return message.channel.send('Hello world!'); + } +} diff --git a/templates/components/listener.js.sapphire b/templates/components/listener.js.sapphire new file mode 100644 index 0000000..891998c --- /dev/null +++ b/templates/components/listener.js.sapphire @@ -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; diff --git a/templates/components/listener.ts.sapphire b/templates/components/listener.ts.sapphire new file mode 100644 index 0000000..287b1db --- /dev/null +++ b/templates/components/listener.ts.sapphire @@ -0,0 +1,9 @@ +{ "category": "listeners" } +--- +import { ApplyOptions } from '@sapphire/decorators'; +import { Listener, ListenerOptions } from '@sapphire/framework'; + +@ApplyOptions({}) +export class UserEvent extends Listener { + public run() {} +} diff --git a/templates/components/precondition.js.sapphire b/templates/components/precondition.js.sapphire new file mode 100644 index 0000000..250068b --- /dev/null +++ b/templates/components/precondition.js.sapphire @@ -0,0 +1,11 @@ +{ "category": "preconditions" } +--- +const { Precondition } = require('@sapphire/framework'); + +class UserPrecondition extends Precondition { + run(message) { + return this.ok(); + } +} + +module.exports.UserPrecondition = UserPrecondition; diff --git a/templates/components/precondition.ts.sapphire b/templates/components/precondition.ts.sapphire new file mode 100644 index 0000000..f8f034c --- /dev/null +++ b/templates/components/precondition.ts.sapphire @@ -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; + } +}