Can't ban player using command from Discord
Opened this issue · 9 comments
Issue
When i tried to ban a player from Discord using a command, it showing an error like this
Here is the error from TShock log file
2021-03-27 07:13:03 - Utils: INFO: kхумаеди executed: /ban add Rushema 0 test.
2021-03-27 07:13:03 - Command: ERROR: System.NullReferenceException: Object reference not set to an instance of an object.
at TShockAPI.Commands.Ban(CommandArgs args)
at TShockAPI.Command.Run(String msg, Boolean silent, TSPlayer ply, List`1 parms)
Server Information
TShock Version: 4.4.0.0
Terracord Version: Terracord 1.2.3
Greetings, @munukhu.
This is not an issue with Terracord itself. This error is coming from TShock. Commands simply get passed to TShock by Terracord. There is no syntax checking or validation. It is up to the issuer to ensure that the command is legitimate. In this case, it looks like the server cannot find a player with the name "Rushema". As a result, you're getting a null reference.
You have the ban
syntax right. However, see below for what happens when a user is not online or is not saved while offline. This seems to be what is happening in your situation. I'll keep this issue open for at least 7 days in case you have any additional information that you would like to include.
: ban
Server executed: /ban.
Ban Sub-Commands (1/2):
add <target> <time> [reason] - Bans a player or user account if the player is not online.
...
: ban add test 0 some reason
Server executed: /ban add test 0 some reason.
Unable to ban target test.
Target is not a valid IP address, a valid online player, or a known offline user.
Hi @ldilley
Thank you for your response. I know ban
command only work for registered user. In this case user with the name "Rushema" is Registered User but we still can't ban the user from command that send remotely from Discord.
I also tried to ban other user with name "Break" this user is Registered user and Online User as you can see from the image bellow.
But when i tried to ban this user the result was error and the error message was same like before.
The error message was different if i ban random player that not exist
Thank you for the follow up, @munukhu.
Unfortunately, I am currently unable to test the ban
command since the Terraria client was recently updated on Steam. My client version is now out of sync with the TShock server (until TShock releases a new executable). We need to validate the input being sent to TShock. The error message, "Command failed, check logs for more details.", is coming from TShock and not Terracord. Is there any other output in the TShock logs (other than the exception you originally included)? Can you execute the same command within the TShock console successfully?
Hi @ldilley.
The error still same like this
2021-03-27 20:25:18 - Utils: INFO: kхумаеди executed: /ban add Break 0 test.
2021-03-27 20:25:18 - Command: ERROR: System.NullReferenceException: Object reference not set to an instance of an object.
at TShockAPI.Commands.Ban(CommandArgs args)
at TShockAPI.Command.Run(String msg, Boolean silent, TSPlayer ply, List`1 parms)
But when i tried to ban player from TShock Console, the ban command result was successfully
Apologies for the delay, @munukhu -- I was waiting for TShock 4.5.x to release so that I could test this. I can now confirm that ban
is indeed broken. My exception output is below. This seems like an issue with TShock considering the following:
- Other commands still work fine.
- Specific TShock methods are called which return the exception (one of these TShock methods may not be receiving the correct input from
Commands.HandleCommand()
). - The signature for
Commands.HandleCommand()
looks like this:
Commands.HandleCommand(TSPlayer player, string text)
And Terracord is passing the following arguments which seem correct (and works for other commands):
Commands.HandleCommand(user_from_Discord_as_a_TSPlayer_object, "/ban add Potato 0 test");
The same command does work fine from within the TShock console. An issue can be opened with the TShock project for them to look further into this issue if you wish. Feel free to reference this issue.
2021-04-19 17:30:08 - Command: ERROR: System.NullReferenceException: Object reference not set to an instance of an object.
at TShockAPI.Commands.<Ban>g__DoBan|21_3(String ident, String reason, DateTime expiration, <>c__DisplayClass21_0& )
at TShockAPI.Commands.<Ban>g__AddBan|21_4(<>c__DisplayClass21_0& )
at TShockAPI.Commands.Ban(CommandArgs args)
at TShockAPI.Command.Run(String msg, Boolean silent, TSPlayer ply, List`1 parms)
I think tShock changed their ban implantation awhile back maybe that's why you're having this issue. Can't remember exactly if banning from discord worked before, but either way I'll look into this and see what I can do.
Thank you for your response and thank you for looking at this issue, i will waiting for your update
Hi @moisterrific and @ldilley
First of all, thank you for helping me to investigate this issue. I'm looking for update about this issue, did anyone found the resolution about this issue?
I just tested and the symptoms persist in the latest TShock release (4.5.4). I am not certain if @moisterrific ever looked into it further from a TShock perspective. As I mentioned before, I'd suggest reporting the problem to TShock. As a workaround until a fix can be implemented on the TShock side, use the ban
command in the console. I am closing this issue since the root cause is not due to this plugin.