Files
archived-sern-website/docs/guide/walkthrough/goal.md
2023-07-29 11:09:03 -05:00

1.4 KiB

sidebar_position
sidebar_position
1

Goal

This walkthrough will be written in TypeScript but will have JavaScript snippets throughout.

Make robust, modular, bots

  • Modularity: sern is built with modularity in mind. You can swap pieces and parts easily.
  • Familiar: commands and structures are similar to classic v12 handlers and the official discord.js command handler guide, while packing many features
  • Concise: Too much code is a liability. with sern, write less for more 🤯

Using @sapphire/framework

import { Command } from '@sapphire/framework'
import type { CommandInteraction } from 'discord.js'

export class PingCommand extends Command {
  public constructor(context: Command.Context) {
    super(context, {
      description: 'Pong!',
      chatInputCommand: {
        register: true,
      },
    })
  }
  public async chatInputRun(interaction: CommandInteraction) {
    await interaction.reply('Pong!')
  }
}

Using @sern/handler

import { commandModule, CommandType } from '@sern/handler'
import { publish } from '../plugins';

export default commandModule({ 
    type: CommandType.Both,
    plugins: [publish()],
    description: 'Pong!',
    execute: (ctx, args) => {
        await ctx.reply('Pong!')
    }
})

Keep in mind the above example acts as both a slash command AND text command