---
slug: blog/1.2.0
title: Release 1.2.0
authors: [jacoobes]
tags: [release]
date: 2022-09-28
---

## Class-based modules

Today we're announcing the ability to create class based modules!
To get started, install

import PackageManagers from '~/components/PackageManagers.astro';

<PackageManagers command="add" text="@sern/handler@latest" />

Quick List of changes!

- [Class-based modules](#class-based-modules-1)
  - [Deprecation Warnings](#deprecation-warnings)
  - [Dependencies Update](#dependencies-update)

### Class based modules

Incorporate class based modules into your project instead of the traditional `commandModule` or `eventModule`
Extend the new `CommandExecutable` or `EventExecutable`

```ts title="commands/meaning-of-life.ts" {15}
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");
  };
}
```

:::caution

execute must not be a method of the class. It should be as above, a property on the class!

:::

```ts title="events/guildMemberAdd.ts" {6}
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. <br /> 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.

### Deprecation Warnings

The next update will bring sern v2 with some important features. Here are some things to watch out for.

- [Wrapper#client](/v3/api/interfaces/wrapper) will be deprecated
- [Wrapper#sernEmitter](/v3/api/interfaces/wrapper) will be deprecated
  - a SernEmitter will be automatically created once Sern#init is called
- The option to pass in a function or array for [Wrapper#events](/v3/api/interfaces/wrapper) will be deprecated. Only strings are accepted.
- `Sern#addExternal` will be deprecated in favor of a better way.

### Dependencies Update

- TypeScript has been updated to 4.8.3
- Discord.js has been upgraded to 14.5
