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
| Kind | What you ship | Use it to |
|---|---|---|
| Plugin | JavaScript | Add features, change how Discord behaves, add buttons and screens |
| Theme | A JSON palette and an optional background | Recolor Discord |
| Icon pack | A folder of images | Replace 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 sendMessage
- Your before patchSees the arguments
- The original runs
- 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
Scaffold a plugin, run it on your phone, and make it change Discord.
The lifecycle, the Addon scope, and what to clean up.
Every file of a real plugin, and why it is there.
Recolor Discord with a palette and no code.
Replace Discord's icons with your own set.