Shimell / DiscordWhitelisterSpigot

Spigot plugin that allows whitelisting users through a discord text channel.
MIT License
41 stars 22 forks source link

Allow whitelisting from bots #37

Closed mbfrog closed 3 years ago

mbfrog commented 3 years ago

I have a setup where new applicants submit whitelist request via a webhook. Server members then vote to accept the new member by adding reactions on the whitelist request. I want to automate the process of whitelisting new applications with a bot, but DiscordWhitelisterSpiggot rejects all messages from bots.

It would be nice if DiscordWhiteListerSpiggot could filter out only itself:

@@ -320,7 +320,7 @@ public class DiscordClient extends ListenerAdapter
             if (!Arrays.asList(targetTextChannels).contains(messageReceivedEvent.getTextChannel().getId()))
                 return;

-            if (messageReceivedEvent.getAuthor().isBot())
+            if (messageReceivedEvent.getMessage().getAuthor().getIdLong() == javaDiscordAPI.getSelfUser().getIdLong())
                 return;

             String messageContents = messageReceivedEvent.getMessage().getContentRaw();

I dont't thiunk it's necessary to add an "authorized bots" whitelist since this is manageable with the existing roles auhorizations.

Shimell commented 3 years ago

Yeah I can make the change, I did this in the past but currently the bot has no way of handling webhooks and spits out a few exceptions when trying to access a webhook as if its a normal discord user/bot. It should work if you are just running the whitelist command without assigning any roles automatically etc. I'll let you test it out.

Shimell commented 3 years ago

changed in 24afba37a7d129196f3ed5dc8e1262d643a4680b

mbfrog commented 3 years ago

I'm already running a patched version that works flawlessly. New applications are posted as discord messages (via a webhook, but it's not our concern here), server members react on them and my custom bot (member of the whitelist role) just sends the appropriate !whitelist commands.

Thanks for the quick fix though :)

Shimell commented 3 years ago

No problem, let me know if you face any issues related to this in the future.