Skip to content

Repository files navigation

Framed.js

GitHubnpm

Framed.js is a multi-platform bot framework, made to be compatible between Discord and Twitch.

  • Object-oriented
  • Written in TypeScript
  • Built upon discord.js and (in the future) Twurple

WARNING: This framework IS NOT STABLE, and does not have any documentation! The only documentation is through code comments and other self-documentating things.

Installation

Requirements may change, due to what discord.js requires.

# You can use npm instead of pnpm, but pnpm is *much* faster and I highly recommend it.
pnpm install @framedjs/core
# Install Framed.js dependencies
pnpm install discord.js twitch twitch-auth twitch-chat-client

Usage

Quick Start

TypeScript is used in this example, and although untested (and with a few changes), this framework should work with JavaScript. Create these files, and make sure your project starts at src/index.ts.

NOTE: All the code below is currently untested.

// src/index.tsimport{Client,Discord}from"@framedjs/core";asyncfunctionstart(){constclient=newClient({appVersion: "0.1.0",defaultPrefix: "!",discord: {botOwners: ["123456789012345678"],// Your user ID},footer: "",});client.plugins.loadPluginsIn({dirname: path.join(__dirname,"plugins"),filter: /^(.+plugin)\.(js|ts)$/,excludeDirs: /^(.*)\.(git|svn)$|^(.*)subcommands(.*)$/,});awaitclient.login([{type: "discord",token: "token",clientOptions: {intents: [Discord.Intents.FLAGS.DIRECT_MESSAGES,Discord.Intents.FLAGS.DIRECT_MESSAGE_REACTIONS,Discord.Intents.FLAGS.GUILDS,Discord.Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,Discord.Intents.FLAGS.GUILD_MESSAGES,Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,],},},]);}start();

Framed.js uses a plugin system, that allows you to import things like commands and events.

// src/plugins/Info/Info.plugin.tsimport{BasePlugin,Client}from"@framedjs/core";importpathfrom"path";exportdefaultclassextendsBasePlugin{constructor(client: Client){super(client,{id: "default.bot.info",name: "Info",description: "Info commands.",version: "0.1.0",paths: {commands: path.join(__dirname,"commands"),// events: path.join(__dirname, "events"),// discordInteractions: path.join(__dirname, "interactions"),// discordMenuFlows: path.join(__dirname, "menus"),},});}}

One command script can handle both Discord slash commands, and message commands.

// src/plugins/Info/commands/Ping.tsimport{BaseCommand,BaseMessage,BasePlugin}from"@framedjs/core";exportdefaultclassextendsBaseCommand{constructor(plugin: BasePlugin){super(plugin,{id: "ping",about: "Sends a pong back!.",botPermissions: {discord: {permissions: ["SEND_MESSAGES"],},},discordInteraction: {slashCommandBuilder:
newDiscordJsBuilders.SlashCommandBuilder(),},});}asyncrun(msg: BaseMessage): Promise<boolean>{awaitmsg.send(`🏓 ${msg.discord.author} Pong!`);returntrue;}}

About

A TypeScript bot framework.

Topics

Resources

Stars

2 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages