diff --git a/templates/.sapphirerc.json.sapphire b/templates/.sapphirerc.json.sapphire index d918411..a7003e5 100644 --- a/templates/.sapphirerc.json.sapphire +++ b/templates/.sapphirerc.json.sapphire @@ -1,14 +1,14 @@ { - "projectLanguage": "{{language}}", - "locations": { - "base": "src", - "arguments": "arguments", - "commands": "commands", - "listeners": "listeners", - "preconditions": "preconditions" - }, - "customFileTemplates": { - "enabled": false, - "location": "" - } + "projectLanguage": "{{language}}", + "locations": { + "base": "src", + "arguments": "arguments", + "commands": "commands", + "listeners": "listeners", + "preconditions": "preconditions" + }, + "customFileTemplates": { + "enabled": false, + "location": "" + } } diff --git a/templates/components/argument.js.sapphire b/templates/components/argument.js.sapphire index b361c6b..fd01f8f 100644 --- a/templates/components/argument.js.sapphire +++ b/templates/components/argument.js.sapphire @@ -1,15 +1,22 @@ { "category": "arguments" } --- -import { Argument } from "@sapphire/framework"; +const { Argument } = require('@sapphire/framework'); -export class UserArgument extends Argument { - constructor(context, options) { - super(context, { - ...options - }); - } +class UserArgument extends Argument { + /** + * @param {Argument.Context} context + */ + constructor(context) { + super(context, { + // Any Argument options you want here + }); + } - async run(parameter) { - return this.ok(parameter); - } + async run(parameter) { + return this.ok(parameter); + } } + +module.exports = { + UserArgument +}; diff --git a/templates/components/argument.ts.sapphire b/templates/components/argument.ts.sapphire index 4ff5a9d..3b374f8 100644 --- a/templates/components/argument.ts.sapphire +++ b/templates/components/argument.ts.sapphire @@ -1,17 +1,17 @@ { "category": "arguments" } --- import { ApplyOptions } from '@sapphire/decorators'; -import { Argument, ArgumentOptions } from "@sapphire/framework"; +import { Argument, ArgumentOptions } from '@sapphire/framework'; @ApplyOptions({}) export class UserArgument extends Argument { - async run(parameter: string) { - return this.ok(parameter); - } + async run(parameter: string) { + return this.ok(parameter); + } } declare module '@sapphire/framework' { - interface ArgType { - {{name}}: string; - } + interface ArgType { + {{name}}: string; + } } diff --git a/templates/components/contextmenucommand.js.sapphire b/templates/components/contextmenucommand.js.sapphire index 20390a4..8001281 100644 --- a/templates/components/contextmenucommand.js.sapphire +++ b/templates/components/contextmenucommand.js.sapphire @@ -1,25 +1,38 @@ { "category": "commands" } --- -const { Command } = require('@sapphire/framework') +const { Command } = require('@sapphire/framework'); +const { ApplicationCommandType } = require('discord-api-types/v10'); class UserCommand extends Command { - constructor(context, options) { - super(context, { - ...options, + /** + * @param {Command.Context} context + */ + constructor(context) { + super(context, { + // Any Command options you want here name: 'command' - }); - } + }); + } - registerApplicationCommands(registry) { - registry.registerContextMenuCommand({ - name: this.name, - type: 'MESSAGE' - }) + /** + * @param {Command.Registry} registry + */ + registerApplicationCommands(registry) { + registry.registerContextMenuCommand((builder) => + builder // + .setName(this.name) + .setType(ApplicationCommandType.Message) + ); } + /** + * @param {Command.ContextMenuInteraction} interaction + */ async contextMenuRun(interaction) { - return await interaction.reply({content: "Hello world!"}) + return await interaction.reply({ content: 'Hello world!' }); } } -exports.UserCommand = UserCommand; +module.exports = { + UserCommand +}; diff --git a/templates/components/contextmenucommand.ts.sapphire b/templates/components/contextmenucommand.ts.sapphire index e055fe6..d022d7a 100644 --- a/templates/components/contextmenucommand.ts.sapphire +++ b/templates/components/contextmenucommand.ts.sapphire @@ -2,19 +2,21 @@ --- import { ApplyOptions } from '@sapphire/decorators'; import { Command } from '@sapphire/framework'; +import { ApplicationCommandType } from 'discord-api-types/v10'; @ApplyOptions({ description: 'A basic contextMenu command' }) export class UserCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { - registry.registerContextMenuCommand({ - name: this.name, - type: 'MESSAGE' - }) + registry.registerContextMenuCommand((builder) => + builder // + .setName(this.name) + .setType(ApplicationCommandType.Message) + ); } public async contextMenuRun(interaction: Command.ContextMenuInteraction) { - return await interaction.reply({content: "Hello world!"}); + return await interaction.reply({ content: 'Hello world!' }); } } diff --git a/templates/components/listener.js.sapphire b/templates/components/listener.js.sapphire index 891998c..2ab4bb2 100644 --- a/templates/components/listener.js.sapphire +++ b/templates/components/listener.js.sapphire @@ -3,13 +3,18 @@ const { Listener } = require('@sapphire/framework'); class UserEvent extends Listener { - constructor(context, options = {}) { - super(context, { - ...options - }); - } + /** + * @param {Listener.Context} context + */ + constructor(context) { + super(context, { + // Any Listener options you want here + }); + } - run() {} + run() {} } -exports.UserEvent = UserEvent; +module.exports = { + UserEvent +} diff --git a/templates/components/listener.ts.sapphire b/templates/components/listener.ts.sapphire index 287b1db..b04d46b 100644 --- a/templates/components/listener.ts.sapphire +++ b/templates/components/listener.ts.sapphire @@ -5,5 +5,5 @@ import { Listener, ListenerOptions } from '@sapphire/framework'; @ApplyOptions({}) export class UserEvent extends Listener { - public run() {} + public run() {} } diff --git a/templates/components/messagecommand.js.sapphire b/templates/components/messagecommand.js.sapphire index d798227..33eb7ca 100644 --- a/templates/components/messagecommand.js.sapphire +++ b/templates/components/messagecommand.js.sapphire @@ -3,15 +3,23 @@ const { Command } = require('@sapphire/framework'); class UserCommand extends Command { - constructor(context, options) { - super(context, { - ...options - }); - } + /** + * @param {Command.Context} context + */ + constructor(context) { + super(context, { + // Any Command options you want here + }); + } - async messageRun(message) { - return message.channel.send('Hello world!'); - } + /** + * @param {import('discord.js').Message} message + */ + async messageRun(message) { + return message.channel.send('Hello world!'); + } } -exports.UserCommand = UserCommand; +module.exports = { + UserCommand +}; diff --git a/templates/components/precondition.js.sapphire b/templates/components/precondition.js.sapphire index 250068b..6735a92 100644 --- a/templates/components/precondition.js.sapphire +++ b/templates/components/precondition.js.sapphire @@ -3,9 +3,28 @@ const { Precondition } = require('@sapphire/framework'); class UserPrecondition extends Precondition { - run(message) { + /** + * @param {import('discord.js').Message} message + */ + messageRun(message) { + return this.ok(); + } + + /** + * @param {import('discord.js').CommandInteraction} interaction + */ + chatInputRun(interaction) { + return this.ok(); + } + + /** + * @param {import('discord.js').ContextMenuInteraction} interaction + */ + contextMenuRun(interaction) { return this.ok(); } } -module.exports.UserPrecondition = UserPrecondition; +module.exports = { + UserPrecondition +}; diff --git a/templates/components/precondition.ts.sapphire b/templates/components/precondition.ts.sapphire index f8f034c..a94a86e 100644 --- a/templates/components/precondition.ts.sapphire +++ b/templates/components/precondition.ts.sapphire @@ -1,16 +1,24 @@ { "category": "preconditions" } --- import { Precondition } from '@sapphire/framework'; -import type { Message } from 'discord.js'; +import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'; export class UserPrecondition extends Precondition { - public run(message: Message) { - return this.ok(); - } + public override messageRun(message: Message) { + return this.ok(); + } + + public override chatInputRun(interaction: CommandInteraction) { + return this.ok(); + } + + public override contextMenuRun(interaction: ContextMenuInteraction) { + return this.ok(); + } } declare module '@sapphire/framework' { - interface Preconditions { - {{name}}: never; - } + interface Preconditions { + {{name}}: never; + } } diff --git a/templates/components/slashcommand.js.sapphire b/templates/components/slashcommand.js.sapphire index c12b2f2..0157209 100644 --- a/templates/components/slashcommand.js.sapphire +++ b/templates/components/slashcommand.js.sapphire @@ -3,24 +3,37 @@ const { Command } = require('@sapphire/framework') class UserCommand extends Command { - constructor(context, options) { - super(context, { - ...options, + /** + * @param {Command.Context} context + */ + constructor(context) { + super(context, { + // Any Command options you want here name: 'command', description: 'A basic slash command' - }); - } + }); + } - registerApplicationCommands(registry) { - registry.registerChatInputCommand({ - name: this.name, - description: this.description - }) + /** + * @param {Command.Registry} registry + */ + registerApplicationCommands(registry) { + registry.registerChatInputCommand( + (builder) => + builder // + .setName(this.name) + .setDescription(this.description) + ); } + /** + * @param {Command.ChatInputInteraction} interaction + */ async chatInputRun(interaction) { - return await interaction.reply({content: "Hello world!"}) + return await interaction.reply({ content: 'Hello world!' }); } } -exports.UserCommand = UserCommand; +module.exports = { + UserCommand +} diff --git a/templates/components/slashcommand.ts.sapphire b/templates/components/slashcommand.ts.sapphire index 5465cd6..98d02ee 100644 --- a/templates/components/slashcommand.ts.sapphire +++ b/templates/components/slashcommand.ts.sapphire @@ -8,13 +8,14 @@ import { Command } from '@sapphire/framework'; }) export class UserCommand extends Command { public override registerApplicationCommands(registry: Command.Registry) { - registry.registerChatInputCommand({ - name: this.name, - description: this.description - }) + registry.registerChatInputCommand((builder) => + builder // + .setName(this.name) + .setDescription(this.description) + ); } - public async chatInputRun(interaction: Command.ChatInputInteraction) { - return await interaction.reply({content: "Hello world!"}); + public override async chatInputRun(interaction: Command.ChatInputInteraction) { + return await interaction.reply({ content: 'Hello world!' }); } } diff --git a/templates/schemas/.sapphirerc.scheme.json b/templates/schemas/.sapphirerc.scheme.json index 9df3233..0093bfe 100644 --- a/templates/schemas/.sapphirerc.scheme.json +++ b/templates/schemas/.sapphirerc.scheme.json @@ -1,63 +1,50 @@ { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "Sapphire CLI Config", - "description": "Scheme for Sapphire CLI Config (@sapphire/cli)", - "type": "object", - "properties": { - "projectLanguage": { - "description": "Project language (ts | js)", - "type": "string" - }, - "locations": { - "description": "Categories and their locations", - "type": "object", - "properties": { - "base": { - "type": "string" - }, - "arguments": { - "type": "string" - }, - "commands": { - "type": "string" - }, - "listeners": { - "type": "string" - }, - "preconditions": { - "type": "string" - } - }, - "required": [ - "base", - "arguments", - "commands", - "listeners", - "preconditions" - ] - }, - "customFileTemplates": { - "description": "Settings about custom component (piece) templates", - "type": "object", - "properties": { - "enabled": { - "description": "Enable custom file templates", - "type": "boolean" - }, - "location": { - "description": "Location of your custom file templates", - "type": "string" - } - }, - "required": [ - "enabled", - "location" - ] - } - }, - "required": [ - "projectLanguage", - "locations", - "customFileTemplates" - ] + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Sapphire CLI Config", + "description": "Scheme for Sapphire CLI Config (@sapphire/cli)", + "type": "object", + "properties": { + "projectLanguage": { + "description": "Project language (ts | js)", + "type": "string" + }, + "locations": { + "description": "Categories and their locations", + "type": "object", + "properties": { + "base": { + "type": "string" + }, + "arguments": { + "type": "string" + }, + "commands": { + "type": "string" + }, + "listeners": { + "type": "string" + }, + "preconditions": { + "type": "string" + } + }, + "required": ["base", "arguments", "commands", "listeners", "preconditions"] + }, + "customFileTemplates": { + "description": "Settings about custom component (piece) templates", + "type": "object", + "properties": { + "enabled": { + "description": "Enable custom file templates", + "type": "boolean" + }, + "location": { + "description": "Location of your custom file templates", + "type": "string" + } + }, + "required": ["enabled", "location"] + } + }, + "required": ["projectLanguage", "locations", "customFileTemplates"] }