class Discord::Client

Overview

The basic client class that is used to connect to Discord, send REST requests, or send or receive gateway messages. It is required for doing any sort of interaction with Discord.

A new simple client that does nothing yet can be created like this:

client = Discord::Client.new(token: "Bot token", client_id: 123_u64)

With this client, REST requests can now be sent. (See the Discord::REST module.) A gateway connection can also be started using the #run method.

Included Modules

Defined in:

lib/discordcr/src/discordcr/client.cr
discordcr-middleware.cr

Instance Method Summary

Macro Summary

Instance Method Detail

def on_channel_create(*middleware) #

Creates a Client#on_channel_create handler with a middleware chain. Handles a Channel payload.


[View source]
def on_channel_create(*middleware, &block : Channel, Context -> ) #

Creates a Client#on_channel_create handler with a middleware chain and trailing block. Handles a Channel payload.


[View source]
def on_channel_delete(*middleware, &block : Channel, Context -> ) #

Creates a Client#on_channel_delete handler with a middleware chain and trailing block. Handles a Channel payload.


[View source]
def on_channel_delete(*middleware) #

Creates a Client#on_channel_delete handler with a middleware chain. Handles a Channel payload.


[View source]
def on_channel_update(*middleware) #

Creates a Client#on_channel_update handler with a middleware chain. Handles a Channel payload.


[View source]
def on_channel_update(*middleware, &block : Channel, Context -> ) #

Creates a Client#on_channel_update handler with a middleware chain and trailing block. Handles a Channel payload.


[View source]
def on_dispatch(*middleware, &block : ::Tuple(String, IO::Memory), Context -> ) #

Creates a Client#on_dispatch handler with a middleware chain and trailing block. Handles a {String, IO::Memory} payload.


[View source]
def on_dispatch(*middleware) #

Creates a Client#on_dispatch handler with a middleware chain. Handles a {String, IO::Memory} payload.


[View source]
def on_guild_ban_add(*middleware, &block : Gateway::GuildBanPayload, Context -> ) #

Creates a Client#on_guild_ban_add handler with a middleware chain and trailing block. Handles a Gateway::GuildBanPayload payload.


[View source]
def on_guild_ban_add(*middleware) #

Creates a Client#on_guild_ban_add handler with a middleware chain. Handles a Gateway::GuildBanPayload payload.


[View source]
def on_guild_ban_remove(*middleware) #

Creates a Client#on_guild_ban_remove handler with a middleware chain. Handles a Gateway::GuildBanPayload payload.


[View source]
def on_guild_ban_remove(*middleware, &block : Gateway::GuildBanPayload, Context -> ) #

Creates a Client#on_guild_ban_remove handler with a middleware chain and trailing block. Handles a Gateway::GuildBanPayload payload.


[View source]
def on_guild_create(*middleware, &block : Gateway::GuildCreatePayload, Context -> ) #

Creates a Client#on_guild_create handler with a middleware chain and trailing block. Handles a Gateway::GuildCreatePayload payload.


[View source]
def on_guild_create(*middleware) #

Creates a Client#on_guild_create handler with a middleware chain. Handles a Gateway::GuildCreatePayload payload.


[View source]
def on_guild_delete(*middleware, &block : Gateway::GuildDeletePayload, Context -> ) #

Creates a Client#on_guild_delete handler with a middleware chain and trailing block. Handles a Gateway::GuildDeletePayload payload.


[View source]
def on_guild_delete(*middleware) #

Creates a Client#on_guild_delete handler with a middleware chain. Handles a Gateway::GuildDeletePayload payload.


[View source]
def on_guild_emoji_update(*middleware) #

Creates a Client#on_guild_emoji_update handler with a middleware chain. Handles a Gateway::GuildEmojiUpdatePayload payload.


[View source]
def on_guild_emoji_update(*middleware, &block : Gateway::GuildEmojiUpdatePayload, Context -> ) #

Creates a Client#on_guild_emoji_update handler with a middleware chain and trailing block. Handles a Gateway::GuildEmojiUpdatePayload payload.


[View source]
def on_guild_integrations_update(*middleware, &block : Gateway::GuildIntegrationsUpdatePayload, Context -> ) #

Creates a Client#on_guild_integrations_update handler with a middleware chain and trailing block. Handles a Gateway::GuildIntegrationsUpdatePayload payload.


[View source]
def on_guild_integrations_update(*middleware) #

Creates a Client#on_guild_integrations_update handler with a middleware chain. Handles a Gateway::GuildIntegrationsUpdatePayload payload.


