@@ -182,91 +182,6 @@ func unmarshal(data []byte, v interface{}) error {
182
182
return nil
183
183
}
184
184
185
- // ------------------------------------------------------------------------------------------------
186
- // Functions specific to Discord Sessions
187
- // ------------------------------------------------------------------------------------------------
188
-
189
- // Login asks the Discord server for an authentication token.
190
- //
191
- // NOTE: While email/pass authentication is supported by DiscordGo it is
192
- // HIGHLY DISCOURAGED by Discord. Please only use email/pass to obtain a token
193
- // and then use that authentication token for all future connections.
194
- // Also, doing any form of automation with a user (non Bot) account may result
195
- // in that account being permanently banned from Discord.
196
- func (s * Session ) Login (email , password string ) (err error ) {
197
-
198
- data := struct {
199
- Email string `json:"email"`
200
- Password string `json:"password"`
201
- }{email , password }
202
-
203
- response , err := s .RequestWithBucketID ("POST" , EndpointLogin , data , EndpointLogin )
204
- if err != nil {
205
- return
206
- }
207
-
208
- temp := struct {
209
- Token string `json:"token"`
210
- MFA bool `json:"mfa"`
211
- }{}
212
-
213
- err = unmarshal (response , & temp )
214
- if err != nil {
215
- return
216
- }
217
-
218
- s .Token = temp .Token
219
- s .MFA = temp .MFA
220
- return
221
- }
222
-
223
- // Register sends a Register request to Discord, and returns the authentication token
224
- // Note that this account is temporary and should be verified for future use.
225
- // Another option is to save the authentication token external, but this isn't recommended.
226
- func (s * Session ) Register (username string ) (token string , err error ) {
227
-
228
- data := struct {
229
- Username string `json:"username"`
230
- }{username }
231
-
232
- response , err := s .RequestWithBucketID ("POST" , EndpointRegister , data , EndpointRegister )
233
- if err != nil {
234
- return
235
- }
236
-
237
- temp := struct {
238
- Token string `json:"token"`
239
- }{}
240
-
241
- err = unmarshal (response , & temp )
242
- if err != nil {
243
- return
244
- }
245
-
246
- token = temp .Token
247
- return
248
- }
249
-
250
- // Logout sends a logout request to Discord.
251
- // This does not seem to actually invalidate the token. So you can still
252
- // make API calls even after a Logout. So, it seems almost pointless to
253
- // even use.
254
- func (s * Session ) Logout () (err error ) {
255
-
256
- // _, err = s.Request("POST", LOGOUT, `{"token": "` + s.Token + `"}`)
257
-
258
- if s .Token == "" {
259
- return
260
- }
261
-
262
- data := struct {
263
- Token string `json:"token"`
264
- }{s .Token }
265
-
266
- _ , err = s .RequestWithBucketID ("POST" , EndpointLogout , data , EndpointLogout )
267
- return
268
- }
269
-
270
185
// ------------------------------------------------------------------------------------------------
271
186
// Functions specific to Discord Users
272
187
// ------------------------------------------------------------------------------------------------
@@ -307,21 +222,18 @@ func (s *Session) UserAvatarDecode(u *User) (img image.Image, err error) {
307
222
return
308
223
}
309
224
310
- // UserUpdate updates a users settings.
311
- func (s * Session ) UserUpdate (email , password , username , avatar , newPassword string ) (st * User , err error ) {
225
+ // UserUpdate updates current user settings.
226
+ func (s * Session ) UserUpdate (username , avatar string ) (st * User , err error ) {
312
227
313
228
// NOTE: Avatar must be either the hash/id of existing Avatar or
314
229
// data:image/png;base64,BASE64_STRING_OF_NEW_AVATAR_PNG
315
230
// to set a new avatar.
316
231
// If left blank, avatar will be set to null/blank
317
232
318
233
data := struct {
319
- Email string `json:"email,omitempty"`
320
- Password string `json:"password,omitempty"`
321
- Username string `json:"username,omitempty"`
322
- Avatar string `json:"avatar,omitempty"`
323
- NewPassword string `json:"new_password,omitempty"`
324
- }{email , password , username , avatar , newPassword }
234
+ Username string `json:"username,omitempty"`
235
+ Avatar string `json:"avatar,omitempty"`
236
+ }{username , avatar }
325
237
326
238
body , err := s .RequestWithBucketID ("PATCH" , EndpointUser ("@me" ), data , EndpointUsers )
327
239
if err != nil {
@@ -332,39 +244,6 @@ func (s *Session) UserUpdate(email, password, username, avatar, newPassword stri
332
244
return
333
245
}
334
246
335
- // UserSettings returns the settings for a given user
336
- func (s * Session ) UserSettings () (st * Settings , err error ) {
337
-
338
- body , err := s .RequestWithBucketID ("GET" , EndpointUserSettings ("@me" ), nil , EndpointUserSettings ("" ))
339
- if err != nil {
340
- return
341
- }
342
-
343
- err = unmarshal (body , & st )
344
- return
345
- }
346
-
347
- // UserUpdateStatus update the user status
348
- // status : The new status (Actual valid status are 'online','idle','dnd','invisible')
349
- func (s * Session ) UserUpdateStatus (status Status ) (st * Settings , err error ) {
350
- if status == StatusOffline {
351
- err = ErrStatusOffline
352
- return
353
- }
354
-
355
- data := struct {
356
- Status Status `json:"status"`
357
- }{status }
358
-
359
- body , err := s .RequestWithBucketID ("PATCH" , EndpointUserSettings ("@me" ), data , EndpointUserSettings ("" ))
360
- if err != nil {
361
- return
362
- }
363
-
364
- err = unmarshal (body , & st )
365
- return
366
- }
367
-
368
247
// UserConnections returns the user's connections
369
248
func (s * Session ) UserConnections () (conn []* UserConnection , err error ) {
370
249
response , err := s .RequestWithBucketID ("GET" , EndpointUserConnections ("@me" ), nil , EndpointUserConnections ("@me" ))
@@ -380,19 +259,6 @@ func (s *Session) UserConnections() (conn []*UserConnection, err error) {
380
259
return
381
260
}
382
261
383
- // UserChannels returns an array of Channel structures for all private
384
- // channels.
385
- func (s * Session ) UserChannels () (st []* Channel , err error ) {
386
-
387
- body , err := s .RequestWithBucketID ("GET" , EndpointUserChannels ("@me" ), nil , EndpointUserChannels ("" ))
388
- if err != nil {
389
- return
390
- }
391
-
392
- err = unmarshal (body , & st )
393
- return
394
- }
395
-
396
262
// UserChannelCreate creates a new User (Private) Channel with another User
397
263
// recipientID : A user ID for the user to which this channel is opened with.
398
264
func (s * Session ) UserChannelCreate (recipientID string ) (st * Channel , err error ) {
@@ -443,20 +309,6 @@ func (s *Session) UserGuilds(limit int, beforeID, afterID string) (st []*UserGui
443
309
return
444
310
}
445
311
446
- // UserGuildSettingsEdit Edits the users notification settings for a guild
447
- // guildID : The ID of the guild to edit the settings on
448
- // settings : The settings to update
449
- func (s * Session ) UserGuildSettingsEdit (guildID string , settings * UserGuildSettingsEdit ) (st * UserGuildSettings , err error ) {
450
-
451
- body , err := s .RequestWithBucketID ("PATCH" , EndpointUserGuildSettings ("@me" , guildID ), settings , EndpointUserGuildSettings ("" , guildID ))
452
- if err != nil {
453
- return
454
- }
455
-
456
- err = unmarshal (body , & st )
457
- return
458
- }
459
-
460
312
// UserChannelPermissions returns the permission of a user in a channel.
461
313
// userID : The ID of the user to calculate permissions for.
462
314
// channelID : The ID of the channel to calculate permission for.
@@ -1958,18 +1810,6 @@ func (s *Session) VoiceRegions() (st []*VoiceRegion, err error) {
1958
1810
return
1959
1811
}
1960
1812
1961
- // VoiceICE returns the voice server ICE information
1962
- func (s * Session ) VoiceICE () (st * VoiceICE , err error ) {
1963
-
1964
- body , err := s .RequestWithBucketID ("GET" , EndpointVoiceIce , nil , EndpointVoiceIce )
1965
- if err != nil {
1966
- return
1967
- }
1968
-
1969
- err = unmarshal (body , & st )
1970
- return
1971
- }
1972
-
1973
1813
// ------------------------------------------------------------------------------------------------
1974
1814
// Functions specific to Discord Websockets
1975
1815
// ------------------------------------------------------------------------------------------------
@@ -2348,86 +2188,6 @@ func (s *Session) MessageReactions(channelID, messageID, emojiID string, limit i
2348
2188
return
2349
2189
}
2350
2190
2351
- // ------------------------------------------------------------------------------------------------
2352
- // Functions specific to user notes
2353
- // ------------------------------------------------------------------------------------------------
2354
-
2355
- // UserNoteSet sets the note for a specific user.
2356
- func (s * Session ) UserNoteSet (userID string , message string ) (err error ) {
2357
- data := struct {
2358
- Note string `json:"note"`
2359
- }{message }
2360
-
2361
- _ , err = s .RequestWithBucketID ("PUT" , EndpointUserNotes (userID ), data , EndpointUserNotes ("" ))
2362
- return
2363
- }
2364
-
2365
- // ------------------------------------------------------------------------------------------------
2366
- // Functions specific to Discord Relationships (Friends list)
2367
- // ------------------------------------------------------------------------------------------------
2368
-
2369
- // RelationshipsGet returns an array of all the relationships of the user.
2370
- func (s * Session ) RelationshipsGet () (r []* Relationship , err error ) {
2371
- body , err := s .RequestWithBucketID ("GET" , EndpointRelationships (), nil , EndpointRelationships ())
2372
- if err != nil {
2373
- return
2374
- }
2375
-
2376
- err = unmarshal (body , & r )
2377
- return
2378
- }
2379
-
2380
- // relationshipCreate creates a new relationship. (I.e. send or accept a friend request, block a user.)
2381
- // relationshipType : 1 = friend, 2 = blocked, 3 = incoming friend req, 4 = sent friend req
2382
- func (s * Session ) relationshipCreate (userID string , relationshipType int ) (err error ) {
2383
- data := struct {
2384
- Type int `json:"type"`
2385
- }{relationshipType }
2386
-
2387
- _ , err = s .RequestWithBucketID ("PUT" , EndpointRelationship (userID ), data , EndpointRelationships ())
2388
- return
2389
- }
2390
-
2391
- // RelationshipFriendRequestSend sends a friend request to a user.
2392
- // userID: ID of the user.
2393
- func (s * Session ) RelationshipFriendRequestSend (userID string ) (err error ) {
2394
- err = s .relationshipCreate (userID , 4 )
2395
- return
2396
- }
2397
-
2398
- // RelationshipFriendRequestAccept accepts a friend request from a user.
2399
- // userID: ID of the user.
2400
- func (s * Session ) RelationshipFriendRequestAccept (userID string ) (err error ) {
2401
- err = s .relationshipCreate (userID , 1 )
2402
- return
2403
- }
2404
-
2405
- // RelationshipUserBlock blocks a user.
2406
- // userID: ID of the user.
2407
- func (s * Session ) RelationshipUserBlock (userID string ) (err error ) {
2408
- err = s .relationshipCreate (userID , 2 )
2409
- return
2410
- }
2411
-
2412
- // RelationshipDelete removes the relationship with a user.
2413
- // userID: ID of the user.
2414
- func (s * Session ) RelationshipDelete (userID string ) (err error ) {
2415
- _ , err = s .RequestWithBucketID ("DELETE" , EndpointRelationship (userID ), nil , EndpointRelationships ())
2416
- return
2417
- }
2418
-
2419
- // RelationshipsMutualGet returns an array of all the users both @me and the given user is friends with.
2420
- // userID: ID of the user.
2421
- func (s * Session ) RelationshipsMutualGet (userID string ) (mf []* User , err error ) {
2422
- body , err := s .RequestWithBucketID ("GET" , EndpointRelationshipsMutual (userID ), nil , EndpointRelationshipsMutual (userID ))
2423
- if err != nil {
2424
- return
2425
- }
2426
-
2427
- err = unmarshal (body , & mf )
2428
- return
2429
- }
2430
-
2431
2191
// ------------------------------------------------------------------------------------------------
2432
2192
// Functions specific to application (slash) commands
2433
2193
// ------------------------------------------------------------------------------------------------
0 commit comments