I'm Sr Izan, your fellow user and contributor.
Today I'm going to show you how to get started with sern and all its cool features.
Install the CLI:
npm i -g @sern/cli
and then run
sern init
You can also run sern init -y if you want to use the default options.
The CLI is written in Typescript and open-sourced on Github. (thanks evo!)
Normally you'd need a way to store secrets, and the best way to do that is by installing another package: dotenv
just npm i dotenv in the project folder and add require('dotenv').config() to your import section. Then, when you login, process.env.TOKEN (or however you have it named on your .env file) should do the trick.
If you're using ESM, configure dotenv with import 'dotenv/config' instead of require('dotenv').config().
Yes, that's it. Here's a little FAQ to get you started. You can also join the Discord for any problems.
Q: How do I publish a slash command?
A: Install the publish extension. Little video:
Q: Any snippet VSCode extension?
A: Yeah, just search sern Snippets made by a verified publisher called Sr Izan (haha yeah me funny!)
Q: HEEEELLLPPPP!!!!
A: Hey, don't panic! We're here to help so, join the Discord. We're trying to get to 100 members!
Today we're announcing the ability to create class based modules! To get started, install
npm install @sern/handler@latest
Quick List of changes!
Incorporate class based modules into your project instead of the traditional commandModule or eventModule
Extend the new CommandExecutable or EventExecutable
import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';
import { publish } from '../plugins/publish.js';
import { serendipityOnly } from '../plugins/serendipityOnly.js';
export default class extends CommandExecutable<CommandType.Both> {
type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
execute must not be a method of the class. It should be as above, a property on the class!
import { CommandType, EventExecutable, type EventType } from '@sern/handler';
import type { GuildMember } from 'discord.js'
export default class extends EventExecutable<EventType.Discord> {
type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}
Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers.
I believe that you should build your own structures however you might like and customize to your liking.
In addition, decorators now unofficially work with modules!
Feel free to use TypeScript experimental decorators to augment and customize your classes.
The next update will bring sern v2 with some important features. Here are some things to watch out for.