Package com.aliucord.api
Object GatewayAPI
-
- All Implemented Interfaces:
public class GatewayAPI
Api for easily listening to gateway events
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
GatewayAPI.EventListener
-
Field Summary
Fields Modifier and Type Field Description public final static GatewayAPI
INSTANCE
-
Method Summary
Modifier and Type Method Description final static Boolean
onRawEvent(GatewayAPI.EventListener<String> listener)
Listens to all raw gateway events final static Unit
onRawEvent(List<String> names, Function1<String, Unit> listener)
Listens to a specific set of gateway eventsSee user docs for a list of possible events final static Unit
onRawEvent(String name, Function1<String, Unit> listener)
Listens to a specific gateway eventSee user docs for a list of possible events final <T extends Any> Unit
onEvent(String name, Function1<T, Unit> listener)
Listens to a specific gateway eventSee user docs for a list of possible events final static <T extends Any> Unit
onEvent(String name, Class<T> clazz, Function1<T, Unit> listener)
Listens to a specific gateway eventSee user docs for a list of possible events -
-
Method Detail
-
onRawEvent
final static Boolean onRawEvent(GatewayAPI.EventListener<String> listener)
Listens to all raw gateway events
- Parameters:
listener
- The method that gets called when a gateway event is received, it is passed the full event string rather than just the data.
-
onRawEvent
final static Unit onRawEvent(List<String> names, Function1<String, Unit> listener)
Listens to a specific set of gateway events
See user docs for a list of possible events
- Parameters:
names
- List of event names to listen to (Case insensitive).listener
- The method that gets called when any of the gateway events are received, it is passed the full event string rather than just the data.
-
onRawEvent
final static Unit onRawEvent(String name, Function1<String, Unit> listener)
Listens to a specific gateway event
See user docs for a list of possible events
- Parameters:
name
- The name of the event (Case insensitive).listener
- The method that gets called when the gateway event is received, it is passed the full event string rather than just the data.
-
onEvent
final <T extends Any> Unit onEvent(String name, Function1<T, Unit> listener)
Listens to a specific gateway event
See user docs for a list of possible events
- Parameters:
name
- The name of the event (Case insensitive).listener
- The method that gets called when the gateway event is received, it is passed a deserialized model of type T.
-
onEvent
final static <T extends Any> Unit onEvent(String name, Class<T> clazz, Function1<T, Unit> listener)
Listens to a specific gateway event
See user docs for a list of possible events
- Parameters:
name
- The name of the event (Case insensitive).clazz
- The type that the event's data should be deserialized to.listener
- The method that gets called when the gateway event is received, it is passed an instance of clazz.
-
-
-
-