Moonwalker

Discord bot to publish forum threads
Moonwalker

Repo

Moonwalker Git Repo

Purpose

Now discord has channels of type Forum, where conversations are held in thread-type form. Some of these threads hold focused discussions with valuable information that can prove useful for others (like from a troubleshooting session).

These forum conversations tend to explore/evolve a specific topic and eventually arrive at a resolution; unlike normal discord channels, which can also be topic based, but their message count just keeps growing.

The main purpose of the Moonwalker bot is to have a way to grab a forum thread, and serialize its contents, typically to JSON. This content can then be processed further and turned into a webpage, or another method for consumption.

Commands

The core commands of the bot are:

/publish

This command is meant to run on a forum-thread channel. It will grab all the thread information and serialize it using a handler. The current available handlers are:

/settings publish

This command has one required argument “publishers”, and two optional arguments, “anonymize” and “unmaskrole”.

publishers

Here, you need to select the server role that will allow members to publish threads.

anonymize

This setting will make it so member usernames and avatars are replaced by fake usernames and avatars.

When set to No, published threads will contain your server members’ usernames and avatars.

When set to Yes, server members’s usernames and avatars will be replaced with fake placeholders.

unmaskrole

If you pick a role for this setting, any member that belongs to this role means they opt-in to revealing their username and avatar on published threads.

With this setting, you can have your server members opt-in with an auto-role to reveal their identifying information.

Moonwalker Bot

The easiest way to start using Moonwalker is to use the hosted instance.

Invite Link | Discord Support Server | FAQs

Setting up the hosted version

What you will need

You will need to select or create a new role that will enable members to publish threads. The publish command will check that the member has this role.

To set the publishers role for your server, you will use the following command:

/settings publish

Moonwalker Basics

When using the hosted Moonwalker bot, publishing forum threads will save them to a public S3 location.

To find an online map of your server’s published threads, you can build the url with the following steps:

https://s3.us-west-2.amazonaws.com/www.readonlychild.com/moonwalks/
<first-two-digits> /
<next-two-digits> /
<server-id> /
_titlemap.json

https://s3.us-west-2.amazonaws.com/www.readonlychild.com/moonwalks/62/01/620112554211140000/_titlemap.json

astro-moonwalks

There is a sidekick project called astro-moonwalks that can generate a webpage per published thread. It uses the above url logic based on your server’s id.

Read the Astro-Moonwalks Blog Post

Self Hosting

Grab a copy of the master branch:

git clone https://github.com/readonlychild/moonwalker.git
cd moonwalker
npm install

Configuration

The main command for the bot is /publish.

As of Nov/2022, this command can handle serialization using an S3 Bucket, or the bot’s filesystem.

AWS S3 configuration lives in .env so that the aws-sdk can pick up the credentials with ease.

/publish

/publish [title: ] [category: ]

This command has an optional title argument, and an optional category argument.

This command has two operation modes, and it can be controlled thru setting publishConfig.handler

Mode Filesystem

Content is saved as json files in your computer (where the bot is running)

Mode S3

Content is saved to an AWS S3 bucket.

.env

These are the environment variables that can be set in the .env file:

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
S3_BUCKET=my.bucket.name
S3_KEY_PREFIX=discord/moonwalks
settingdescription
AWS_ACCESS_KEY_IDThe access key value that can write to a folder in an AWS S3 Bucket.
AWS_SECRET_ACCESS_KEYThe secret value that pairs with the above key.
S3_BUCKETThe name of the S3 Bucket to publish the JSON thread data.
AWS_DEFAULT_REGIONAWS Region of the above Bucket.
S3_KEY_PREFIXAn optional S3 object prefix (folder path) where the JSON files will be published to. Example: discord/moonwalks

config.json

Here are other settings for the bot.

propdescription
prefixBot prefix, to interact with the bot with “legacy” commands (precursors to slash commands).
tokenBot token from the Discord App
ownerYour discord user id, which the bot will recognize as the owner.
client_idValue from the Discord App
test_guild_idId of the server you use for testing.

publishConfig

The key/values in here are specific to the /publish command.

propdescription
handlerOne of fsHandler.js or s3Handler.js Or another custom handler you or someone else has worked on.

Conventions that were not parameterized as settings

Solution reaction

A thread message is flagged as part of the solution by reacting to it with an emoji named :solution:.

You can create a server emoji and name it solution. Any message in a thread that has this emoji in its reactions, will be flagged as isSolution in the JSON.



Back to Post List
ok!