Options
All
  • Public
  • Public/Protected
  • All
Menu

不和 (Fuwa)

不和 (fuwa)

不和 is a simple, small and easy-to-use library for use in Node.js to interact with the popular text and VoIP instant messaging application Discord using its official API.

Note: this package is currently maintained in 0ver, which means breaking changes may occur at our discretion in compliance with SemVer.

Installation

Node.js version 16 or higher is required for this library.

Installing with npm, Yarn or any other package manager for Node.js is simple. Simply run the following command (adapted to your current package manager, if applicable) in your terminal and you'll be ready to go!

# with npm
npm install --save fuwadiscord/fuwa

# with yarn
yarn add github:fuwadiscord/fuwa

# then, compile the code (if you're installing from GitHub)
cd node_modules/fuwa
tsc

Note: pin to a commit you like to avoid breaking changes

Getting started

Fuwa is designed to be quite simple to use, and easy to transfer from other libraries like Discord.js. A simple bot would be programmed along the lines of:

import Fuwa from 'fuwa';

const client = new Fuwa.Client('my token', {
intents: [
...Fuwa.DefaultClientOptions.intents,
Fuwa.Intents.Bits.MessageContent,
],
});

client.on('messages.create', message => {
if (message.content === 'hi, bot!') {
return message.channel.createMessage('hello, ' + message.author.tag);
}
});

client.connect();

Optional dependencies

  • Erlpack: For very fast encoding/decoding of gateway messages. To use this feature, install erlpack as an npm dependency and pass etf: true to your Client's options.
    • => If you have your own custom ETF decoder, you can pass that instead to etf, but make sure it implements our Erlpack interface.
  • Kleur: For coloured log output. To use this feature, install kleur as an npm dependency.

Links

Generated using TypeDoc