jacoobes 0f0b0fb61c feat(handler): adding higher-order-function wrappers to increase readability and shorten code
Experimenting with functional paradigm to hopefully reduce redundancy and try improving readability,
shorten code, and create a cleaner code base
2022-02-15 16:09:42 -06:00
2022-02-15 19:38:43 +03:00
2022-02-15 10:19:03 +05:30
2022-02-14 13:18:14 +05:30
2022-01-24 20:48:18 -06:00
2022-01-30 21:02:16 -06:00
2022-01-25 22:23:17 -06:00
2022-02-14 09:48:16 +05:30
2022-02-15 10:19:03 +05:30
2022-02-13 21:55:17 +03:00
2022-02-15 10:19:03 +05:30
2022-02-12 08:54:02 +03:00
2022-02-15 10:21:03 +05:30
2022-02-15 10:21:03 +05:30

Sern Handler

NPM version NPM downloads Builds Passing

Sern automates and streamlines development your discord bot with new version compatibility and full customization.

Installation

npm install sern-handler
yarn add sern-handler
pnpm add sern-handler

Basic Usage

Typescript

import { Client, Intents } from 'discord.js'
import { Sern } from 'sern-handler';
import { prefix, token } from '../src/secrets.json';

const client = new Client({
    intents: [
        Intents.FLAGS.GUILDS,
        Intents.FLAGS.GUILD_MESSAGES,
        Intents.FLAGS.GUILD_MEMBERS
    ]
});

new Sern.Handler({
    client,
    prefix,
    commands : 'dist/commands',  // If using typescript, target your outDir/~
    privateServers : [
        {
            test : true,
            id: 'server-id'
        }
    ],
    init: async (handler : Sern.Handler) => {
        // Optional function to initialize anything else on bot startup
    },
});

ping.ts

import  { Sern, Types } from "sern-handler";
import { Ok } from "ts-results";

export default  {
    alias: [],
    desc : "ping pong",
    visibility : "private",
    test : false,
    type: Sern.CommandType.SLASH | Sern.CommandType.TEXT,
    execute : async ({message, interaction} : Types.Context, args: Ok<string> ) => Ok("pong!")      

} as Sern.Module;

JavaScript

import { Client, Intents } from 'discord.js';
import { Sern } from 'sern-handler';
import { prefix, token } from '../src/secrets.json';

const client = new Client({
    intents: [
        Intents.FLAGS.GUILDS,
        Intents.FLAGS.GUILD_MESSAGES,
        Intents.FLAGS.GUILD_MEMBERS
    ]
});

new Sern.Handler({
    client,   
    prefix,   
    commands : 'dist/commands', 
    privateServers : [           
        {
            test : true,
            id: 'server-id'
        }
    ],
    init: async (handler) => {
        // Optional function to initialize anything else on bot startup
    },
});


client.login(token);

ping.js

import { Sern, Types } from "sern-handler";
import { Ok } from "ts-results";

export default  {
    alias: [],
    desc : "ping pong",
    visibility : "private",
    test : false,
    type: Sern.CommandType.SLASH | Sern.CommandType.TEXT,
    execute : async ({message, interaction}, args) => Ok("pong!")      

};
  • 📑 Official Documentation
  • 🎧 Discord Server

Contribute 😄

  • Pull up on issues and tell me if there are bugs
  • All kinds of contributions are welcomed!
Description
No description provided
Readme MIT 8.4 MiB
Languages
TypeScript 100%