Get back command console output from dispatchCommand()

Discussion in 'Plugin Development' started by HelpMeILostMyAccount, Jul 29, 2019.

Thread Status:
Not open for further replies.
  1. Hello everyone. I've gotten my plugin's ConsoleCommandSender instance to dispatch a command, but I would like to grab the command feedback as a String and utilize it in my application. How can I do this?

    For example, you'd do "/kill" and get back "Killed (target's name)", but the dispatchCommand() method is a boolean.
     
  2. Offline

    Kars

  3. Offline

    timtower Administrator Administrator Moderator

  4. @Kars It was a show of concept, I'm just asking if I can do the same while getting the output (Thank you for the answer)
    @timtower You see, I'm combining two APIs, and I want a given string input from the other API to dispatch a command. However, for the whole time, I can only know if the command ran, or if the command didn't run. But the command doesn't work, even when onCommand returns true. (The API would send "/kill", and get back "Command executed successfully", but nothing happened). I'd like my other API to get the command feedback as well. So, instead of "command has been run", I can get "Given (items) to (player)".

    You see what I mean?
     
  5. Offline

    Kars

  6. Offline

    timtower Administrator Administrator Moderator

    @HelpMeILostMyAccount API that only runs through commands isn't really an API. API means that you can talk to it through code.
    I asked to see if there was a different method for you. But I think that you are stuck with the logger as Kars suggested.
     
  7. Offline

    Machine Maker

  8. Offline

    timtower Administrator Administrator Moderator

    You can trigger the commands but not see the result.
     
  9. Alright, some more context. I'm using Discord JDA for Discord bots in combination with CraftBukkit. I want to have a channel in my Discord server that the bot will recognize as a console. If an approved moderator sends a message there, the plugin shall dispatch it as a command, and send the Discord channel whatever the return message was.
     
  10. Offline

    timtower Administrator Administrator Moderator

    @HelpMeILostMyAccount Then you also need to take into account that things can be delayed and have multiple messages.
     
  11. Offline

    Machine Maker

    Probably a better way would be to use a Handler to capture everything and post it in that discord channel.
     
  12. Offline

    timtower Administrator Administrator Moderator

    You mean as in the discord channel becomes a full log?
     
  13. upload_2019-7-30_9-48-4.png

    For some reason, my console says "An unexpected error occurred trying to execute that command", but the command did work. I have 20 golden apples.

    [​IMG]

    [​IMG]
     
    Last edited: Jul 30, 2019
  14. Offline

    timtower Administrator Administrator Moderator

  15. @timtower Edited. That command worked. Something weird is going on there

    You guys are saying I should use logger filtering to find what messages correspond to my sent commands?
    Where can I start to learn how?
     
  16. Offline

    timtower Administrator Administrator Moderator

    An unexpected error occurred trying to execute that command
    If it says that then there should be an error log as well.
     
  17. There is nothing else. I swear.

    upload_2019-7-30_10-1-51.png

    It's just that.
     
  18. Offline

    Machine Maker

    Yeah. That just seems simpler than trying to figure out what messages were sent because of what command.

    I'd be more of a console then a log, but you wouldn't have to do any other stuff to filter out messages.
     
  19. How can copy logs to the Discord channel?
     

    Attached Files:

  20. Offline

    timtower Administrator Administrator Moderator

  21. Offline

    timtower Administrator Administrator Moderator

    @HelpMeILostMyAccount Start by printing the commands that are being executed.
    And find out what is doing the error handling, because it isn't Bukkit.
     
Thread Status:
Not open for further replies.

Share This Page