XF2 [8WR] Discord Integration

XF2 [8WR] Discord Integration [Paid] 2.3.0.4

No permission to buy ($30.00)
As a side note: Posting new threads to Discord is broken if a custom message has been provided.

Fix:
\src\addons\EWR\Discord\Entity\Post.php lines 112-117:
PHP:
$content = str_ireplace(
    ['{user}', '{title}', '{node}', '{url}'],
    ['{user}', '{title}', '{url}'],
    [$thread->username, str_replace('@', '@𝅳', $thread->title), $thread->Forum->title, $url],
    $discord['threads']['message']
);
->
PHP:
$content = str_ireplace(
    ['{user}', '{title}', '{node}', '{url}'], // search
    [$thread->username, str_replace('@', '@𝅳', $thread->title), $thread->Forum->title, $url], // replace
    $discord['threads']['message'] // subject
);
The call to str_ireplace has the args in the wrong order. The 4th param gets passed in (which is the $count out param), and the replacement array repeats the placeholders instead of the values. Thus, $content becomes an array instead of a string, so Discord rejects the payload.
 
As a side note: Posting new threads to Discord is broken if a custom message has been provided.

Fix:
\src\addons\EWR\Discord\Entity\Post.php lines 112-117:
PHP:
$content = str_ireplace(
    ['{user}', '{title}', '{node}', '{url}'],
    ['{user}', '{title}', '{url}'],
    [$thread->username, str_replace('@', '@𝅳', $thread->title), $thread->Forum->title, $url],
    $discord['threads']['message']
);
->
PHP:
$content = str_ireplace(
    ['{user}', '{title}', '{node}', '{url}'], // search
    [$thread->username, str_replace('@', '@𝅳', $thread->title), $thread->Forum->title, $url], // replace
    $discord['threads']['message'] // subject
);
The call to str_ireplace has the args in the wrong order. The 4th param gets passed in (which is the $count out param), and the replacement array repeats the placeholders instead of the values. Thus, $content becomes an array instead of a string, so Discord rejects the payload.
So this explains why whenever we make a new thread/post after updating (all of our messages with threads and posts are a bit modified from the ones that are set by the addon itself) suddenly we're not seeing any of them get pushed through to Discord anymore....

How do we re-order or fix this...?? @Jaxel or @SeToY would certainly appreciate your insight...

Thanks all!
 
Hmm... it looks like I fixed the bug in my internal files on 2024-12-05... I just never released the update.

I'll release the update soon.
 
Hey @Jaxel

First off, love your Discord Integration add-on, been using the role sync and bot features and they work great.

I wanted to share something I ended up building for the chat/embed side of things. I spent about a week trying to get WidgetBot working (the clusters kept going down, SSL errors, the setup process was painful) and eventually just gave up on it. So I wrote my own lightweight Discord chat viewer instead.

It's a PHP script that uses the Discord REST API through a bot to pull channels and messages, then displays them in a Discord-style UI that I iframe into a XenForo Page node. No external server needed, no Node.js, runs entirely on shared hosting (Bluehost/cPanel in my case). It reads channels, messages, embeds, reactions, custom emoji, attachments, role colors, the whole thing. The bot only sees channels its role has access to, so private channels stay private.

It's read-only on purpose. The idea is to give website visitors a live preview of the Discord activity so they're tempted to actually join. There's a native Discord widget on the side showing online members and a Join button.

Some details if anyone is curious:
  • Pure PHP backend with file-based caching (5 sec for messages, 5 min for channels)
  • Polls every 8 seconds for new messages, reactions, edits
  • Smart message windowing: always shows last 30 messages minimum, but expands to show everything from the last 5 hours if the channel is active
  • Lazy cache cleanup built in, no cron needed
  • Mobile responsive with a channel dropdown when the sidebar is hidden
  • Under 1000 lines of code total

Here's how it looks:

discord_bot.webp

Not trying to replace your add-on at all, yours handles the important stuff like role sync and bot management. This just fills the gap that WidgetBot was supposed to fill but never reliably could.

If you're interested in integrating this as an alternative option alongside WidgetBot, I'm happy to share the files and contribute it for a future update. Either way, figured someone else here might find the idea useful.

Cheers!
 
Hi, I have using years of this awesome add-on and very happy about it, but some reason it does not work right now.
Users can't currently get discord roles when registering to the forum.

It gives me this error:

upstream connect error or disconnect/reset before headers. reset reason: connection timeout

Thanks!
 
Hi, I have using years of this awesome add-on and very happy about it, but some reason it does not work right now.
Users can't currently get discord roles when registering to the forum.

It gives me this error:

upstream connect error or disconnect/reset before headers. reset reason: connection timeout

Thanks!

That's an error on Discord's side, I believe. I had that same issue overnight with my Discord widget bots on my website. It's corrected itself this morning.

While I've noticed some of my connectivity between XF and Discord is not happening as it use to, that's been the case for a bit. Haven't had a chance to post here or ask @Jaxel about it. Could be Discord made some changes...l not sure..

But that above, is the EXACT error I had last night from my widgets.
 
That's an error on Discord's side, I believe. I had that same issue overnight with my Discord widget bots on my website. It's corrected itself this morning.

While I've noticed some of my connectivity between XF and Discord is not happening as it use to, that's been the case for a bit. Haven't had a chance to post here or ask @Jaxel about it. Could be Discord made some changes...l not sure..

But that above, is the EXACT error I had last night from my widgets.

Yeah. It's on Discords side. All members can't connect to our server and it says increased api errors.
 
It happened to me too, but this was just Discord having issues, it's not an issue with the plugin. You can clear the errors from your forum log.
 
Back
Top Bottom