Skip to content

Events

on-event receives an event. A plugin is never called while it is already running, so events triggered during a call arrive after it returns.

These need a subscription in plugin-info.events:

Event kind Fired when
ready The client connected and loaded its initial state
logout The user logged out
message-created, message-updated, message-deleted Messages change. Updates and deletes include the previous version when it was cached
typing-started Someone starts typing
presence-updated A user’s status or activities change
voice-state-updated Someone joins, leaves or changes state in voice
relationship-changed A friend, block or request changes
channel-selected The user switches channel
channel-changed, guild-changed, member-changed Channels, guilds, roles or members change
gateway Every raw gateway dispatch, as JSON. Prefer the typed events
fn info() -> PluginInfo {
PluginInfo {
events: vec![EventKind::MessageDeleted],
..PluginInfo::new("DeleteLogger", "Logs deleted messages", &["you"])
}
}
fn on_event(&mut self, event: Event) {
if let Event::MessageDeleted(deleted) = event
&& let Some(message) = deleted.message
{
host::log(LogLevel::Info, &format!("{} deleted: {}", message.author.username, message.content));
}
}

These are delivered only to the plugin that caused them and need no subscription:

Event Caused by
timer(id) host.set-timeout or host.set-interval
http((id, result)) host.fetch
discord((id, result)) actions.request-discord
action(ui-action) The user interacting with something the plugin rendered
command(invocation) The user running one of the plugin’s commands
setting-changed(key) A setting of the plugin changing

See User interface.