Kit de Construção para 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 curtidas

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 curtidas

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 curtidas

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 curtidas

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 curtidas

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 curtida

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 curtida

Fair enough. Thanks for the help.

2 curtidas

Olá.

Estou usando seu plugin atualmente e consegui colocar tudo em um ponto funcional. Parece muito bom, ótimo trabalho!

No entanto, tenho algumas perguntas: agora que tudo está funcionando, preciso que meus usuários façam login via Discord OAuth. Isso cria uma nova conta.

Qual é a melhor maneira de eu gerenciar isso? Preciso mesclar as contas nova e antiga? Tentei fazer isso com minha conta de administrador e recebi o erro “Você não tem permissão para executar o comando discsync!” ao tentar usar o comando !discsync manualmente.

Além disso, ele ainda não copiou nenhum papel do meu Discourse.

Para sua informação, minha conta do Discord aparece nas minhas opções como uma conta associada.

Agradeço antecipadamente pela ajuda!

2 curtidas

Obrigado pelo seu interesse no plugin!

Isso não é um recurso do plugin, é um recurso central. O Discord OAuth já vem incluído no Discourse por padrão:

As configurações acima aparecem independentemente de você adicionar este plugin ao seu Discourse.

Se você fizer login por meio da conta social, desde que os e-mails de registro coincidam, a conta será reconhecida e nenhuma nova conta será criada. No entanto, se o usuário se inscreveu no Discord usando um e-mail diferente do usado no Discourse, claro, não há como o sistema saber que se trata do mesmo usuário, então uma nova conta será criada.

Sua conta de administrador é no servidor do Discord? Você também autorizou o bot?

Qual é o resultado do Ping!?

4 curtidas

Concordo com isso. No pior dos cenários, posso simplesmente mesclar contas com e-mails que não correspondem.

Sim, está correto. Sou o proprietário das instâncias do Discord e do Discourse. O resultado do “Ping!” é “Pong!”. Nenhuma função foi migrada do Discourse para o Discord.

O bot está no meu servidor do Discord e tem privilégios de administrador. Posso esclarecer o que você quer dizer com “autorizar”?

3 curtidas

Você concluiu esta etapa? (apenas verificando todos os pré-requisitos, você quase certamente já concluiu).

2 curtidas

Sim, eu tenho :slight_smile:

1 curtida

Meu palpite é que suas permissões ou as do bot no servidor do Discord não estão configuradas corretamente de alguma forma. Estou apenas relembrando como funciona este plugin, já que trabalho com dezenas deles. Minha última alteração nele foi há bastante tempo!

1 curtida

Roger! Fiz uma verificação rápida do meu lado, então, para sua ciência, estou listado como o proprietário do servidor e tenho direitos de administrador.

EDIT: Podemos esclarecer quais direitos o bot precisa? Atualmente, ele está listado como administrador (isso foi concedido a ele por meio de uma função, e não pelo convite OAuth, no entanto).

1 curtida

Meu bot tem isso:

1 curtida

Aqui estão os meus (desculpe, como sou um novo usuário aqui

, preciso fazer 3 postagens…)

1 curtida

Você poderia verificar as permissões do canal? As permissões do canal no Discord têm precedência sobre as permissões do servidor.

1 curtida

Sim, está no canal sem problemas. Não há nenhuma permissão desativada lá que impediria o envio ou recebimento de mensagens.

Ele consegue enviar Pong!, mas me informa que não tenho as permissões necessárias para executar !discsync

1 curtida

OK, estou tentando recriar, mas até agora consigo executar ambos os comandos.

1 curtida