[View source]
def on_guild_member_add(*middleware, &block : Gateway::GuildMemberAddPayload, Context -> ) #

Creates a Client#on_guild_member_add handler with a middleware chain and trailing block. Handles a Gateway::GuildMemberAddPayload payload.


[View source]
def on_guild_member_add(*middleware) #

Creates a Client#on_guild_member_add handler with a middleware chain. Handles a Gateway::GuildMemberAddPayload payload.


[View source]
def on_guild_member_remove(*middleware, &block : Gateway::GuildMemberRemovePayload, Context -> ) #

Creates a Client#on_guild_member_remove handler with a middleware chain and trailing block. Handles a Gateway::GuildMemberRemovePayload payload.


[View source]
def on_guild_member_remove(*middleware) #

Creates a Client#on_guild_member_remove handler with a middleware chain. Handles a Gateway::GuildMemberRemovePayload payload.


[View source]
def on_guild_member_update(*middleware, &block : Gateway::GuildMemberUpdatePayload, Context -> ) #

Creates a Client#on_guild_member_update handler with a middleware chain and trailing block. Handles a Gateway::GuildMemberUpdatePayload payload.


[View source]
def on_guild_member_update(*middleware) #

Creates a Client#on_guild_member_update handler with a middleware chain. Handles a Gateway::GuildMemberUpdatePayload payload.


[View source]
def on_guild_members_chunk(*middleware, &block : Gateway::GuildMembersChunkPayload, Context -> ) #

Creates a Client#on_guild_members_chunk handler with a middleware chain and trailing block. Handles a Gateway::GuildMembersChunkPayload payload.


[View source]
def on_guild_members_chunk(*middleware) #

Creates a Client#on_guild_members_chunk handler with a middleware chain. Handles a Gateway::GuildMembersChunkPayload payload.


[View source]
def on_guild_role_create(*middleware) #

Creates a Client#on_guild_role_create handler with a middleware chain. Handles a Gateway::GuildRolePayload payload.


[View source]
def on_guild_role_create(*middleware, &block : Gateway::GuildRolePayload, Context -> ) #

Creates a Client#on_guild_role_create handler with a middleware chain and trailing block. Handles a Gateway::GuildRolePayload payload.


[View source]
def on_guild_role_delete(*middleware) #

Creates a Client#on_guild_role_delete handler with a middleware chain. Handles a Gateway::GuildRoleDeletePayload payload.


[View source]
def on_guild_role_delete(*middleware, &block : Gateway::GuildRoleDeletePayload, Context -> ) #

Creates a Client#on_guild_role_delete handler with a middleware chain and trailing block. Handles a Gateway::GuildRoleDeletePayload payload.


[View source]
def on_guild_role_update(*middleware) #

Creates a Client#on_guild_role_update handler with a middleware chain. Handles a Gateway::GuildRolePayload payload.


[View source]
def on_guild_role_update(*middleware, &block : Gateway::GuildRolePayload, Context -> ) #

Creates a Client#on_guild_role_update handler with a middleware chain and trailing block. Handles a Gateway::GuildRolePayload payload.


[View source]
def on_guild_update(*middleware) #

Creates a Client#on_guild_update handler with a middleware chain. Handles a Guild payload.


[View source]
def on_guild_update(*middleware, &block : Guild, Context -> ) #

Creates a Client#on_guild_update handler with a middleware chain and trailing block. Handles a Guild payload.


[View source]
def on_message_create(*middleware, &block : Message, Context -> ) #

Creates a Client#on_message_create handler with a middleware chain and trailing block. Handles a Message payload.


[View source]
def on_message_create(*middleware) #

Creates a Client#on_message_create handler with a middleware chain. Handles a Message payload.


[View source]
def on_message_delete(*middleware, &block : Gateway::MessageDeletePayload, Context -> ) #

Creates a Client#on_message_delete handler with a middleware chain and trailing block. Handles a Gateway::MessageDeletePayload payload.


[View source]
def on_message_delete(*middleware) #

Creates a Client#on_message_delete handler with a middleware chain. Handles a Gateway::MessageDeletePayload payload.


[View source]
def on_message_delete_bulk(*middleware, &block : Gateway::MessageDeleteBulkPayload, Context -> ) #

Creates a Client#on_message_delete_bulk handler with a middleware chain and trailing block. Handles a Gateway::MessageDeleteBulkPayload payload.


[View source]
def on_message_delete_bulk(*middleware) #

Creates a Client#on_message_delete_bulk handler with a middleware chain. Handles a Gateway::MessageDeleteBulkPayload payload.


