"Discord Bot": run one on your Discourse server & keep things in sync

OK I’m trying to recreate, but so far I can run both commands.

1 Like

I’d be happy to invite you into my instance? I don’t know if your plugin logs anywhere, would be able to send you that if it helps?

EDIT: When you authorised the bot, what permissions did you allocate it there?

1 Like

The bot needs Administrator:

image

You need to grant permissions via the browser as described here (and in the OP):

something like: https://discord.com/api/oauth2/authorize?client_id=YOURCLIENTID&scope=bot&permissions=8

Your issue is almost certainly Discord side since the Discourse bot server seems to be running (you have shown this with the Ping! command), so Discourse logs will be irrelevant.

I’ve just retested this plugin on the latest Discourse version and everything is working (I updated a couple of gems to a more modern version to ensure compatibility with other plugins but this is irrelevant to your issue).

Yep, so I’ve reinvited it a couple of times with no change. It is an admin, it has the bot scope. I am the person inviting it to the discord, I’m the owner of the discord server. It just doesn’t recognise me and returns “You don’t have permission to execute command discsync!”

I’m bamboozled, unfortunately!

1 Like

Did you set these up in Discourse settings?:

image

2 Likes

Huzzah! It seems I managed to malform the Admin Group ID somehow! Looks like my copy/paste job may have missed a number…

So as a follow on question, I’m now trying to assign people colours in Discord based on their trust level in Discourse. To get trust levels to copy across, I reckon the command should be:

!discsync false, 0, true

Is this correct? It returns the following for me:

EDIT: The same is returned if I run the command without commas, i.e.:

!discsync false 0 true

2 Likes

Increase your Visibility Level. The standard automated Groups default to Visibility 1 (“Logged on users”), so if this value is zero you exclude the default automated Groups:

Zero will only include Groups visible to everyone including anonymous.

3 Likes

That is me squared away. Thank you very much - greatly appreciated.

Can I help out, in return, by writing some of what I have learned into your guide? If not, no dramas; I’m just hoping to pay forward your support.

3 Likes

That’s very kind. Would be delighted to have you edit it. You should be able to already? It’s a wiki

You helped me also to refresh my memory :slight_smile:

2 Likes

I don’t really need role syncing but a discord bot that posts in specific channels of the discord server when new topics are made in the forum, would be nice. Is there any plugin that can do that?

1 Like

Yeah this plugin is probably not the right tool for that. The bot is powered by your Discourse and can access your Discourse data (where permitted and prompted by command) but runs in a separate thread so will not be signalled by Discourse events.

I guess it might be feasible to extend it at some point to eg watch for a new Topics within a specific category. Not the best use of this architecture but PR welcome.

Sounds like you need to investigate?:

Or

1 Like

Yep, I investigated both of those options. The first option, Zapier, isn’t free. You can make up to 5 free Zaps and those are single-step zaps. This is exactly what was said in that thread, so the alternative that was proposed was the discourse-chat-integration which is supposedly an official plugin. I think this is the closest way to do what I want to do.

The last option seems to be an RSS feed plugin:

Update: After learning to properly setup the rules and configuring the webhooks, the chat-integration does exactly what I wanted! Thanks.

4 Likes

Hey @merefield,

thanks again for reaching out with this plugin!

I installed everything like described in the docs. I use this command: !discsync and everything is looking good to me. :smiling_face_with_three_hearts:

However for some users (not for all) I get for all of their groups this error:

Discourse Sync:  [11/31] Adding member 'MaxMustermann' to 'Member'
Discourse Sync:  I dont appear to have rights to do this though!
ERROR on server XYZ (ID: 123123123123) for command ^add_role, undefined method add_role' for nil:NilClass

Other users are able to be sync for the same group :thinking:

1 Like

That suggests your provider_uid in Discourse is not set for that user. Please investigate.

Well done for setting this up btw. It’s quite complex and not for the faint hearted! :).

2 Likes

I ran this query in the Knowledge Explorer Plugin:

SELECT *
FROM   user_associated_accounts  u 
WHERE  u.provider_name = 'discord' 

I can’t post the result for reasons :smile: but I checked every user for their provider_uid and each user has one. Is there anything else I could debug?

1 Like

Then the next most likely issue is that the currently mapped Discord UID is wrong.

ie the data in Discourse is not mapping to a valid UID in Discord.

Check this users record in Discord manually and confirm it is correct.

2 Likes

Hey, I can confirm this. The user has another UID in Discourse than in Discord.

How can this issue be reproduced?

1 Like

Could you delete the association and ask the user to recreate by associating Discord once more? If it happens again, something is buggy with the social login?

2 Likes

Hey,

I just wanted to do an follow up. I was talking to the people who had these issues. We could determine the possible issue.

The User signed up with his old discord account which he didn’t joined the server with. So the Sync Bot could not find the discord user I guess and errored.

2 Likes

Thanks for clarifying. Can you confirm how you resolved? Did you delete his association and then get him to reassociate?

1 Like