lispcord

A wrapper library for the Discordapp bot-api

This document serves as a guide to the individual public functions of lispcord and lispcord.classes. The library aims to offer a consistent and intuitive way to interact with the API, although we are well aware that intuitive is largely subjective :)

The documentation is seperated into two parts:

:lispcord, the core functions imported by the :lispcord package

:lispcord.classes, the class functions exported by the lispcord.classes package

:lispcord

The :lispcord package contains the core functionality of the library, including the event-handler implementation, the REST calls and many user facing utilities.

(defbot symbol token &key prefix version) => a client instance

Initiates a client instance and binds it to symbol via defparameter

The client instance serves as an authentication structure for REST-calls, handles all relevant websocket connections and isolates the wrapper behaviour so more than one bot can be run from the same script.

(connect bot) => nil

Establishes a connection to the websocket and starts the event loop

This can be considered "logging in" to the discord API

(disconnect bot) => nil

Kills the websocket connection and cleans up remaining threads

(commandp msg &optional bot) => Generalised boolean

Returns true if the msg object contains a direct mention to the bot, or if it starts with a character registered with make-prefix.

(make-prefix character &rest guilds) => guilds if passed, otherwise :global

Registers the character to be used as a command-prefix.

If guilds is passed, the prefix will only be valid for the given guild-objects.

(me &optional bot) => an lc:user object

Returns the user instance bound to *client* or of the passed bot instance.

Event-Handlers

(add-event-handler handler function) => nil

Registers the function for the corresponding event as a handler

>:on-message-create> | cargo: lc:message

Called when a new message is created in a discord channel

>:on-message-update> | cargo: lc:message

Called when a message is edited

>:on-message-delete> | cargo: snowflake, lc:channel

Called when a message is deleted. The Snowflake represents the deleted message

>:on-message-purge> | cargo: lc:channel, a vector of snowflakes

Called when multi-message-delete occurs. As with :on-message-delete, the snowflakes represent the deleted messages

>:on-reaction-add> | cargo: lc:emoji, snowflake, lc:user, lc:channel

Called when a reaction is added to a message. The message is represented by the snowflake

>:on-reaction-remove> | cargo: lc:emoji, snowflake, lc:user, lc:channel

Like :on-reaction-add, but dispatches on removal of the reaction

>:on-reaction-purge> | cargo: lc:channel, snowflake

Called when all reactions are removed from a message. The snowflake represents the message

>:on-presence-update> | cargo: lc:presence

Called when a user-presence changes

>:on-status-ready> | cargo: lc:ready

Called when the bot succesfully connects to the gateway

>:on-status-resumed> | cargo: nil

Called when the bot reconnects to the gateway, after it has lost connection. It does not forward any useful information

>:on-typing-start> | cargo: lc:user, lc:channel, a timestamp

Called when a user sends starts typing

>:on-user-update> | cargo: lc:user

Called when a user updates their profile

>:on-channel-create> | cargo: lc:channel

Called when a channel is created. This might be a guild channel or a DM channel

>:on-channel-update> | cargo: lc:channel

Called when channel-attributes are changed

>:on-channel-delete> | cargo: lc:channel

Called when a channel is removed

>:on-pin-update> | cargo: lc:channel, a timestamp

Called when a message is pinned. Unfortunately, discord does not dispatch any special event when a pinged message is deleted

>:on-guild-create> | cargo: lc:guild

Called when the client gains access to a new guild

>:on-guild-update> | cargo: lc:guild

Called when guild-settings are changed

>:on-guild-delete> | cargo: lc:guild

Called when the bots access to a guild is removed, e.G. because the bot is kicked or the guild is deleted

>:on-member-add> | cargo: lc:member, lc:guild

Called when a user joins a guild the bot can see

>:on-member-revmove> | cargo: lc:user, lc:guild

Called when a user is kicked from a guild the bot can see

>:on-member-update> | cargo: lc:member, lc:guild

Called when a member is updated

>:on-member-ban> | cargo: lc:user, lc:guild

Called when a member is banned off a server

>:on-member-unban> | cargo: lc:user, lc:guild

Called when a member is unbanned off a server

>:on-emoji-update> | cargo: a vector of lc:emoji, lc:guild

Called when the emoji list of a guild is Updated. This may occur when an emoji is added or removed from a guild

>:on-integrations-update> | cargo: lc:guild

Called when the Integrations are updated. I do not know what integrations are for tbh

>:on-role-create> | cargo: lc:role, lc:guild

Called when a role is added to a guild

>:on-role-delete> | cargo: role-id, guild-id

Called when a role is deleted. Note that it sends 2 snowflakes

>:on-role-update> | cargo: lc:role, lc:guild

Called when a role is changed on a guild