Skip to content

Commit a40bd83

Browse files
committed
some general cleanup preparing to make more additions
1 parent 84f9131 commit a40bd83

File tree

4 files changed

+20
-25
lines changed

4 files changed

+20
-25
lines changed

api/auditLog.go

+13-8
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ import (
55
"net/http"
66
)
77

8+
/* Whenever an admin action is performed on the API, an entry is added to the respective guild's audit log.
9+
You can specify the reason by attaching the X-Audit-Log-Reason request header.
10+
This header supports url encoded utf8 characters.
11+
*/
12+
813
type AuditLog struct {
9-
AuditLogEntries []AuditLogEntry `json:"audit_log_entries"`
10-
// GuildScheduledEvents []GuildScheduledEvent `json:"guild_scheduled_events"`
11-
Integrations []Integration `json:"integrations"`
12-
Threads []Channel `json:"threads"`
13-
Users []User `json:"users"`
14-
// Webhooks []Webhook `json:"webhooks"`
14+
AuditLogEntries []AuditLogEntry `json:"audit_log_entries"`
15+
GuildScheduledEvents []GuildScheduledEvent `json:"guild_scheduled_events"`
16+
Integrations []Integration `json:"integrations"`
17+
Threads []Channel `json:"threads"`
18+
Users []User `json:"users"`
19+
// TODO: Webhooks []Webhook `json:"webhooks"`
1520
}
1621

1722
type AuditLogEntry struct {
@@ -20,8 +25,8 @@ type AuditLogEntry struct {
2025
UserID *Snowflake `json:"user_id"`
2126
ID Snowflake `json:"id"`
2227
ActionType AuditLogEvent `json:"action_type"`
23-
Options OptionalAuditEntry `json:"options"`
24-
Reason string `json:"reason"`
28+
Options OptionalAuditEntry `json:"options,omitempty"`
29+
Reason string `json:"reason,omitempty"`
2530
}
2631

2732
type AuditLogEvent int

api/channel.go

+5-13
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const (
6767

6868
type VideoQualityMode int
6969

70+
//goland:noinspection GoUnusedConst
7071
const (
7172
Auto VideoQualityMode = iota + 1
7273
Full
@@ -106,6 +107,7 @@ type Message struct {
106107

107108
type MessageType int
108109

110+
//goland:noinspection GoUnusedConst,SpellCheckingInspection
109111
const (
110112
Default MessageType = iota
111113
RecipientAdd
@@ -126,9 +128,9 @@ const (
126128
GuildDiscoveryGracePeriodInitialWarning
127129
GuildDiscoveryGracePeriodFinalWarning
128130
ThreadCreated
129-
Reply // only in API v8+
130-
ChatInputCommand // only in API v8+
131-
ThreadStarterMessage // only in API v9+
131+
Reply
132+
ChatInputCommand
133+
ThreadStarterMessage
132134
GuildInviteReminder
133135
ContextMenuCommand
134136
)
@@ -388,25 +390,18 @@ func (c *Channel) String() string {
388390
switch c.Type {
389391
case GuildText:
390392
chanType = "GTC:"
391-
break
392393
case DM:
393394
chanType = "DM:"
394-
break
395395
case GroupDM:
396396
chanType = "GDM:"
397-
break
398397
case GuildNews:
399398
chanType = "GNC:"
400-
break
401399
case GuildNewsThread:
402400
chanType = "GNT:"
403-
break
404401
case GuildPublicThread:
405402
chanType = "GPuT:"
406-
break
407403
case GuildPrivateThread:
408404
chanType = "GPrT:"
409-
break
410405
}
411406

412407
return chanType + c.Name + "(" + c.ID.String() + ")"
@@ -463,7 +458,6 @@ func (c *Channel) ModifyChannel(dm *map[string]interface{}, guildChannel *map[st
463458
Name: fmt.Sprintf("%v", (*dm)["name"]),
464459
Icon: fmt.Sprintf("%v", (*dm)["icon"]),
465460
}
466-
break
467461
case GuildPublicThread:
468462
fallthrough
469463
case GuildPrivateThread:
@@ -482,8 +476,6 @@ func (c *Channel) ModifyChannel(dm *map[string]interface{}, guildChannel *map[st
482476
Name: fmt.Sprintf("%v", (*dm)["name"]),
483477
Archived: archived,
484478
}
485-
break
486-
487479
}
488480

489481
if c.Type == GroupDM {

api/rate_limits.go

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package api
22

3-
// Based upon DiscordGo <https://github.com/bwmarrin/discordgo>
4-
53
import (
64
"math"
75
"net/http"

api/rest.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ func (r *RateLimiter) requestWithLockedBucket(method, route, contentType string,
9393
case <-ctx.Done():
9494
switch ctx.Err() {
9595
case context.DeadlineExceeded:
96-
logging.Debugln(logging.LogPrefixDiscord, "context timeout exceeded")
96+
logging.Traceln(logging.LogPrefixDiscord, "context timeout exceeded")
9797
case context.Canceled:
98-
logging.Debugln(logging.LogPrefixDiscord, "context cancelled; process complete")
98+
logging.Traceln(logging.LogPrefixDiscord, "context cancelled; process complete")
9999
}
100100
}
101101
}(ctx)

0 commit comments

Comments
 (0)