Concepts

What you can build for Unbound, and the few ideas every plugin is made of.

An addon changes the Discord mobile app. There are three kinds. Pick the one that fits what you want to make, and this page tells you which ideas you need.

What you can build

KindWhat you shipUse it to
PluginJavaScriptAdd features, change how Discord behaves, add buttons and screens
ThemeA JSON palette and an optional backgroundRecolor Discord
Icon packA folder of imagesReplace Discord's icons

Themes and icon packs need no code. If that's what you're making, go straight to How Themes Work or Icon Packs. The rest of this page is about plugins.

How a plugin changes Discord

Discord's app is written in JavaScript, split into thousands of small modules. One sends messages, one holds the current user, one draws a button. Your plugin runs inside the same app, so it can reach the same modules Discord uses. Almost every plugin does some mix of three things with them.

Find Discord's code

Modules have no fixed names, so you search for them by what they export. This finds the module that has both sendMessage and receiveMessage:

import { metro } from '@unbound-app/api';

const Messages = metro.findByProps('sendMessage', 'receiveMessage');

The search is lazy. It runs the first time you use Messages, so it never slows Discord's launch. Finding Modules covers every way to search.

Change what it does

To change a function, you patch it. A patch wraps the function in your own code, which runs before it, after it, or instead of it. Discord keeps calling the same function, so your code runs every time Discord's does.

Discord calls a function you patched
  1. Discord calls sendMessage
  2. Your before patchSees the arguments
  3. The original runs
  4. Your after patchSees the result

Components are functions too, so the same idea changes what Discord shows on screen. See Patching Functions and Patching Components.

Read what Discord knows

Discord keeps its state in stores: the current user, the servers you're in, the selected channel. When something happens, such as a message arriving, Discord sends out an action and the stores update. Read a store to get state, and listen for an action to run code when something happens. See Flux Stores.

Unbound cleans up after you

While your plugin runs, Unbound records every patch, command and listener it makes. After the user turns the plugin off, Unbound removes them all. So most plugins only write a start function. How Plugins Run covers the few things you clean up yourself.

Where to go next