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 property 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.voidaddMessageListener(MessageListener messageListener) Adds aMessageListenerto 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 list ofMessageListeners of the bot.Gets the prefix of the bot.Gets theStartListenerof the bot.join(long serverId) This method joins a server if not already joined by the bot.voidrun()The method to run the bot.This method sends a message to a server if the bot is in it.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, isBot, setErrorListener
-
Method Details
-
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.- Throws:
RuntimeException- If the prefix, token or bot user ID is not set.
-
send
This method sends a message to a server if the bot is in it. If not this method will fail, 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 if not already joined by the bot.- 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 property 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.
-
getMessageListeners
Gets the list ofMessageListeners of the bot.- Returns:
- An
ArrayListcontaining theMessageListeners of the bot.
-
addMessageListener
Adds aMessageListenerto the bot.- Parameters:
messageListener- TheMessageListenerto add.
-
getCommandListeners
Gets the list ofCommandListeners of the bot.- Returns:
- An
ArrayListcontaining theCommandListeners of the bot.
-
addCommandListener
Adds aCommandListenerto the bot.- Parameters:
commandListener- TheCommandListenerto add.
-