Package io.github.unknowncoder56.javaslc
Class Bot
java.lang.Object
io.github.unknowncoder56.javaslc.User
io.github.unknowncoder56.javaslc.Bot
The main class of the library containing all important methods, like to run the bot. This class cannot be instantiated directly, use
BotBuilder instead.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe enum containing all possible change keys. -
Field Summary
Fields inherited from class io.github.unknowncoder56.javaslc.User
errorListener, userId -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCommandListener(CommandListener commandListener) Adds aCommandListenerto the bot.change(Bot.ChangeKey changeKey, String changeValue) This method changes a bot property defined in theBot.ChangeKeyenum.longGets the user ID of the bot.Gets the list ofCommandListeners of the bot.Gets the prefix of the bot.Gets theStartListenerof the bot.join(long serverId) This method joins a server.voidrun()The method to run the bot.This method sends a message to a server.voidSets the prefix of the bot.voidsetStartListener(StartListener startListener) Sets theStartListenerof the bot.Methods inherited from class io.github.unknowncoder56.javaslc.User
getAccountCreationDate, getErrorListener, getJoinedServerIds, getLabelJsonObject, getNickname, getProfileImageUrl, getUserId, getUsername, setErrorListener
-
Method Details
-
run
public void run()The method to run the bot. This method will throw aRuntimeExceptionif the prefix, token or bot user ID is not set in theBotBuilderor later inBot. -
send
This method sends a message to a server. This method will throw aRuntimeExceptionif the bot is not in the server. To fix it add it to a server withjoin(long).- Parameters:
message- The message to send.serverId- The ID of the server to send the message to.- Returns:
- A
CompletableFuturethat will be completed when the message is sent. - See Also:
-
join
This method joins a server. This method will throw aRuntimeExceptionif the bot is already in the server.- Parameters:
serverId- The ID of the server to join.- Returns:
- A
CompletableFuturethat will be completed when the bot has joined the server.
-
change
This method changes a bot property defined in theBot.ChangeKeyenum.- Parameters:
changeKey- The key of the value to change.changeValue- The value to change the key to.- Returns:
- A
CompletableFuturethat will be completed when the value is changed. - See Also:
-
getPrefix
Gets the prefix of the bot.- Returns:
- The prefix of the bot.
-
setPrefix
Sets the prefix of the bot.- Parameters:
prefix- The prefix to set.
-
getStartListener
Gets theStartListenerof the bot.- Returns:
- The
StartListenerof the bot.
-
setStartListener
Sets theStartListenerof the bot.- Parameters:
startListener- TheStartListenerto set.
-
getBotUserId
public long getBotUserId()Gets the user ID of the bot.- Returns:
- The user ID of the bot.
-
getCommandListeners
Gets the list ofCommandListeners of the bot.- Returns:
- An
ArrayListcontaining theCommandListeners of the bot.
-
addCommandListener
Adds aCommandListenerto the bot.- Parameters:
commandListener- TheCommandListenerto add.
-