Package com.example.common.command
Class HelpCommand
java.lang.Object
com.example.common.command.BaseCommand
com.example.common.command.HelpCommand
- All Implemented Interfaces:
Command
The HelpCommand class represents a command that displays all available chat commands to a client.
-
Field Summary
Fields inherited from class com.example.common.command.BaseCommand
chatInterface, description, messageSender, name
-
Constructor Summary
ConstructorsConstructorDescriptionHelpCommand
(MessageSender messageSender, ChatInterface chatInterface, CommandsInterface commands) Constructs a HelpCommand with the given MessageSender, ChatInterface, and CommandsInterface. -
Method Summary
Modifier and TypeMethodDescriptionexecute
(BodyMessage bodyMessage) Executes the HelpCommand by sending the list of available commands to the requesting client.Methods inherited from class com.example.common.command.BaseCommand
getDescription, getName
-
Constructor Details
-
HelpCommand
public HelpCommand(MessageSender messageSender, ChatInterface chatInterface, CommandsInterface commands) Constructs a HelpCommand with the given MessageSender, ChatInterface, and CommandsInterface.- Parameters:
messageSender
- The MessageSender object for sending messages.chatInterface
- The ChatInterface managing clients in the chat.commands
- The CommandsInterface containing all chat commands.
-
-
Method Details
-
execute
Executes the HelpCommand by sending the list of available commands to the requesting client.- Parameters:
bodyMessage
- The BodyMessage containing the command details.- Returns:
- The execution status of the command (SUCCESS or ERROR).
- Throws:
IOException
- if an I/O error occurs during message sending.
-