-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.ts
136 lines (116 loc) · 3.32 KB
/
common.ts
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
//import { Client } from './';
export const BP_VERSION = '1.1.0';
export enum OperationCodes {
/** Request to authenticate */
AUTHENTICATE = 0,
/** Authentication successful */
AUTH_SUCCESS = 1,
/** Error received from the WebSocket */
ERROR = 2,
APPLICATION_STATUS = 3, // reserved for browser clients
/** Guild is being accessed from the dashboard */
GUILD_INTERACTION = 4,
/** Response to GUILD_INTERACTION with guild data and info */
REQUEST_GUILD_DATA = 5,
/** Guild data modified by user */
MODIFY_GUILD_DATA = 6,
/** Acknowledges MODIFY_GUILD_DATA */
ACKNOWLEDGE_INTERACTION = 7,
HEARTBEAT = 8
}
export enum ComponentType {
Text = 'Text',
Number = 'Number',
Checkbox = 'Checkbox',
Select = 'Select',
TextChannelSelect = 'Text Channel Select',
VoiceChannelSelect = 'Voice Channel Select',
CategorySelect = 'Category Select',
RoleSelect = 'Role Select'
}
export enum ElementType {
TextChannel = 'textChannels',
VoiceChannel = 'voiceChannels',
Category = 'categories',
Role = 'roles'
}
export type GuildData = number | string | Array<string>
export interface ServerMessage {
op: number;
d: object;
}
export interface ServerResponseError {
error: string
}
export interface ServerResponseAuthSuccess {
name: string,
heartbeatInterval: number
}
export interface InteractionInfo {
interactionId: string,
guildId: string
}
export interface GuildRequestResponse {
interactionId?: string,
/** Object of guild data for the dashboard. */
data?: { [key: string]: GuildData },
/** Bot is in the guild? */
inGuild: boolean,
/** Formatted list of the guild's text channels */
textChannels?: Array<GuildElement>,
/** Formatted list of the guild's voice channels */
voiceChannels?: Array<GuildElement>,
/** Formatted list of the guild's category channels */
categories?: Array<GuildElement>,
/** Formatted list of the guild's roles */
roles?: Array<GuildElement>,
/** Object of variables for use in the client dashboard */
variables?: { [key: string]: DynamicSelectOption[] | number | string }
}
export interface InteractionResponse {
interactionId: string,
success: boolean,
key: GuildDataChangeInfo['varname'],
value: GuildDataChangeInfo['data']
}
export interface GuildRequestInfo extends InteractionInfo {
include: Array<'categories' | 'textChannels' | 'voiceChannels' | 'roles'>
}
export interface GuildDataChangeInfo extends InteractionInfo {
varname: string,
data: GuildData,
userId: string,
inputType: ComponentType.Text | ComponentType.Number | ComponentType.Checkbox | ComponentType.Select
}
export interface GuildElement {
id: string,
name: string,
position?: number,
managed?: boolean
}
export interface DynamicSelectOption {
icon?: string,
name: string,
value: string
}
export interface AuthenticationData {
/** ID of the client */
id: string,
/** Secret key of the client (do not share this) */
secret: string,
/** Custom WebSocket server URL (you should only use a trusted server) */
wss?: string,
/** (Using this option may cause errors; not supported) */
wssVersionOverride?: string,
connectAs?: 'application', // "browser" not supported
}
// BotPanel.js Custom
export interface ClientDebugOptions {
logHeartbeat?: boolean,
disableAutoReconnect?: boolean
}
export interface AcknowledgementData {
success?: boolean,
message?: string | undefined,
newValue?: string | number | Array<string>
}