When I ban a user plugin sends double message to discord. Anyone knows how to fix it? Thanks...
Ban messages being sent twice initially
Hello I tried to fix it and I think I have done. Please if you see something wrong let me know. Because I m not a developer and I can do big mistakes about coding.
I changed these lines
OnUserBanned(target.Name, target.Id, target.Address, reason, player);
target.Ban(GetLang("BanPrefix", target.Id) + reason);
as
target.Ban(reason);
OnUserBanned(target.Name, target.Id, target.Address, reason, player);
i have the same problem please fix it thx
Appears to be from having two plugins doing the same thing. Search your other plugins for ones using the OnUserBanned or OnPlayerBanned hooks. The first message is from this plugin, the second doesn't appear to be.
okay i fix it @Wulf can you fix it in the plugin ?
go to
private void ExecuteBan( IPlayer target, IPlayer player, string reason )
search
OnUserBanned( target.Name, target.Id, target.Address, reason, -1, player );
target.Ban( GetLang( "BanPrefix", target.Id ) + reason );
and change it to
target.Ban( GetLang( "BanPrefix", target.Id ) + reason );
OnUserBanned( target.Name, target.Id, target.Address, reason, -1, player );
it is in the wrong order
Hawkerokay i fix it @Wulf can you fix it in the plugin ?
go to private void ExecuteBan( IPlayer target, IPlayer player, string reason ) search OnUserBanned( target.Name, target.Id, target.Address, reason, -1, player ); target.Ban( GetLang( "BanPrefix", target.Id ) + reason ); and change it to target.Ban( GetLang( "BanPrefix", target.Id ) + reason ); OnUserBanned( target.Name, target.Id, target.Address, reason, -1, player ); it is in the wrong order
I don't see anything wrong with the order there. The target.Ban is the actual banning on the server, the OnUserBanned is the sending of the message to Discord.
yes but OnUserBanned is the send to the discord
and the target.Ban is the message on the server
but in the original order the plugin additionally sends the server message to Discord
it works i have test it
Hawkeryes but OnUserBanned is the send to the discord
and the target.Ban is the messag on the server ?
but in the original order the plugin send the message to the discord
it works i have test it
If the player was banned before or after the message is sent to Discord would not change the duplication.
and why is the error gone when i change the order?
Hawkerand why is the error gone when i change the order?
It isn't an error, it's just only showing once because the user is already technically banned.
Looking into the duplication more though, I believe we've found the cause. Changing the order isn't the fix, it just needs to be changed some to prevent the OnUserBanned hook from being called twice for the actual ban.
there must be more, i just see that even in the ban.cfg the same error is deposited as in the discord at the message
banid 7xxxxxxxxxxxxxx "Unknown" "Banned: {0}Banned" -1