blob: b49c264bbaabdf4b0ace8846912c174b0d33c2e0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
open Async
(**
Record type for registering event handlers
*)
type handler = {
ready: (Yojson.Basic.json -> unit) option;
resumed: (Yojson.Basic.json -> unit) option;
channel_create: (Yojson.Basic.json -> unit) option;
channel_delete: (Yojson.Basic.json -> unit) option;
channel_update: (Yojson.Basic.json -> unit) option;
channel_pins_update: (Yojson.Basic.json -> unit) option;
guild_create: (Yojson.Basic.json -> unit) option;
guild_delete: (Yojson.Basic.json -> unit) option;
guild_update: (Yojson.Basic.json -> unit) option;
guild_ban_add: (Yojson.Basic.json -> unit) option;
guild_ban_remove: (Yojson.Basic.json -> unit) option;
guild_emojis_update: (Yojson.Basic.json -> unit) option;
guild_integrations_update: (Yojson.Basic.json -> unit) option;
guild_member_add: (Yojson.Basic.json -> unit) option;
guild_member_remove: (Yojson.Basic.json -> unit) option;
guild_member_update: (Yojson.Basic.json -> unit) option;
guild_members_chunk: (Yojson.Basic.json -> unit) option; (* Not sure if this should be exposed *)
guild_role_create: (Yojson.Basic.json -> unit) option;
guild_role_delete: (Yojson.Basic.json -> unit) option;
guild_role_update: (Yojson.Basic.json -> unit) option;
message_create: (Yojson.Basic.json -> unit) option;
message_delete: (Yojson.Basic.json -> unit) option;
message_update: (Yojson.Basic.json -> unit) option;
message_delete_bulk: (Yojson.Basic.json -> unit) option;
message_reaction_add: (Yojson.Basic.json -> unit) option;
message_reaction_remove: (Yojson.Basic.json -> unit) option;
message_reaction_remove_all: (Yojson.Basic.json -> unit) option;
presence_update: (Yojson.Basic.json -> unit) option;
typing_start: (Yojson.Basic.json -> unit) option;
user_update: (Yojson.Basic.json -> unit) option;
voice_state_update: (Yojson.Basic.json -> unit) option;
voice_server_update: (Yojson.Basic.json -> unit) option;
webhooks_update: (Yojson.Basic.json -> unit) option;
}
(**
Represents a single Shard. Manual creation is discouraged; use Sharder.start instead
*)
module Shard : sig
type t = {
mutable hb: unit Ivar.t option;
mutable seq: int;
mutable session: string option;
mutable handler: handler;
token: string;
shard: int * int;
write: string Pipe.Writer.t;
read: string Pipe.Reader.t;
ready: unit Ivar.t;
}
val parse :
[< `Ok of string | `Eof] ->
Yojson.Basic.json
val push_frame :
?payload:Yojson.Basic.json ->
t ->
Opcode.t ->
t Deferred.t
val heartbeat :
t ->
t Deferred.t
val dispatch :
t ->
Yojson.Basic.json ->
t Deferred.t
val set_status :
t ->
Yojson.Basic.json ->
t Deferred.t
val request_guild_members :
guild:int ->
?query:string ->
?limit:int ->
t ->
t Deferred.t
val initialize :
t ->
Yojson.Basic.json ->
t Deferred.t
val handle_frame :
t ->
Yojson.Basic.json ->
t Deferred.t
val create :
url:string ->
shards:int * int ->
token:string ->
handler: handler ->
unit ->
t Deferred.t
end
type t = {
shards: Shard.t list;
}
val start :
?count:int ->
handler:handler ->
string ->
t Deferred.t
val set_status :
t ->
Yojson.Basic.json ->
Shard.t list Deferred.t
val set_status_with :
t ->
(Shard.t -> Yojson.Basic.json) ->
Shard.t list Deferred.t
val request_guild_members :
guild:int ->
?query:string ->
?limit:int ->
t ->
Shard.t list Deferred.t
val update_handler :
t ->
handler ->
unit
|