DiscordWidget

From Support Wiki
Jump to navigation Jump to search

DiscordWidget is a widget for Wikis to show a Discord server widget.

Summary

Related:

Dependencies

  • [[Template:DiscordWidget]]
  • MediaWiki:Common.js

Latest Branch

Make sure you enable your Widget in your Discord Server Settings:

Server Settings > Widget > Invite Channel (Welcome or Rules) > Enable Server Widget (Green Toggle)

You can also find the server ID in this screen.

mw.loader.load("https://commons.wiki.gg/wiki/MediaWiki:DiscordIntegrator.js?action=raw\u0026ctype=text/javascript");

<includeonly>
{{#if:{{{1|{{{id|}}}}}}|<span class="DiscordIntegrator"
  data-id="{{{1|{{{id}}}}}}"
  data-logged-in="{{{loggedIn}}}"
  data-theme="{{{theme|}}}"
  data-width="{{{width|75%}}}"
  data-height="{{{height|90%}}}">
  If you see this, your JavaScript might be disabled or DiscordIntegrator plugin isn't working. If the latter, please contact a wiki administrator.</span>
  |<strong class="error">DiscordIntegrator error: ID of the server isn't supplied.</strong> On instructions how to find a Discord server ID, see [https://support.discord.com/hc/articles/206346498 this]}}</includeonly><noinclude>
{{Documentation}}
[[Category:Templates]]
</noinclude>

{{DiscordWidget
|id     = serverID
|width  = 300px
|height = 500px
}}
<noinclude>[[Category:Templates]]</noinclude>

Paste {{Template:Discord}} anywhere.

Work with ThemeToggle

If the wiki has multiple themes, You can specify the discord widget's theme individually for each wiki theme by providing a configuration array in the data-theme attribute.

For example, there are 3 themes definded at MediaWiki:Theme-definitions:

* blue[bundled|default]
* red
* purple

Now you want to use dark discord theme for blue and red wiki themes, and light theme for purple wiki theme. You can configure it in Template:DiscordWidget:

...
<span class="DiscordIntegrator"
  ...
  data-theme='{{{theme| {"blue":"dark", "red":"dark", "purple":"light"} }}}'
  ...

The configuration array must follow valid JSON syntax including quoted property names.