-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathconstant.go
More file actions
56 lines (48 loc) · 1.72 KB
/
Copy pathconstant.go
File metadata and controls
56 lines (48 loc) · 1.72 KB
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
package tempest
import (
"fmt"
"sync"
)
const (
DISCORD_EPOCH = 1420070400000 // Discord epoch in milliseconds
USER_AGENT = "DiscordApp https://github.com/amatsagu/tempest"
CONTENT_TYPE_JSON = "application/json"
CONTENT_TYPE_OCTET_STREAM = "application/octet-stream"
CONTENT_MULTIPART_JSON_DESCRIPTION = `form-data; name="payload_json"`
MAX_REQUEST_BODY_SIZE = 1024 * 1024 // 1024 KB
MAX_FILE_UPLOAD_SIZE = 10 * 1024 * 1024 // 10 MB
ROOT_PLACEHOLDER = "-"
)
var (
discordAPIBaseURL = "https://discord.com/api/v10"
discordCDNBaseURL = "https://cdn.discordapp.com"
discordURLMu sync.RWMutex
)
// Prepare those replies as they never change so there's no point in re-creating them each time.
var (
bodyPingResponse = fmt.Appendf(nil, `{"type":%d}`, PONG_RESPONSE_TYPE)
bodyAcknowledgeResponse = fmt.Appendf(nil, `{"type":%d}`, DEFERRED_UPDATE_MESSAGE_RESPONSE_TYPE)
bodyUnknownCommandResponse = fmt.Appendf(nil, `{"type":%d,"data":{"content":"Oh uh.. It looks like you tried to use outdated/unknown slash command. Please report this bug to bot owner.","flags":%d}}`, CHANNEL_MESSAGE_WITH_SOURCE_RESPONSE_TYPE, EPHEMERAL_MESSAGE_FLAG)
)
func DiscordAPIBaseURL() string {
discordURLMu.RLock()
url := discordAPIBaseURL
discordURLMu.RUnlock()
return url
}
func DiscordCDNBaseURL() string {
discordURLMu.RLock()
url := discordCDNBaseURL
discordURLMu.RUnlock()
return url
}
func UpdateDiscordAPIBaseURL(url string) {
discordURLMu.Lock()
discordAPIBaseURL = url
discordURLMu.Unlock()
}
func UpdateDiscordCDNBaseURL(url string) {
discordURLMu.Lock()
discordCDNBaseURL = url
discordURLMu.Unlock()
}