Discord Bot 构建套件 🤖

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:

I’ve altered the OP accordingly, sorry about that!!

3 个赞

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 个赞

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 个赞

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 个赞

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 个赞

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 个赞

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 个赞

Fair enough. Thanks for the help.

2 个赞

您好。

我目前正在使用您的插件,一切已处于可运行状态。看起来非常棒,做得好!

不过,我有几个问题:现在所有功能都已正常运行,我需要让用户通过 Discord OAuth 登录。这会创建一个新账户。

我该如何最好地管理这种情况?我是否需要合并新旧账户?我尝试用管理员账户进行操作,但在手动执行 !discsync 命令时收到错误提示:“您没有权限执行 discsync 命令!”

此外,它尚未从 Discourse 复制任何角色。

需要说明的是,我的 Discord 账户在选项中显示为已关联账户。

提前感谢您的帮助!

2 个赞

感谢您对插件的关注!

这不是插件的功能,而是核心功能。Discord OAuth 是 Discourse 默认自带的:

无论您是否将此插件添加到 Discourse,上述设置都会出现。

如果您通过社交账户登录,只要注册邮箱一致,系统就会识别该账户,不会创建新账户。但如果用户用于 Discord 注册的邮箱与 Discourse 不同,系统自然无法判断是同一用户,因此会创建新账户。

您指的是 Discord 服务器上的管理员账户吗?另外,您是否已授权该机器人?

执行 Ping! 的结果是什么?

4 个赞

同意这一点。在最坏的情况下,我可以合并电子邮件不匹配的账户。

是的,没错。我是 Discord 和 Discourse 实例的所有者。“Ping!” 的结果是 “Pong!”。没有任何角色从 Discourse 迁移到 Discord。

机器人已在我的 Discord 服务器上,并拥有管理员权限。能否请您澄清一下“授权”具体指什么?

3 个赞

您是否已完成此步骤?(只是确认所有前提条件,您几乎肯定已经完成了。)

2 个赞

是的,我有 :slight_smile:

1 个赞

我怀疑你在 Discord 服务器上的权限或机器人的权限设置可能有问题。我目前正在同时处理几十个插件,所以正在通过此插件重温相关知识。我对这个插件的上次修改已经是很久以前的事了!

1 个赞

收到!我这边快速检查了一下,供您知晓:我被列为服务器所有者,并拥有管理员权限。

编辑:能否明确一下机器人需要哪些权限?它目前被列为管理员(不过这是通过角色授予的,而非 OAuth 邀请)。

1 个赞

我的机器人有以下功能:

1 个赞

以下是我的(抱歉,作为新来的用户

,我需要发 3 个帖子……)

1 个赞

能否检查一下频道权限?Discord 上的频道权限会覆盖服务器权限。

1 个赞

是的,它在频道里运行正常。里面没有任何会阻止其发送或接收消息的权限设置。

它可以发送 Pong!,但它告诉我我没有启动 !discsync 所需的权限。

1 个赞

好的,我正在尝试复现,但到目前为止两个命令都能正常运行。

1 个赞