wumbly 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,26 +1,6 @@
1
+ import { Permissions, PermissionResolvable, PermissionOverwrite } from './permissions.js';
1
2
  import { EventEmitter } from 'node:events';
2
3
 
3
- interface GatewayOptions {
4
- token: string;
5
- url?: string;
6
- intents?: number;
7
- }
8
- declare class Gateway extends EventEmitter {
9
- private ws;
10
- private heartbeatTimer;
11
- private seq;
12
- private sessionId;
13
- private token;
14
- private url;
15
- private intents;
16
- constructor(options: GatewayOptions);
17
- connect(): Promise<void>;
18
- private handlePayload;
19
- private identify;
20
- send(payload: any): void;
21
- close(): void;
22
- }
23
-
24
4
  interface RestOptions {
25
5
  token?: string;
26
6
  baseUrl?: string;
@@ -46,13 +26,26 @@ interface User {
46
26
  discriminator?: string;
47
27
  [k: string]: unknown;
48
28
  }
29
+ interface GuildRole {
30
+ id: string;
31
+ name?: string;
32
+ color?: number;
33
+ position?: number;
34
+ permissions?: string | number | bigint;
35
+ [k: string]: unknown;
36
+ }
49
37
  interface Guild {
50
38
  id: string;
51
39
  name?: string;
52
40
  shardId?: number;
41
+ ownerId?: string | null;
42
+ icon?: string | null;
43
+ iconURL?: (opts?: any) => string | null;
44
+ roles?: GuildRole[];
53
45
  channels?: {
54
46
  cache?: Map<string, Channel> | Record<string, Channel>;
55
47
  get?: (id: string) => Channel | undefined;
48
+ fetch?: (id: string) => Promise<Channel>;
56
49
  };
57
50
  members?: {
58
51
  me?: GuildMember | null;
@@ -66,6 +59,12 @@ interface Guild {
66
59
  interface GuildMember {
67
60
  id?: string;
68
61
  user?: User;
62
+ roles?: Array<string | {
63
+ id?: string;
64
+ }>;
65
+ permissions?: Permissions;
66
+ permissionsIn?: (channel: Channel) => Permissions;
67
+ has?: (...flags: PermissionResolvable[]) => boolean;
69
68
  voice?: {
70
69
  channelId?: string | null;
71
70
  channel_id?: string | null;
@@ -76,6 +75,22 @@ interface GuildMember {
76
75
  };
77
76
  [k: string]: unknown;
78
77
  }
78
+ interface PermissionOverwriteEditOptions {
79
+ /** Defaults to the cached type, then to a role overwrite. */
80
+ type?: number;
81
+ allow?: PermissionResolvable;
82
+ deny?: PermissionResolvable;
83
+ }
84
+ interface PermissionOverwriteManager {
85
+ readonly cache: Map<string, PermissionOverwrite>;
86
+ get(id: string): PermissionOverwrite | null;
87
+ has(id: string): boolean;
88
+ values(): IterableIterator<PermissionOverwrite>;
89
+ toArray(): PermissionOverwrite[];
90
+ edit(id: string, options: PermissionOverwriteEditOptions): Promise<PermissionOverwrite>;
91
+ create(id: string, options: PermissionOverwriteEditOptions): Promise<PermissionOverwrite>;
92
+ delete(id: string): Promise<void>;
93
+ }
79
94
  interface Channel {
80
95
  id: string;
81
96
  guildId?: string;
@@ -83,6 +98,8 @@ interface Channel {
83
98
  type?: number;
84
99
  send?: (options: any) => Promise<Message>;
85
100
  isVoice?: () => boolean;
101
+ isTextBased?: () => boolean;
102
+ permissionOverwrites?: PermissionOverwriteManager;
86
103
  members?: Map<string, GuildMember> | GuildMember[] | {
87
104
  values?: () => Iterable<GuildMember>;
88
105
  };
@@ -106,6 +123,7 @@ interface ClientEventMap {
106
123
  messageUpdate: [Message, Message];
107
124
  messageDelete: [Message];
108
125
  guildCreate: [Guild];
126
+ guildDelete: [any];
109
127
  voiceStateUpdate: [any];
110
128
  voiceServerUpdate: [any];
111
129
  voiceStateAck: [any];
@@ -117,35 +135,56 @@ interface ClientEventMap {
117
135
  type ClientEventName = keyof ClientEventMap;
118
136
  type ClientEvents = ClientEventMap;
119
137
 
138
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error';
120
139
  interface PlatformClientOptions {
121
140
  token?: string;
122
141
  apiBase?: string;
123
142
  gatewayUrl?: string;
124
143
  intents?: number;
125
- logLevel?: string;
126
- }
144
+ /** Minimum level written to the console. Defaults to `info`. */
145
+ logLevel?: LogLevel;
146
+ }
147
+ declare function makeLogger(level?: LogLevel): {
148
+ debug: (msg: string, data?: unknown) => void;
149
+ info: (msg: string, data?: unknown) => void;
150
+ warn: (msg: string, data?: unknown) => void;
151
+ error: (msg: string, data?: unknown) => void;
152
+ };
127
153
  declare class PlatformClient extends EventEmitter {
128
154
  readonly rest: RestClient;
129
- readonly logger: {
130
- info: (msg: string, data?: unknown) => void;
131
- warn: (msg: string, data?: unknown) => void;
132
- error: (msg: string, data?: unknown) => void;
133
- debug: (msg: string, data?: unknown) => void;
134
- };
135
- readonly guilds: Map<string, Guild>;
136
- readonly channels: Map<string, Channel>;
155
+ readonly logger: ReturnType<typeof makeLogger>;
156
+ readonly guilds: any;
157
+ readonly channels: any;
137
158
  readonly users: Map<string, User>;
138
159
  user: User | null;
139
- ws: Gateway | null;
160
+ ws: any;
140
161
  options: PlatformClientOptions;
162
+ readyAt: number | null;
141
163
  private readyResolve;
142
164
  constructor(options?: PlatformClientOptions);
165
+ get uptime(): number | null;
166
+ /**
167
+ * Normalize a guild payload. Gateway payloads often omit `owner_id` and
168
+ * deliver members as an array, so both are handled here.
169
+ */
170
+ private wrapGuild;
171
+ /** Attach permission helpers to a raw member payload. */
172
+ private wrapMember;
173
+ private wrapChannel;
174
+ /** Overwrite manager backed by `PUT/DELETE /channels/:id/permissions/:id`. */
175
+ private createOverwriteManager;
143
176
  login(token: string, _options?: {
144
177
  signal?: AbortSignal;
145
178
  }): Promise<void>;
146
179
  destroy(): Promise<void>;
147
180
  sendToGateway(_shardId: number, payload: any): void;
148
181
  private handleDispatch;
182
+ /**
183
+ * Cache a gateway guild. Gateway payloads can include `roles` but omit
184
+ * `owner_id`, so the REST guild is fetched once and merged before the
185
+ * `guildCreate` event is emitted.
186
+ */
187
+ private handleGuildCreate;
149
188
  sendMessage(channelId: string, options: any): Promise<Message>;
150
189
  }
151
190
 
@@ -555,4 +594,4 @@ declare class Client extends PlatformClient {
555
594
  private replySafely;
556
595
  }
557
596
 
558
- export { createMiddleware as $, type Awaitable as A, type MiddlewareOptions as B, COMMAND_BRAND as C, ModuleLoadError as D, EVENT_BRAND as E, type PlatformClientOptions as F, Gateway as G, type PrefixOption as H, type ResolvedClientOptions as I, RestClient as J, type VoicePlayOptions as K, LISTENER_BRAND as L, type Message as M, type VoiceProvider as N, type VoiceSession as O, PlatformClient as P, type VoiceSource as Q, type ReplyInput as R, VoiceUnavailableError as S, collectFiles as T, type User as U, VoiceManager as V, type WalkOptions as W, createCommand as X, createCommandContext as Y, createEvent as Z, createListener as _, type Channel as a, isCommand as a0, isEvent as a1, isListener as a2, loadDirectory as a3, loadFile as a4, Client as b, type ClientEventMap as c, type ClientEventName as d, type ClientEvents as e, type ClientMessages as f, type ClientOptions as g, Command as h, type CommandContext as i, type CommandOptions as j, CommandStore as k, type CooldownOptions as l, type CooldownScope as m, CooldownStore as n, Event as o, type EventOptions as p, EventStore as q, type Guild as r, type GuildMember as s, Listener as t, type ListenerOptions as u, ListenerStore as v, type LoadOptions as w, type LoadedModules as x, Middleware as y, type MiddlewareNext as z };
597
+ export { createCommandContext as $, type Awaitable as A, type MiddlewareNext as B, COMMAND_BRAND as C, type MiddlewareOptions as D, EVENT_BRAND as E, ModuleLoadError as F, type Guild as G, type PermissionOverwriteManager as H, PlatformClient as I, type PlatformClientOptions as J, type PrefixOption as K, LISTENER_BRAND as L, type Message as M, type ResolvedClientOptions as N, RestClient as O, type PermissionOverwriteEditOptions as P, type VoicePlayOptions as Q, type ReplyInput as R, type VoiceProvider as S, type VoiceSession as T, type User as U, VoiceManager as V, type VoiceSource as W, VoiceUnavailableError as X, type WalkOptions as Y, collectFiles as Z, createCommand as _, type Channel as a, createEvent as a0, createListener as a1, createMiddleware as a2, isCommand as a3, isEvent as a4, isListener as a5, loadDirectory as a6, loadFile as a7, Client as b, type ClientEventMap as c, type ClientEventName as d, type ClientEvents as e, type ClientMessages as f, type ClientOptions as g, Command as h, type CommandContext as i, type CommandOptions as j, CommandStore as k, type CooldownOptions as l, type CooldownScope as m, CooldownStore as n, Event as o, type EventOptions as p, EventStore as q, type GuildMember as r, type GuildRole as s, Listener as t, type ListenerOptions as u, ListenerStore as v, type LoadOptions as w, type LoadedModules as x, type LogLevel as y, Middleware as z };