[View source]
def on_message_reaction_add(*middleware, &block : Gateway::MessageReactionPayload, Context -> ) #

Creates a Client#on_message_reaction_add handler with a middleware chain and trailing block. Handles a Gateway::MessageReactionPayload payload.


[View source]
def on_message_reaction_add(*middleware) #

Creates a Client#on_message_reaction_add handler with a middleware chain. Handles a Gateway::MessageReactionPayload payload.


[View source]
def on_message_reaction_remove(*middleware, &block : Gateway::MessageReactionPayload, Context -> ) #

Creates a Client#on_message_reaction_remove handler with a middleware chain and trailing block. Handles a Gateway::MessageReactionPayload payload.


[View source]
def on_message_reaction_remove(*middleware) #

Creates a Client#on_message_reaction_remove handler with a middleware chain. Handles a Gateway::MessageReactionPayload payload.


[View source]
def on_message_reaction_remove_all(*middleware) #

Creates a Client#on_message_reaction_remove_all handler with a middleware chain. Handles a Gateway::MessageReactionRemoveAllPayload payload.


[View source]
def on_message_reaction_remove_all(*middleware, &block : Gateway::MessageReactionRemoveAllPayload, Context -> ) #

Creates a Client#on_message_reaction_remove_all handler with a middleware chain and trailing block. Handles a Gateway::MessageReactionRemoveAllPayload payload.


[View source]
def on_message_update(*middleware, &block : Gateway::MessageUpdatePayload, Context -> ) #

Creates a Client#on_message_update handler with a middleware chain and trailing block. Handles a Gateway::MessageUpdatePayload payload.


[View source]
def on_message_update(*middleware) #

Creates a Client#on_message_update handler with a middleware chain. Handles a Gateway::MessageUpdatePayload payload.


[View source]
def on_presence_update(*middleware) #

Creates a Client#on_presence_update handler with a middleware chain. Handles a Gateway::PresenceUpdatePayload payload.


[View source]
def on_presence_update(*middleware, &block : Gateway::PresenceUpdatePayload, Context -> ) #

Creates a Client#on_presence_update handler with a middleware chain and trailing block. Handles a Gateway::PresenceUpdatePayload payload.


[View source]
def on_ready(*middleware) #

Creates a Client#on_ready handler with a middleware chain. Handles a Gateway::ReadyPayload payload.


[View source]
def on_ready(*middleware, &block : Gateway::ReadyPayload, Context -> ) #

Creates a Client#on_ready handler with a middleware chain and trailing block. Handles a Gateway::ReadyPayload payload.


[View source]
def on_resumed(*middleware, &block : Gateway::ResumedPayload, Context -> ) #

Creates a Client#on_resumed handler with a middleware chain and trailing block. Handles a Gateway::ResumedPayload payload.


[View source]
def on_resumed(*middleware) #

Creates a Client#on_resumed handler with a middleware chain. Handles a Gateway::ResumedPayload payload.


[View source]
def on_typing_start(*middleware, &block : Gateway::TypingStartPayload, Context -> ) #

Creates a Client#on_typing_start handler with a middleware chain and trailing block. Handles a Gateway::TypingStartPayload payload.


[View source]
def on_typing_start(*middleware) #

Creates a Client#on_typing_start handler with a middleware chain. Handles a Gateway::TypingStartPayload payload.


[View source]
def on_user_update(*middleware, &block : User, Context -> ) #

Creates a Client#on_user_update handler with a middleware chain and trailing block. Handles a User payload.


[View source]
def on_user_update(*middleware) #

Creates a Client#on_user_update handler with a middleware chain. Handles a User payload.


[View source]
def on_voice_server_update(*middleware, &block : Gateway::VoiceServerUpdatePayload, Context -> ) #

Creates a Client#on_voice_server_update handler with a middleware chain and trailing block. Handles a Gateway::VoiceServerUpdatePayload payload.


[View source]
def on_voice_server_update(*middleware) #

Creates a Client#on_voice_server_update handler with a middleware chain. Handles a Gateway::VoiceServerUpdatePayload payload.


[View source]
def on_voice_state_update(*middleware, &block : VoiceState, Context -> ) #

Creates a Client#on_voice_state_update handler with a middleware chain and trailing block. Handles a VoiceState payload.


[View source]
def on_voice_state_update(*middleware) #

Creates a Client#on_voice_state_update handler with a middleware chain. Handles a VoiceState payload.


[View source]

Macro Detail

macro stack_event(event_name, klass) #

[View source]