Discord Bot Construction Kit 🤖

Allright. That’s a bit of a bummer since I just enforced threads in the support chans of our Discord to get a better overview of support cases. And I am not sure it actually gives that - but luckily there’s other advantages.

Do you have an ETA on the API and an idea of what it would cost to back the feature?




I did chase recently and it’s been in development for some time. I’ll chase again and revert, but be warned, the last time they told me “it’ll be done when it’s done” … the problem with open source is often a lack of a good way of directing appropriate levels of community funding (or lack thereof) to assist with focus and prioritisation … we’ll see …

From my end I’d have to see the final implementation to estimate the effort.

The challenge might be that whilst it’s straightforward to copy across messages, keeping Threads in sync with Topics may require some kind of mapping maintained in Discourse, e.g. a custom field or table that maps Discord Threads to Discourse Topics, so when a new message gets added to a Thread you know where to put it in Discourse.

Can you elaborate on exactly the functionality/behaviour you are seeking?


Yeah that sucks to be depending on something you can’t influence.

My idea is very inspired on the article and the discoussion on the Discourse blog on how well Discord and Discourse supplement each other. When we started our Discord server almost two months ago we didn’t really know how it would evolve and how it would affect our existing (but barely configured) Discourse forum but it looks like people still use it as well as our Discord for asking technical support questions (I am with the FOSS project CrowdSec). So basically I completely buy in on the idea to use Discourse as a more long term memory and sync Discord threads to Discourse under topics matching Discord channels (and vice versa). The way I see it, it can be done much more effectively (e.g. automated) by using threads.

As I said I recently enforced threads on Discord which means that it’s not always very easy to get an overview of threads for those of our developers that are assigned to user support. So I want to use the sync to Discourse also as a good way for them to keep updated on questions to answer whilst not being sucked too much into the Discord chitter-chatter.

Does that makes sense? And is there some other way to achieve this on a shorter time frame maybe?


Hi @merefield !

I’m reaching out to you here because I don’t think my github Issue was seen, and I’m thinking this is the next best place.


We’ve been getting an error that we’ve tracked down to the discord bot plugin. The above image shows the inspect element error, but any user who sends a PM also gets a “500 Error” visual when their PM is sent. The PM is still sent successfully, but this error makes it seem otherwise. After disabling the plugin, the issue no longer exists.

I’m pretty sure the issue is coming from /lib/discourse_event_handlers.rb. I’m assuming that a PM is triggering the post_created DiscourseEvent which makes it try to access the post’s category via posted_category = post.topic.category.id, which causes the error.

I hope this helps and I hope this can be resolved soon. Thanks


Thanks for the report. Sounds about right. Might get chance to look at it this week …


Fantastic, thank you! We’ll keep an eye out for the update. :+1:


Heads up that I’m drowning in client work atm so this may not get looked at for a little while.

In the meantime PR accepted.

In general I would welcome more community contribution to the free plugins.


Things are preeeetty busy for me atm, but I’ve pushed what I believe is a fix:

FIX: exclude private messages from bot event considerations · merefield/discourse-discord-bot@82b2109 (github.com)

Seems to work now and the dreaded 500 on PM’s is gone …


Oh, that’s wonderful and replaces Discord Chat!

¿It has supposed to read slug names on Discourse or just titles?

1 Like

Discord does not manage by slugs in the same way, so iirc it is titles.


Hello, I don’t know if this was questioned before but, the OAuth credentials must be the same as the app? Cause right now we are using another discord sync integration and the OAuth fields are already filled. Thanks.

1 Like

This plugin is compatible with the official social login solution in core. The bot needs a token from an authorised Discord app. The social login allows the plugin to identify the same user across the two platforms.


thanks for the answer! I’ll debug a little bit more to see what I’m missing on the setup.


I don’t think it needs to be the same discord app but try it!


Hello here!
Searching the forum for a way to give the Discourse users a different Trust Level based on a Discord account brought me here.

We already have a pretty active community on Discord and brought in Discourse lately for more organized discussions.

I am looking for a solution that goes like this. A member that logins with their Discord account and has a specific role on Discord automatically receives a Trust Level 1 on Discourse.

Would this Bot Kit be the right starting point for such an implementation?

Thank you

1 Like

This bot afaik is “one-way” from Discourse to Discord. There aren’t any functions that are the opposite that are built.

Personally I think you’d find it a bit easier to accomplish this with outside code that is watching the user events webhook of your discourse install.

Webhook event out → Grab discord user ID from Discourse database (requires using Discord authentication) → Grab roles using discord.js, .py, etc. → Assign role with Discourse API request

In order to get the Discord ID you need to use the Data Explorer plugin and create the following query:

-- [params]
-- string :user
SELECT u.username, u.id, a.user_id, a.provider_name, a.provider_uid
FROM users u
JOIN user_associated_accounts a on a.user_id = u.id
WHERE u.username = :user

You can then look up the Data Explorer plugin documentation and hit that query with an API request to get the ID.

Hope this helps somewhat.

1 Like

Whilst this is true for role sync, this is otherwise not correct.

From the OP:

So plenty of Discord → Discourse behaviour and far from just a ‘role sync’ bot.

As ever PR welcome for any generally useful additional functionality. It would be good to have some additions from the community. :eyes:


Thank you for this post @merefield

Could I get your discord? I would like to ask you some questions if that’s okay.

To keep knowledge open and indexed for everyone it’s probably best to ask the questions here. Discord is a black hole for information. Stuff goes in and is then never found again :slight_smile: And otherwise, we also have chat here on Discourse.

1 Like

Hi Kene, if it’s not of a commercial nature, would appreciate if you could ask your questions here so that the community might benefit from (or even answer) them