Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed core templates #159

Merged
merged 6 commits into from
Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions templates/.sapphirerc.json.sapphire
Original file line number Diff line number Diff line change
@@ -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": ""
}
}
27 changes: 17 additions & 10 deletions templates/components/argument.js.sapphire
Original file line number Diff line number Diff line change
@@ -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
};
14 changes: 7 additions & 7 deletions templates/components/argument.ts.sapphire
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{ "category": "arguments" }
---
import { ApplyOptions } from '@sapphire/decorators';
import { Argument, ArgumentOptions } from "@sapphire/framework";
import { Argument, ArgumentOptions } from '@sapphire/framework';

@ApplyOptions<ArgumentOptions>({})
export class UserArgument extends Argument<string> {
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;
}
}
39 changes: 26 additions & 13 deletions templates/components/contextmenucommand.js.sapphire
Original file line number Diff line number Diff line change
@@ -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
};
12 changes: 7 additions & 5 deletions templates/components/contextmenucommand.ts.sapphire
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@
---
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
import { ApplicationCommandType } from 'discord-api-types/v10';

@ApplyOptions<Command.Options>({
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!' });
}
}
19 changes: 12 additions & 7 deletions templates/components/listener.js.sapphire
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion templates/components/listener.ts.sapphire
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import { Listener, ListenerOptions } from '@sapphire/framework';

@ApplyOptions<ListenerOptions>({})
export class UserEvent extends Listener {
public run() {}
public run() {}
}
26 changes: 17 additions & 9 deletions templates/components/messagecommand.js.sapphire
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
23 changes: 21 additions & 2 deletions templates/components/precondition.js.sapphire
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
22 changes: 15 additions & 7 deletions templates/components/precondition.ts.sapphire
Original file line number Diff line number Diff line change
@@ -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;
}
}
37 changes: 25 additions & 12 deletions templates/components/slashcommand.js.sapphire
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
13 changes: 7 additions & 6 deletions templates/components/slashcommand.ts.sapphire
Original file line number Diff line number Diff line change
Expand Up @@ -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!' });
}
}
Loading