Discord Bot Construction Kit šŸ¤–

Whoops, I deleted the wrong link from the OP. (There were two plugins, I should have deleted the OAuth one, but instead I deleted the link to the bot!)

Uninstall that plugin asap, as Core now supports Discord OAuth out of the box.

The bot plugin is THIS one:

https://github.com/merefield/discourse-discord-bot

Iā€™ve altered the OP accordingly, sorry about that!!

3 Likes

Do we know what the status might be of us getting this plugin to automatically update users at the time of their group joining instead of manually syncing? And potentially a way to tell it what groups/roles to sync together instead of it taking over / creating the roles itself?

2 Likes

First time thatā€™s been requested so as you might imagine, itā€™s not even in backlog as it were.

That would be quite tricky as the bot runs on a discrete thread. Youā€™d have to add a method to message the bot and ensure itā€™s listening for the request. An interesting exercise technically but not trivial.

Alternatively it might be better to explore a direct API call alternative instead of using the bot. Then you have to decide whether that warrants delivery in a different plugin based on discrete calls, not a bot.

Thatā€™s a not a bad idea but why do you need them to be different out of interest?

This is more practical.

PR accepted. Unfortunately my time is very limited to work on significant features without funding.

3 Likes

Well as it is now, it appears to base the roles off of the ā€œnameā€ instead of the title. Which means my roles on discord end up having dashing and no spaces for example. So I suppose an alternative solution is to have it base the roles not on the name but instead the full name, or default title.

That said, there are potentially groups on discourse that I would not want it to sync at all to discord.

Appreciate the responses :slight_smile:

2 Likes

This is on purpose to avoid keying off a description field which can:

a) have spaces in it
b) not be unique

(and is usually a terrible idea in computer science)

However, if there is a safe way of improving this Iā€™m all ears. I appreciate it doesnā€™t ā€˜lookā€™ very nice :slight_smile:

The plugin could definitely have additional functionality added to turn sync off for specific groups, at the adminā€™s discretion. PR accepted.

4 Likes

Could we have the bot auto sync at a scheduled time in the meantime while an API method is explored? Something like, check once every hour, or 24, etc ?

1 Like

I believe it would be possible to add ā€˜repeat this again after x hoursā€™ like functionality no problem.

The problem with that though is that will stop every time the bot goes down (e.g. on a reboot).

The absolute best approach would be to either:

a) add a discrete API call connected to a sidekiq job to this plugin OR
b) write a new plugin that used normal API calls instead of utilising a bot (and incorporate a batch sync in that).

Either of those things are going to need sponsorship or a PR.

1 Like

Fair enough. Thanks for the help.

2 Likes

Hi.

Iā€™m using your plugin currently and have everything at a workable point. It seems really nice, good work!

However, I have some questions: now that I have everything running I need my users to login via Discord OAuth. This creates a new account.

What is the best way for me to manage this? Do I need to merge the new and old accounts? I tried this with my Admin account and get the error ā€œYou donā€™t have permission to execute command discsync!ā€ when trying to manually !discsync.

Additionally, it has not yet copied across any roles from my discourse.

For awareness, my discord account shows in my options as being an associated account.

Thanks in advance for your help!

2 Likes

Thanks for your interest in the plugin!

This is not a feature of the plugin, this is a core feature. Discord OAuth is shipped with Discourse by default.:

image

The above settings appear regardless of you adding this plugin to your Discourse.

If you login via the social account, so long as the registration emails match, the account should be recognised and no new account will be created. If however, the user has signed up for Discord using a different email to Discourse, yes, of course, there is no way for it to know it is the same user, so a new account will be created.

Your admin account on the Discord server? Also did you authorise the bot?

What is the result of Ping!?

4 Likes

Ack to that. I can just merge accounts with non-matching emails in a worst case scenario.

Yep, thatā€™s right. Iā€™m the owner of the discord and discourse instances. The result of ā€œPing!ā€ Is ā€œPong!ā€. No roles have been migrated from the Discourse to Discord.

The bot is on my Discord server and has admin privs. Can I clarify what you mean by authorising?

3 Likes

Have you completed this step? (just checking all prerequisites, you almost certainly have).

2 Likes

Yeah, I have :slight_smile:

1 Like

My hunch is that your rights or that of the bot on the Discord server are not set up correctly somehow. Iā€™m just refreshing my memory with this plugin as I work on dozens. My last change to this one was a while back!

1 Like

Roger! Iā€™ve had a quick check on my side, so for your awareness I am listed as the server owner and I have admin rights.

EDIT: Can we clarify what rights the bot requires? Itā€™s currently listed as an admin (this was granted to it by a role as opposed to the OAuth invite, though).

1 Like

My bot has these:

image

1 Like

Here are mine (sorry, as a new user here

I need to make 3 postsā€¦)

1 Like

Could you check the channel permissions? Channel permissions on Discord override Server permissions.

1 Like

Yeah, itā€™s in the channel fine. There arenā€™t any permissions off in there that would prevent it from sending/receiving messages.

It can send Pong!, and it tells me I donā€™t have the required permissions to launch !discsync

1 Like

OK Iā€™m trying to recreate, but so far I can run both commands.

1 Like