Skip to content

Commit f10abf3

Browse files
FedorLap2006SmoothieNoIce
authored andcommitted
feat(*)!: dropped undocumented endpoints
1 parent 1cb4672 commit f10abf3

File tree

3 files changed

+10
-332
lines changed

3 files changed

+10
-332
lines changed

endpoints.go

+5-29
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,10 @@ var (
4141
EndpointCDNChannelIcons = EndpointCDN + "channel-icons/"
4242
EndpointCDNBanners = EndpointCDN + "banners/"
4343

44-
EndpointAuth = EndpointAPI + "auth/"
45-
EndpointLogin = EndpointAuth + "login"
46-
EndpointLogout = EndpointAuth + "logout"
47-
EndpointVerify = EndpointAuth + "verify"
48-
EndpointVerifyResend = EndpointAuth + "verify/resend"
49-
EndpointForgotPassword = EndpointAuth + "forgot"
50-
EndpointResetPassword = EndpointAuth + "reset"
51-
EndpointRegister = EndpointAuth + "register"
52-
5344
EndpointVoice = EndpointAPI + "/voice/"
5445
EndpointVoiceRegions = EndpointVoice + "regions"
55-
EndpointVoiceIce = EndpointVoice + "ice"
56-
57-
EndpointTutorial = EndpointAPI + "tutorial/"
58-
EndpointTutorialIndicators = EndpointTutorial + "indicators"
5946

60-
EndpointTrack = EndpointAPI + "track"
61-
EndpointSso = EndpointAPI + "sso"
62-
EndpointReport = EndpointAPI + "report"
63-
EndpointIntegrations = EndpointAPI + "integrations"
47+
// TODO: EndpointUserGuildMember
6448

6549
EndpointUser = func(uID string) string { return EndpointUsers + uID }
6650
EndpointUserAvatar = func(uID, aID string) string { return EndpointCDNAvatars + uID + "/" + aID + ".png" }
@@ -69,14 +53,10 @@ var (
6953
uDiscriminatorInt, _ := strconv.Atoi(uDiscriminator)
7054
return EndpointCDN + "embed/avatars/" + strconv.Itoa(uDiscriminatorInt%5) + ".png"
7155
}
72-
EndpointUserSettings = func(uID string) string { return EndpointUsers + uID + "/settings" }
73-
EndpointUserGuilds = func(uID string) string { return EndpointUsers + uID + "/guilds" }
74-
EndpointUserGuild = func(uID, gID string) string { return EndpointUsers + uID + "/guilds/" + gID }
75-
EndpointUserGuildSettings = func(uID, gID string) string { return EndpointUsers + uID + "/guilds/" + gID + "/settings" }
76-
EndpointUserChannels = func(uID string) string { return EndpointUsers + uID + "/channels" }
77-
EndpointUserDevices = func(uID string) string { return EndpointUsers + uID + "/devices" }
78-
EndpointUserConnections = func(uID string) string { return EndpointUsers + uID + "/connections" }
79-
EndpointUserNotes = func(uID string) string { return EndpointUsers + "@me/notes/" + uID }
56+
EndpointUserGuilds = func(uID string) string { return EndpointUsers + uID + "/guilds" }
57+
EndpointUserGuild = func(uID, gID string) string { return EndpointUsers + uID + "/guilds/" + gID }
58+
EndpointUserChannels = func(uID string) string { return EndpointUsers + uID + "/channels" }
59+
EndpointUserConnections = func(uID string) string { return EndpointUsers + uID + "/connections" }
8060

8161
EndpointGuild = func(gID string) string { return EndpointGuilds + gID }
8262
EndpointGuildPreview = func(gID string) string { return EndpointGuilds + gID + "/preview" }
@@ -171,10 +151,6 @@ var (
171151
return EndpointWebhookMessage(aID, iToken, mID)
172152
}
173153

174-
EndpointRelationships = func() string { return EndpointUsers + "@me" + "/relationships" }
175-
EndpointRelationship = func(uID string) string { return EndpointRelationships() + "/" + uID }
176-
EndpointRelationshipsMutual = func(uID string) string { return EndpointUsers + uID + "/relationships" }
177-
178154
EndpointGuildCreate = EndpointAPI + "guilds"
179155

180156
EndpointInvite = func(iID string) string { return EndpointAPI + "invites/" + iID }

restapi.go

+5-245
Original file line numberDiff line numberDiff line change
@@ -182,91 +182,6 @@ func unmarshal(data []byte, v interface{}) error {
182182
return nil
183183
}
184184

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-
270185
// ------------------------------------------------------------------------------------------------
271186
// Functions specific to Discord Users
272187
// ------------------------------------------------------------------------------------------------
@@ -307,21 +222,18 @@ func (s *Session) UserAvatarDecode(u *User) (img image.Image, err error) {
307222
return
308223
}
309224

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) {
312227

313228
// NOTE: Avatar must be either the hash/id of existing Avatar or
314229
// data:image/png;base64,BASE64_STRING_OF_NEW_AVATAR_PNG
315230
// to set a new avatar.
316231
// If left blank, avatar will be set to null/blank
317232

318233
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}
325237

326238
body, err := s.RequestWithBucketID("PATCH", EndpointUser("@me"), data, EndpointUsers)
327239
if err != nil {
@@ -332,39 +244,6 @@ func (s *Session) UserUpdate(email, password, username, avatar, newPassword stri
332244
return
333245
}
334246

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-
368247
// UserConnections returns the user's connections
369248
func (s *Session) UserConnections() (conn []*UserConnection, err error) {
370249
response, err := s.RequestWithBucketID("GET", EndpointUserConnections("@me"), nil, EndpointUserConnections("@me"))
@@ -380,19 +259,6 @@ func (s *Session) UserConnections() (conn []*UserConnection, err error) {
380259
return
381260
}
382261

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-
396262
// UserChannelCreate creates a new User (Private) Channel with another User
397263
// recipientID : A user ID for the user to which this channel is opened with.
398264
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
443309
return
444310
}
445311

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-
460312
// UserChannelPermissions returns the permission of a user in a channel.
461313
// userID : The ID of the user to calculate permissions for.
462314
// channelID : The ID of the channel to calculate permission for.
@@ -1958,18 +1810,6 @@ func (s *Session) VoiceRegions() (st []*VoiceRegion, err error) {
19581810
return
19591811
}
19601812

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-
19731813
// ------------------------------------------------------------------------------------------------
19741814
// Functions specific to Discord Websockets
19751815
// ------------------------------------------------------------------------------------------------
@@ -2348,86 +2188,6 @@ func (s *Session) MessageReactions(channelID, messageID, emojiID string, limit i
23482188
return
23492189
}
23502190

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-
24312191
// ------------------------------------------------------------------------------------------------
24322192
// Functions specific to application (slash) commands
24332193
// ------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)