Skip to content
This repository was archived by the owner on Mar 5, 2023. It is now read-only.

Commit 2d8d50c

Browse files
author
jonas747
committed
make API base configurable
1 parent 77175ef commit 2d8d50c

File tree

1 file changed

+172
-0
lines changed

1 file changed

+172
-0
lines changed

endpoints.go

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,175 @@ var (
187187
return EndpointWebhookInteraction(applicationID, token) + "/messages/" + StrID(messageID)
188188
}
189189
)
190+
191+
func CreateEndpoints(base string) {
192+
EndpointStatus = "https://status.discord.com/api/v2/"
193+
EndpointSm = EndpointStatus + "scheduled-maintenances/"
194+
EndpointSmActive = EndpointSm + "active.json"
195+
EndpointSmUpcoming = EndpointSm + "upcoming.json"
196+
197+
EndpointDiscord = base
198+
EndpointAPI = EndpointDiscord + "api/v" + APIVersion + "/"
199+
EndpointGuilds = EndpointAPI + "guilds/"
200+
EndpointChannels = EndpointAPI + "channels/"
201+
EndpointUsers = EndpointAPI + "users/"
202+
EndpointGateway = EndpointAPI + "gateway"
203+
EndpointGatewayBot = EndpointGateway + "/bot"
204+
EndpointWebhooks = EndpointAPI + "webhooks/"
205+
206+
EndpointCDN = "https://cdn.discordapp.com/"
207+
EndpointCDNAttachments = EndpointCDN + "attachments/"
208+
EndpointCDNAvatars = EndpointCDN + "avatars/"
209+
EndpointCDNIcons = EndpointCDN + "icons/"
210+
EndpointCDNSplashes = EndpointCDN + "splashes/"
211+
EndpointCDNChannelIcons = EndpointCDN + "channel-icons/"
212+
213+
EndpointAuth = EndpointAPI + "auth/"
214+
EndpointLogin = EndpointAuth + "login"
215+
EndpointLogout = EndpointAuth + "logout"
216+
EndpointVerify = EndpointAuth + "verify"
217+
EndpointVerifyResend = EndpointAuth + "verify/resend"
218+
EndpointForgotPassword = EndpointAuth + "forgot"
219+
EndpointResetPassword = EndpointAuth + "reset"
220+
EndpointRegister = EndpointAuth + "register"
221+
222+
EndpointVoice = EndpointAPI + "/voice/"
223+
EndpointVoiceRegions = EndpointVoice + "regions"
224+
EndpointVoiceIce = EndpointVoice + "ice"
225+
226+
EndpointTutorial = EndpointAPI + "tutorial/"
227+
EndpointTutorialIndicators = EndpointTutorial + "indicators"
228+
229+
EndpointTrack = EndpointAPI + "track"
230+
EndpointSso = EndpointAPI + "sso"
231+
EndpointReport = EndpointAPI + "report"
232+
EndpointIntegrations = EndpointAPI + "integrations"
233+
234+
EndpointUser = func(uID string) string { return EndpointUsers + uID }
235+
EndpointUserAvatar = func(uID int64, aID string) string { return EndpointCDNAvatars + StrID(uID) + "/" + aID + ".png" }
236+
EndpointUserAvatarAnimated = func(uID int64, aID string) string { return EndpointCDNAvatars + StrID(uID) + "/" + aID + ".gif" }
237+
EndpointUserSettings = func(uID string) string { return EndpointUsers + uID + "/settings" }
238+
EndpointUserGuilds = func(uID string) string { return EndpointUsers + uID + "/guilds" }
239+
EndpointUserGuild = func(uID string, gID int64) string { return EndpointUsers + uID + "/guilds/" + StrID(gID) }
240+
EndpointUserGuildSettings = func(uID string, gID int64) string { return EndpointUsers + uID + "/guilds/" + StrID(gID) + "/settings" }
241+
EndpointUserChannels = func(uID string) string { return EndpointUsers + uID + "/channels" }
242+
EndpointUserDevices = func(uID string) string { return EndpointUsers + uID + "/devices" }
243+
EndpointUserConnections = func(uID string) string { return EndpointUsers + uID + "/connections" }
244+
EndpointUserNotes = func(uID int64) string { return EndpointUsers + "@me/notes/" + StrID(uID) }
245+
246+
EndpointGuild = func(gID int64) string { return EndpointGuilds + StrID(gID) }
247+
EndpointGuildChannels = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/channels" }
248+
EndpointGuildMembers = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/members" }
249+
EndpointGuildMember = func(gID int64, uID int64) string { return EndpointGuilds + StrID(gID) + "/members/" + StrID(uID) }
250+
EndpointGuildMemberMe = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/members/@me" }
251+
EndpointGuildMemberRole = func(gID, uID, rID int64) string {
252+
return EndpointGuilds + StrID(gID) + "/members/" + StrID(uID) + "/roles/" + StrID(rID)
253+
}
254+
EndpointGuildBans = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/bans" }
255+
EndpointGuildBan = func(gID, uID int64) string { return EndpointGuilds + StrID(gID) + "/bans/" + StrID(uID) }
256+
EndpointGuildIntegrations = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/integrations" }
257+
EndpointGuildIntegration = func(gID, iID int64) string { return EndpointGuilds + StrID(gID) + "/integrations/" + StrID(iID) }
258+
EndpointGuildIntegrationSync = func(gID, iID int64) string {
259+
return EndpointGuilds + StrID(gID) + "/integrations/" + StrID(iID) + "/sync"
260+
}
261+
EndpointGuildRoles = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/roles" }
262+
EndpointGuildRole = func(gID, rID int64) string { return EndpointGuilds + StrID(gID) + "/roles/" + StrID(rID) }
263+
EndpointGuildInvites = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/invites" }
264+
EndpointGuildEmbed = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/embed" }
265+
EndpointGuildPrune = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/prune" }
266+
EndpointGuildIcon = func(gID int64, hash string) string { return EndpointCDNIcons + StrID(gID) + "/" + hash + ".png" }
267+
EndpointGuildSplash = func(gID int64, hash string) string { return EndpointCDNSplashes + StrID(gID) + "/" + hash + ".png" }
268+
EndpointGuildWebhooks = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/webhooks" }
269+
EndpointGuildAuditLogs = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/audit-logs" }
270+
EndpointGuildEmojis = func(gID int64) string { return EndpointGuilds + StrID(gID) + "/emojis" }
271+
EndpointGuildEmoji = func(gID, eID int64) string { return EndpointGuilds + StrID(gID) + "/emojis/" + StrID(eID) }
272+
273+
EndpointChannel = func(cID int64) string { return EndpointChannels + StrID(cID) }
274+
EndpointChannelPermissions = func(cID int64) string { return EndpointChannels + StrID(cID) + "/permissions" }
275+
EndpointChannelPermission = func(cID, tID int64) string { return EndpointChannels + StrID(cID) + "/permissions/" + StrID(tID) }
276+
EndpointChannelInvites = func(cID int64) string { return EndpointChannels + StrID(cID) + "/invites" }
277+
EndpointChannelTyping = func(cID int64) string { return EndpointChannels + StrID(cID) + "/typing" }
278+
EndpointChannelMessages = func(cID int64) string { return EndpointChannels + StrID(cID) + "/messages" }
279+
EndpointChannelMessage = func(cID, mID int64) string { return EndpointChannels + StrID(cID) + "/messages/" + StrID(mID) }
280+
EndpointChannelMessageAck = func(cID, mID int64) string { return EndpointChannels + StrID(cID) + "/messages/" + StrID(mID) + "/ack" }
281+
EndpointChannelMessagesBulkDelete = func(cID int64) string { return EndpointChannel(cID) + "/messages/bulk-delete" }
282+
EndpointChannelMessagesPins = func(cID int64) string { return EndpointChannel(cID) + "/pins" }
283+
EndpointChannelMessagePin = func(cID, mID int64) string { return EndpointChannel(cID) + "/pins/" + StrID(mID) }
284+
285+
EndpointGroupIcon = func(cID int64, hash string) string { return EndpointCDNChannelIcons + StrID(cID) + "/" + hash + ".png" }
286+
287+
EndpointChannelWebhooks = func(cID int64) string { return EndpointChannel(cID) + "/webhooks" }
288+
EndpointWebhook = func(wID int64) string { return EndpointWebhooks + StrID(wID) }
289+
EndpointWebhookToken = func(wID int64, token string) string { return EndpointWebhooks + StrID(wID) + "/" + token }
290+
291+
EndpointDefaultUserAvatar = func(uDiscriminator string) string {
292+
uDiscriminatorInt, _ := strconv.Atoi(uDiscriminator)
293+
return EndpointCDN + "embed/avatars/" + strconv.Itoa(uDiscriminatorInt%5) + ".png"
294+
}
295+
296+
EndpointMessageReactionsAll = func(cID, mID int64) string {
297+
return EndpointChannelMessage(cID, mID) + "/reactions"
298+
}
299+
EndpointMessageReactions = func(cID, mID int64, emoji EmojiName) string {
300+
return EndpointChannelMessage(cID, mID) + "/reactions/" + emoji.String()
301+
}
302+
EndpointMessageReaction = func(cID, mID int64, emoji EmojiName, uID string) string {
303+
return EndpointMessageReactions(cID, mID, emoji) + "/" + uID
304+
}
305+
306+
EndpointRelationships = func() string { return EndpointUsers + "@me" + "/relationships" }
307+
EndpointRelationship = func(uID int64) string { return EndpointRelationships() + "/" + StrID(uID) }
308+
EndpointRelationshipsMutual = func(uID int64) string { return EndpointUsers + StrID(uID) + "/relationships" }
309+
310+
EndpointGuildCreate = EndpointAPI + "guilds"
311+
312+
EndpointInvite = func(iID string) string { return EndpointAPI + "invite/" + iID }
313+
314+
EndpointIntegrationsJoin = func(iID string) string { return EndpointAPI + "integrations/" + iID + "/join" }
315+
316+
EndpointEmoji = func(eID int64) string { return EndpointAPI + "emojis/" + StrID(eID) + ".png" }
317+
EndpointEmojiAnimated = func(eID int64) string { return EndpointAPI + "emojis/" + StrID(eID) + ".gif" }
318+
319+
EndpointOauth2 = EndpointAPI + "oauth2/"
320+
EndpointApplications = EndpointOauth2 + "applications"
321+
EndpointApplication = func(aID int64) string { return EndpointApplications + "/" + StrID(aID) }
322+
EndpointApplicationMe = EndpointApplications + "/@me"
323+
EndpointApplicationsBot = func(aID int64) string { return EndpointApplications + "/" + StrID(aID) + "/bot" }
324+
325+
EndpointApplicationNonOauth2 = func(aID int64) string { return EndpointAPI + "applications/" + StrID(aID) }
326+
EndpointApplicationCommands = func(aID int64) string { return EndpointApplicationNonOauth2(aID) + "/commands" }
327+
EndpointApplicationCommand = func(aID int64, cmdID int64) string {
328+
return EndpointApplicationNonOauth2(aID) + "/commands/" + StrID(cmdID)
329+
}
330+
331+
EndpointApplicationGuildCommands = func(aID int64, gID int64) string {
332+
return EndpointApplicationNonOauth2(aID) + "/guilds/" + StrID(gID) + "/commands"
333+
}
334+
335+
EndpointApplicationGuildCommand = func(aID int64, gID int64, cmdID int64) string {
336+
return EndpointApplicationGuildCommands(aID, gID) + "/" + StrID(cmdID)
337+
}
338+
339+
EndpointApplicationGuildCommandsPermissions = func(aID int64, gID int64) string {
340+
return EndpointApplicationGuildCommands(aID, gID) + "/permissions"
341+
}
342+
343+
EndpointApplicationGuildCommandPermissions = func(aID int64, gID int64, cmdID int64) string {
344+
return EndpointApplicationGuildCommand(aID, gID, cmdID) + "/permissions"
345+
}
346+
347+
EndpointInteractions = EndpointAPI + "interactions"
348+
EndpointInteractionCallback = func(interactionID int64, token string) string {
349+
return EndpointInteractions + "/" + StrID(interactionID) + "/" + token + "/callback"
350+
}
351+
EndpointWebhookInteraction = func(applicationID int64, token string) string {
352+
return EndpointWebhooks + "/" + StrID(applicationID) + "/" + token
353+
}
354+
EndpointInteractionOriginalMessage = func(applicationID int64, token string) string {
355+
return EndpointWebhookInteraction(applicationID, token) + "/messages/@original"
356+
}
357+
EndpointInteractionFollowupMessage = func(applicationID int64, token string, messageID int64) string {
358+
return EndpointWebhookInteraction(applicationID, token) + "/messages/" + StrID(messageID)
359+
}
360+
361+
}

0 commit comments

Comments
 (0)