Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Registering an Event Listener

SeanOMik edited this page Sep 3, 2020 · 2 revisions

Registering an event listener is pretty simple. Here's the syntax:

#include <discpp/events/EVENT_HEADER.h>

discpp::EventHandler<discpp::EVENT_NAME>::RegisterListener([](discpp::EVENT_NAME event) {
    // Do things when the event is triggered.
});

Where EVENT_NAME is the event you want to listen for. You can find a list of events you can listen to here. Just click on the header to view the event class name.

Where EVENT_HEADER is the event header you want to listen for. You can find a list of event headers here.

Example:

#include <discpp/events/ready_event.h>

discpp::EventHandler<discpp::ReadyEvent>::RegisterListener([](discpp::ReadyEvent event) {
    std::cout << "Ready!" << std::endl;
});