• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Multivit4min / TS3-NodeJS-Library / 5461107410

pending completion
5461107410

push

github

Multivit4min
remove support for node v14 update deploy to use node 18

330 of 433 branches covered (76.21%)

Branch coverage included in aggregate %.

1150 of 1191 relevant lines covered (96.56%)

59.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.25
/src/node/Client.ts
1
import { Abstract } from "./Abstract"
11✔
2
import { TeamSpeak } from "../TeamSpeak"
3
import { ClientEntry } from "../types/ResponseTypes"
4
import { ClientDBEdit, ClientEdit } from "../types/PropertyTypes"
5
import { ClientType } from "../types/enum"
11✔
6
import { TeamSpeakChannel } from "./Channel"
7
import { TeamSpeakServerGroup } from "./ServerGroup"
8
import { Permission } from "../util/Permission"
9

10
export class TeamSpeakClient extends Abstract<ClientEntry> {
11✔
11

12
  constructor(parent: TeamSpeak, list: ClientEntry) {
13
    super(parent, list, "client")
96✔
14
  }
15

16
  get clid() {
17
    return super.getPropertyByName("clid")
22✔
18
  }
19

20
  get cid() {
21
    return super.getPropertyByName("cid")
3✔
22
  }
23

24
  get databaseId() {
25
    return super.getPropertyByName("clientDatabaseId")
16✔
26
  }
27

28
  get nickname() {
29
    return super.getPropertyByName("clientNickname")
4✔
30
  }
31

32
  get type() {
33
    return super.getPropertyByName("clientType")
12✔
34
  }
35

36
  get uniqueIdentifier() {
37
    return super.getPropertyByName("clientUniqueIdentifier")
4✔
38
  }
39

40
  get away() {
41
    return super.getPropertyByName("clientAway")
1✔
42
  }
43

44
  get awayMessage() {
45
    return super.getPropertyByName("clientAwayMessage")
1✔
46
  }
47

48
  get flagTalking() {
49
    return super.getPropertyByName("clientFlagTalking")
1✔
50
  }
51

52
  get inputMuted() {
53
    return super.getPropertyByName("clientInputMuted")
1✔
54
  }
55

56
  get outputMuted() {
57
    return super.getPropertyByName("clientOutputMuted")
1✔
58
  }
59

60
  get inputHardware() {
61
    return super.getPropertyByName("clientInputHardware")
1✔
62
  }
63

64
  get outputHardware() {
65
    return super.getPropertyByName("clientOutputHardware")
1✔
66
  }
67

68
  get talkPower() {
69
    return super.getPropertyByName("clientTalkPower")
1✔
70
  }
71

72
  get isTalker() {
73
    return super.getPropertyByName("clientIsTalker")
1✔
74
  }
75

76
  get isPrioritySpeaker() {
77
    return super.getPropertyByName("clientIsPrioritySpeaker")
1✔
78
  }
79

80
  get isRecording() {
81
    return super.getPropertyByName("clientIsRecording")
1✔
82
  }
83

84
  get isChannelCommander() {
85
    return super.getPropertyByName("clientIsChannelCommander")
1✔
86
  }
87

88
  get servergroups() {
89
    return super.getPropertyByName("clientServergroups")
1✔
90
  }
91

92
  get channelGroupId() {
93
    return super.getPropertyByName("clientChannelGroupId")
1✔
94
  }
95

96
  get channelGroupInheritedChannelId() {
97
    return super.getPropertyByName("clientChannelGroupInheritedChannelId")
1✔
98
  }
99

100
  get version() {
101
    return super.getPropertyByName("clientVersion")
1✔
102
  }
103

104
  get platform() {
105
    return super.getPropertyByName("clientPlatform")
1✔
106
  }
107

108
  get idleTime() {
109
    return super.getPropertyByName("clientIdleTime")
1✔
110
  }
111

112
  get created() {
113
    return super.getPropertyByName("clientCreated")
1✔
114
  }
115

116
  get lastconnected() {
117
    return super.getPropertyByName("clientLastconnected")
1✔
118
  }
119

120
  get country() {
121
    return super.getPropertyByName("clientCountry")
1✔
122
  }
123

124
  get estimatedLocation() {
125
    return super.getPropertyByName("clientEstimatedLocation")
1✔
126
  }
127

128
  get connectionClientIp() {
129
    return super.getPropertyByName("connectionClientIp")
1✔
130
  }
131

132
  get badges() {
133
    return super.getPropertyByName("clientBadges")
1✔
134
  }
135

136
  /** evaluates if the client is a query client or a normal client */
137
  isQuery() {
138
    return this.type === ClientType.ServerQuery
1✔
139
  }
140

141
  /**
142
   * Retrieves a displayable Client Link for the TeamSpeak Chat
143
   */
144
  getUrl() {
145
    return `[URL=client://${this.clid}/${this.uniqueIdentifier}~${encodeURIComponent(this.nickname)}]${this.nickname}[/URL]`
1✔
146
  }
147

148
  /** returns general info of the client, requires the client to be online */
149
  getInfo() {
150
    return super.getParent().clientInfo(this).then(data => data[0])
1✔
151
  }
152

153
  /** returns the clients database info */
154
  getDBInfo() {
155
    return super.getParent().clientDbInfo(this).then(data => data[0])
3✔
156
  }
157

158
  /** returns a list of custom properties for the client */
159
  customInfo() {
160
    return super.getParent().customInfo(this)
1✔
161
  }
162

163
  /**
164
   * removes a custom property from the client
165
   * @param ident the key which should be deleted
166
   */
167
  customDelete(ident: string) {
168
    return super.getParent().customDelete(this, ident)
1✔
169
  }
170

171
  /**
172
   * creates or updates a custom property for the client
173
   * ident and value can be any value, and are the key value pair of the custom property
174
   * @param ident the key which should be set
175
   * @param value the value which should be set
176
   */
177
  customSet(ident: string, value: string) {
178
    return super.getParent().customSet(this, ident, value)
1✔
179
  }
180

181
  /**
182
   * kicks the client from the server
183
   * @param msg the message the client should receive when getting kicked
184
   */
185
  kickFromServer(msg: string) {
186
    return super.getParent().clientKick(this, 5, msg)
1✔
187
  }
188

189
  /**
190
   * kicks the client from their currently joined channel
191
   * @param msg the message the client should receive when getting kicked (max 40 Chars)
192
   */
193
  kickFromChannel(msg: string) {
194
    return super.getParent().clientKick(this, 4, msg)
1✔
195
  }
196

197
  /**
198
   * bans the chosen client with its uid
199
   * @param banreason ban reason
200
   * @param time bantime in seconds, if left empty it will result in a permaban
201
   */
202
  ban(banreason: string, time?: number) {
203
    return super.getParent().ban({ uid: this.uniqueIdentifier, time, banreason })
1✔
204
  }
205

206
  /**
207
   * moves the client to a different channel
208
   * @param cid channel id in which the client should get moved
209
   * @param cpw the channel password
210
   */
211
  move(cid: string|TeamSpeakChannel, cpw?: string) {
212
    return super.getParent().clientMove(this, cid, cpw)
3✔
213
  }
214

215
  /**
216
   * adds the client to one or more groups
217
   * @param sgid one or more servergroup ids which the client should be added to
218
   */
219
  addGroups(sgid: string|string[]|TeamSpeakServerGroup|TeamSpeakServerGroup[]) {
220
    return super.getParent().clientAddServerGroup(this, sgid)
1✔
221
  }
222

223
  /**
224
   * Removes the client from one or more groups
225
   * @param sgid one or more servergroup ids which the client should be added to
226
   */
227
  delGroups(sgid: string|string[]|TeamSpeakServerGroup|TeamSpeakServerGroup[]) {
228
    return super.getParent().clientDelServerGroup(this, sgid)
1✔
229
  }
230

231
  /**
232
   * edits the client
233
   * @param properties the properties to change
234
   */
235
  edit(properties: ClientEdit) {
236
    return this.getParent().clientEdit(this, properties)
1✔
237
  }
238

239
  /**
240
   * Changes a clients settings using given properties.
241
   * @param properties the properties which should be modified
242
   */
243
  dbEdit(properties: ClientDBEdit) {
244
    return this.getParent().clientDbEdit(this, properties)
1✔
245
  }
246

247
  /**
248
   * pokes the client with a certain message
249
   * @param msg the message the client should receive
250
   */
251
  poke(msg: string) {
252
    return super.getParent().clientPoke(this, msg)
1✔
253
  }
254

255
  /**
256
   * sends a textmessage to the client
257
   * @param msg the message the client should receive
258
   */
259
  message(msg: string) {
260
    return super.getParent().sendTextMessage(this, 1, msg)
1✔
261
  }
262

263
  /**
264
   * returns a list of permissions defined for the client
265
   * @param permsid if the permsid option is set to true the output will contain the permission names
266
   */
267
  permList(permsid?: boolean) {
268
    return super.getParent().clientPermList(this, permsid)
3✔
269
  }
270

271
  /**
272
   * Adds a set of specified permissions to a client.
273
   * Multiple permissions can be added by providing the three parameters of each permission.
274
   * A permission can be specified by permid or permsid.
275
   * @param perm the permission object to set
276
   */
277
  addPerm(perm: Permission.PermType) {
278
    return super.getParent().clientAddPerm(this, perm)
1✔
279
  }
280

281
  /**
282
   * Adds a set of specified permissions to a client.
283
   * Multiple permissions can be added by providing the three parameters of each permission.
284
   * A permission can be specified by permid or permsid.
285
   */
286
  createPerm() {
287
    return super.getParent().clientAddPerm(this, undefined)
×
288
  }
289

290
  /**
291
   * Removes a set of specified permissions from a client.
292
   * Multiple permissions can be removed at once.
293
   * A permission can be specified by permid or permsid
294
   * @param perm the permid or permsid
295
   */
296
  delPerm(perm: string|number) {
297
    return super.getParent().clientDelPerm(this, perm)
1✔
298
  }
299

300
  /** returns a Buffer with the avatar of the user */
301
  getAvatar() {
302
    return this.getAvatarName().then(name => super.getParent().downloadFile(`/${name}`))
1✔
303
  }
304

305
  /** returns a Buffer with the icon of the client */
306
  getIcon() {
307
    return this.getIconId().then(id => super.getParent().downloadIcon(id))
1✔
308
  }
309

310
  /** returns the avatar name of the client */
311
  getAvatarName() {
312
    return this.getDBInfo().then(data => `avatar_${data.clientBase64HashClientUID}`)
2✔
313
  }
314

315
  /** gets the icon name of the client */
316
  getIconId() {
317
    return super.getParent().getIconId(this.permList(true))
2✔
318
  }
319

320
  /** retrieves the client id from a string or teamspeak client */
321
  static getId<T extends TeamSpeakClient.ClientType>(client?: T): T extends undefined ? undefined : string
322
  static getId(client?: TeamSpeakClient.ClientType): string|undefined {
323
    return client instanceof TeamSpeakClient ? client.clid : client
39✔
324
  }
325

326
  /** retrieves the client dbid from a string or teamspeak client */
327
  static getDbid<T extends TeamSpeakClient.ClientType>(client?: T): T extends undefined ? undefined : string
328
  static getDbid(client?: TeamSpeakClient.ClientType): string|undefined {
329
    return client instanceof TeamSpeakClient ? client.databaseId : client
51✔
330
  }
331

332
  /** retrieves the client dbid from a string or teamspeak client */
333
  static getUid<T extends TeamSpeakClient.ClientType>(client?: T): T extends undefined ? undefined : string
334
  static getUid(client?: TeamSpeakClient.ClientType): string|undefined {
335
    return client instanceof TeamSpeakClient ? client.uniqueIdentifier : client
2!
336
  }
337

338
  /** retrieves the clients from an array */
339
  static getMultipleIds(client: TeamSpeakClient.MultiClientType): string[] {
340
    const list = Array.isArray(client) ? client : [client]
2!
341
    return list.map(c => TeamSpeakClient.getId(c)) as string[]
2✔
342
  }
343

344
  /** retrieves the clients from an array */
345
  static getMultipleDbids(client: TeamSpeakClient.MultiClientType): string[] {
346
    const list = Array.isArray(client) ? client : [client]
10✔
347
    return list.map(c => TeamSpeakClient.getDbid(c)) as string[]
12✔
348
  }
349

350
  /** retrieves the clients from an array */
351
  static getMultipleUids(client: TeamSpeakClient.MultiClientType): string[] {
352
    const list = Array.isArray(client) ? client : [client]
×
353
    return list.map(c => TeamSpeakClient.getUid(c)) as string[]
×
354
  }
355

356
}
357

358
export namespace TeamSpeakClient {
359
  export type ClientType = string|TeamSpeakClient
360
  export type MultiClientType = string[]|TeamSpeakClient[]|ClientType
361
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc