RoinujNosde / SimpleClans

Full featured Clan system for Minecraft
https://www.spigotmc.org/resources/simpleclans.71242/
GNU General Public License v3.0
49 stars 35 forks source link

Discord, duplicating clan channels at reboot #436

Open TomLewis opened 1 month ago

TomLewis commented 1 month ago

Describe the bug I had this bug previously, https://github.com/RoinujNosde/SimpleClans/issues/434 And it was disagnosed as Clan channels duplicating along with simpleclans needing to be the latest dev build.

After reboot yesterday, SimeplClans randomly decided to create a bunch of duplicates for a clan "ee", nothing has changed on the server or discord, it just decided to do it at reboot.

Theres a bug somewhere thats duplicating channels, and in this case its created 3 all at once for one clan, this in turn breaks ALL of the discod chat for every single clan, not just this clan.

Can we please get some logic thats checking for existing channels, there must be some sort of API issue with discord that happens randomly, and then you tell it to make new channels over and over until it can check it exists, and then theres 3 or 4 etc.

image

To Reproduce Steps to reproduce the behavior:

  1. Reboot the server

Expected behavior To not do this

Software (please complete the following information):

Tomut0 commented 1 month ago

Can I ask you to enable SimpleClans' debug and try to reproduce your issue? SimpleClans should throw an error in console when there are duplicated channels appears at server boot.

RoinujNosde commented 1 month ago

Are you running SimpleClans in 3 servers? All connected to the same Discord server?

TomLewis commented 1 month ago

Are you running SimpleClans in 3 servers? All connected to the same Discord server?

Nope, just 1 server.

Can I ask you to enable SimpleClans' debug and try to reproduce your issue?

Yeah sure, its already on from the last issue! haha

https://gist.github.com/TomLewis/bddcda8ec67c035aa4457b134f1b3153

And boot https://gist.github.com/TomLewis/7036d0a2b38d318fa595dd1488a675db

Tomut0 commented 1 month ago

You told us those discord channels were created on boot, However, I am sure they were created earlier. It follows from the error exception you sent us:

java.lang.IllegalStateException: Duplicate key ee (attempted merging values <#1092075569082015764> and <#1269260858488389694>)

Which means SimpleClans somehow passed through 2 layers of protection: 1 Layer: It removes already used discord channels from the creation. 2 Layer: It actually does checking on channel existence before the creation.

I am going to add some more debug messages to this process at #437.

TomLewis commented 1 month ago

Weird! Sounds good to me, If you add debug messages at boot at every stage to output to console, then I can wait for my reboot and see what its checking for what and I can report back, then we can see if its doing things at the right time!

Does it cache these channels from discord or is it doing a fresh check each reboot? Because these discord channels shouldnt ever be touched outside of this plugin by anything or anyone, silly question but shouldnt each discord channel have an ID thats unique? then each clan can just have that as their discord channel ID, and not its name being unique, that solves the bug where if there is another channel created its not going to fully break.

I just dont know how you solve bad API calls back from discord, if they are temp down, or if theres some sort of issue in the pipeline if its checking for a channel to see if it exists already and keeps trying..

Tomut0 commented 1 month ago

clan can just have that as their discord channel ID, and not its name being unique

It was made on purpose. Storing Clan <-> Discord ID in a separated file or in config.yaml is an unnecessary I/O task.

how you solve bad API calls back from discord, if they are temp down

It actually doesn't happen much, but even so, simple server restart should fix any troubles.

Tomut0 commented 1 month ago

@TomLewis It was just merged, can you try it? It was uploaded on Jenkins.

TomLewis commented 3 weeks ago

Sorry, I completely forgot about this.

So I just noticed today, I have 6 new channels for the Crew "EE" image

So I wondered, if its always EE why not see if a crew leader is running the command.

Looked on my coreprotect web UI and, low and behold a crew leader for EE is spamming the command, ignore their username, the coreprotect web UI is ancient and displays old usernames.

image

They used it 7 times, but when I look at my log, there is no simpleclans feedback on what its doing.

[10:36:39] [Server thread/INFO]: Tulipss issued server command: /crew discord create
[10:36:39] [Server thread/INFO]: [Matrix] (Via) Player Exoticial joined with (1.21.X/767) client
[10:36:41] [Server thread/INFO]: Tulipss issued server command: /crew discord create
[10:36:42] [Async Chat Thread - #1/INFO]: *--------- Rule match (chat) for Nick_A_Naut --------- 
[10:36:42] [Async Chat Thread - #1/INFO]: MATCH: \bwb\b
[10:36:42] [Async Chat Thread - #1/INFO]: CATCH: wb
[10:36:42] [Async Chat Thread - #1/INFO]: UPDATE: welcome back
[10:36:42] [Async Chat Thread - #1/INFO]: [global] Nick_A_Naut: welcome back
[10:36:42] [Async Chat Thread - #1/INFO]: [global] Dim30: I am back
[10:36:42] [Server thread/INFO]: Tulipss issued server command: /crew discord create
[10:36:43] [Server thread/INFO]: Tulipss issued server command: /crew discord create

so now, im thinking, maybe its stuck somewhere doing a check when they run the command, its also suppose to charge them to do this, but I can't see any logs that that, happened either.

Im going to ask the player why they did this and what feedback they had from the plugin, otherwise im in the dark with no logs in the console.

but thought I would update as this popped out to me today!

I will get that jenkins build added now for tomorrows reboot.

Tomut0 commented 3 weeks ago

if you have enabled show-debug-info in SimpleClans config and use the latest development build (from Jenkins). You should see something like this after command execution:

[23:52:23 INFO]: Tomut0 issued server command: /clan discord create
[23:52:23 INFO]: [SimpleClans] [51] Creating a discord text channel for test clan
[23:52:23 INFO]: [SimpleClans] Added view permission to null (194521791824265216) discord member
[23:52:23 INFO]: [SimpleClans] Added leader role to null (194521791824265216) discord member

However, if the clan was already created, it will return nothing to the console.