Note: self-hosting the bot and pointing it at production Hubs servers is currently broken. If you want to run the bot as-is, you'll need to also run your own Hubs server. We're trying to fix this.
A Discord bot that interacts with Mozilla Hubs. Mostly bridges information (chat, media links, joins/leaves), lets you see who is currently in Hubs from Discord and sets Hubs permissions and abilities based on Discord roles. Check out the bot in action on our own Hubs community Discord!
The bot has two primary functions, both related to linking Discord text channels and Hubs rooms.
When you create a Hubs room using the !hubs create
bot command, you establish a permanent association between the Hubs room and the Discord channel where you typed the command. This association will cause the Hubs room to use information from your Discord server to authenticate participants. Specifically:
- People can only join the Hubs room via Discord OAuth, and only if they are a member of the channel that the Hubs room is associated with.
- When they join, their permissions are based on their Discord roles. (People with Discord "manage channels" permission will be able to change the name and scene in the room, and people with Discord "kick users" permission will be able to kick and mute people in the Hubs room.)
- Their display name in the Hubs room will reflect their Discord display name.
This only happens with rooms that you create using !hubs create
-- simply bridging a room by putting it in the topic won't cause it to become permission-linked. This linkage will persist for the lifetime of the Hubs room -- if you don't like it, make a new Hubs room.
Independently of being permission-linked, the bot will detect any Hubs rooms in channel topics in channels that the bot can read and join those rooms, establishing a bridge between the room and the Discord channel. Specifically:
- A notification will appear in the Discord channel when someone joins or leaves the Hubs room, or if administrative stuff happens in the Hubs room.
- Text chat and images will be bridged from the Discord channel into the Hubs room.
- Text chat and photos will be bridged from the Hubs room into the Discord channel.
- Links to media (images, videos, models) which are pinned in the Hubs room will be bridged to Discord.
Note that you need to set up a webhook for the bot to use in the Discord channel, or it won't be able to post chat from Hubs.
If you remove the Hubs room from the topic, bridging will stop.
Head over here to get a bot invite link.
Once the bot is running on your server:
-
Give the bot appropriate permissions on the channels you want it to run in.
-
Create a webhook named "Hubs" in the channels you want it to run in. It will use this webhook to bridge chat and send Hubs status updates.
-
Try out the bot! Type
!hubs
in a channel the bot is in to see all of the ways you can control the bot. Put your favorite Hubs room into a channel topic to start bridging, or use the!hubs create
command to create a new room.
The bot requires several permissions in order to work:
- "Send messages," "Read messages," and "Embed links" are necessary in order to bridge between the Hubs room that is linked to a channel and the messages that are sent within the channel on Discord.
- "Manage webhooks" is necessary in order for the bot to find and use a webhook for bridging chat.
- "Manage channels" is necessary in order for the bot to set the channel topic and bridge chat. Note: We do not ask for this permission globally when you add the bot to your server, instead we recommend you grant this permission to the bot in specific groups or channels.
You can and should assign these on a channel-by-channel basis to the bot role after adding the bot to your guild.
If you want to run the bot yourself or contribute to it right now, your best bet is to join our Discord and ask for help, because there are some parts of the server code that you will need to run and hack up. In the future this process should be easier.
To simply run the bot process:
-
Clone this repository.
-
Install Node and
npm
. The instructions at the NPM website should suffice. -
Install Javascript dependencies by running
npm ci
. -
Create an
.env
file with your bot's API token. IncludeRETICULUM_HOST={your server}
andHUBS_HOSTS={your server}
to point it at your local backend. You can see the different configuration bits you can override in.env.defaults
. You can also pass these values as environment variables when you runnpm start
. -
Run
npm start
to start the server, connect to Discord and Reticulum, and operate indefinitely. -
Follow the instructions above to set up and use the bot on your Discord guild.