Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
75c1ea3
Expand MessageType enum with new values
biast12 Mar 1, 2026
fc2b4d3
Fix typo and add new message flags
biast12 Mar 1, 2026
33b48e7
Add label/file-upload and reorder component constants
biast12 Mar 1, 2026
694273a
Add new gateway events and update models
biast12 Mar 2, 2026
74004b1
Make ThreadMember IDs optional and add Member
biast12 Mar 2, 2026
02cb93c
Simplify PartialChannel and ToPartialChannel
biast12 Mar 2, 2026
f76ea31
Fix short time timestamp style constant
biast12 Mar 2, 2026
7aefa7c
Add burst reaction details to Reaction struct
biast12 Mar 2, 2026
9ce509e
Enhance Message struct and add message types
biast12 Mar 2, 2026
2c8bfd4
Rename AllowedMentionType constants to verbose names
biast12 Mar 2, 2026
a7e4361
Make embed fields optional and add type
biast12 Mar 2, 2026
6c83721
Expand Attachment struct with optional fields
biast12 Mar 2, 2026
c7ec928
Make channel fields optional, handle nil GuildId
biast12 Mar 2, 2026
3e56cf5
Always include PermissionOverwrite.Id in JSON
biast12 Mar 2, 2026
cc2f0cb
Refactor automoderation types & metadata
biast12 Mar 2, 2026
cb9cd14
Prefix entitlement constants with EntitlementType
biast12 Mar 2, 2026
18e798f
Make Emoji fields nullable/optional
biast12 Mar 2, 2026
2f1891e
Add recurrence rule support to events
biast12 Mar 2, 2026
339100d
Add omitempty to Sticker JSON tags
biast12 Mar 2, 2026
b1a5401
Make guild/integration fields optional; add stickers
biast12 Mar 2, 2026
e8467c1
Expand GuildFeature constants
biast12 Mar 2, 2026
b67623e
Update Webhook object and add webhook type
biast12 Mar 2, 2026
aa04dfd
Rename enums and update Connection struct
biast12 Mar 2, 2026
38d0b88
Rename ComponentSelectMenu to ComponentStringSelect
biast12 Mar 2, 2026
09a28d3
Update application command structs and option types
biast12 Mar 2, 2026
190b2e4
Rename and realign interaction response types
biast12 Mar 2, 2026
11b0978
Refactor Invite model and REST payload
biast12 Mar 2, 2026
f79a4cb
Add AvatarDecorationData; mark fields omitempty
biast12 Mar 2, 2026
09c486f
Add omitempty to SoundboardSound GuildId
biast12 Mar 2, 2026
70d7f0a
Use StagePrivacyLevel and nullable event ID
biast12 Mar 2, 2026
51d8361
Rename Status to SubscriptionStatus; add omitempty
biast12 Mar 2, 2026
6bea2e3
Refactor user/activity structs; add fields
biast12 Mar 2, 2026
5075d9d
Update auditlog structs & enums for new fields
biast12 Mar 3, 2026
def858b
Add owner team member role constant
biast12 Mar 3, 2026
f6b9fc8
Extend Application with webhooks & integrations
biast12 Mar 3, 2026
6bb5545
Add localization, handler & integration types
biast12 Mar 3, 2026
a761935
Rename explicit content filter constants
biast12 Mar 3, 2026
39db06f
Rename VerificationLevel constants
biast12 Mar 3, 2026
a74e0a8
Rename permission overwrite constants
biast12 Mar 3, 2026
5f4365e
Rename message activity constants and set values
biast12 Mar 3, 2026
9b024fc
Update channel type enums and usages
biast12 Mar 3, 2026
5a51b44
Fix typo in DefaultMessageNotificationLevel
biast12 Mar 3, 2026
e48f090
Add ID to ActionRow and fix marshaled type
biast12 Mar 3, 2026
e0ab77f
Make interaction fields optional and add new metadata
biast12 Mar 3, 2026
e3860a6
Remove Vip field from VoiceRegion struct
biast12 Mar 3, 2026
500af07
Reorder ClientStatusType constants
biast12 Mar 3, 2026
62648f4
Add cover and URL fields to user Asset struct
biast12 Mar 3, 2026
0898c19
Add optional ID field to Container struct
biast12 Mar 3, 2026
2f48d0d
Update interaction component structs for new schema
biast12 Mar 3, 2026
5b36edf
Rename ManageEmojis and add BypassSlowmode
biast12 Mar 3, 2026
1eb916e
Enhance channel REST models and endpoints
biast12 Mar 3, 2026
8a397ca
Update guild REST API structs and endpoints
biast12 Mar 3, 2026
205eafe
Add get command endpoints & update command data
biast12 Mar 3, 2026
94671db
Webhook message: add GET/DELETE, edit -> PATCH
biast12 Mar 3, 2026
2c00b15
user: add banner, guild member endpoint, and query fixes
biast12 Mar 4, 2026
d44f9ff
Add activity instance types and endpoint
biast12 Mar 4, 2026
aa19167
Support after param and validate audit log limit
biast12 Mar 4, 2026
8c3fd52
Add application emoji endpoints; fix content-type
biast12 Mar 4, 2026
41470cb
entitlement: add GetEntitlement and option fixes
biast12 Mar 4, 2026
9dc74f3
Support guild_scheduled_event_id in GetInvite
biast12 Mar 4, 2026
a61962e
Add voice state REST endpoints
biast12 Mar 4, 2026
ec32966
Add /oauth2/@me endpoint and client_credentials grant
biast12 Mar 4, 2026
61d530e
Use io.ReadAll instead of ioutil.ReadAll
biast12 Mar 4, 2026
a76e78a
Adjust REST ListThreadMembers and object types
biast12 Mar 4, 2026
3c1a6fd
Add new REST endpoints and SKU object
biast12 Mar 4, 2026
d1935ef
Move guild objects and rename event file
biast12 Mar 4, 2026
f43c1a0
Merge branch 'master' into add-types
biast12 Mar 6, 2026
4cb5c58
Use iota for enum constants
biast12 Mar 6, 2026
eb0d137
Remove extra spaces in const declarations
biast12 Mar 6, 2026
1ab539f
format
biast12 Mar 6, 2026
77bc3a3
Merge branch 'master' into add-types
biast12 Apr 26, 2026
da40dcc
Add guild message search and voice/channel updates
biast12 Apr 27, 2026
f87758f
Format Go structs and constants for alignment
biast12 Apr 27, 2026
2cf967f
Use shared channel/application types in gateway
biast12 Apr 27, 2026
a91faf4
Various cleanup: APIs, context, and rate limits
biast12 Apr 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions cache/boltcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,13 @@ func (c *BoltCache) StoreChannels(channels []channel.Channel) {
b := tx.Bucket([]byte("channels"))

for _, ch := range channels {
var guildId uint64
if ch.GuildId != nil {
guildId = *ch.GuildId
}
cwg := channelWithGuild{
CachedChannel: ch.ToCachedChannel(),
guildId: ch.GuildId,
guildId: guildId,
}

if encoded, err := json.Marshal(cwg); err == nil {
Expand Down Expand Up @@ -732,7 +736,11 @@ func (c *BoltCache) StoreVoiceStates(states []guild.VoiceState) {

for _, state := range states {
if encoded, err := json.Marshal(state.ToCachedVoiceState()); err == nil {
if err := b.Put(memberToBytes(state.UserId, state.GuildId), encoded); err != nil {
guildId := uint64(0)
if state.GuildId != nil {
guildId = *state.GuildId
}
if err := b.Put(memberToBytes(state.UserId, guildId), encoded); err != nil {
return err
}
} else {
Expand Down Expand Up @@ -766,7 +774,7 @@ func (c *BoltCache) GetVoiceState(userId, guildId uint64) (guild.VoiceState, boo
u = user.User{Id: userId}
}

m = member.Member{User: u}
m = member.Member{User: &u}
}

state := cached.ToVoiceState(guildId, m)
Expand Down Expand Up @@ -805,7 +813,7 @@ func (c *BoltCache) GetGuildVoiceStates(guildId uint64) []guild.VoiceState {
u = user.User{Id: stateUserId}
}

m = member.Member{User: u}
m = member.Member{User: &u}
}

states = append(states, cached.ToVoiceState(guildId, m))
Expand Down
48 changes: 24 additions & 24 deletions cache/memorycache.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,19 +300,21 @@ func (c *MemoryCache) StoreChannels(ctx context.Context, channels []channel.Chan

// Add to guild object
c.guildLock.Lock()
if guild, found := c.guilds[channel.GuildId]; found {
// Check to see if channel already exists
var channelExists bool
for _, userId := range guild.Channels {
if userId == channel.Id {
channelExists = true
break
if channel.GuildId != nil {
if guild, found := c.guilds[*channel.GuildId]; found {
// Check to see if channel already exists
var channelExists bool
for _, userId := range guild.Channels {
if userId == channel.Id {
channelExists = true
break
}
}
}

if !channelExists {
guild.Channels = append(guild.Channels, channel.Id)
c.guilds[channel.GuildId] = guild
if !channelExists {
guild.Channels = append(guild.Channels, channel.Id)
c.guilds[*channel.GuildId] = guild
}
}
}
c.guildLock.Unlock()
Expand Down Expand Up @@ -677,11 +679,15 @@ func (c *MemoryCache) StoreVoiceStates(ctx context.Context, states []guild.Voice
defer c.voiceStateLock.Unlock()

for _, state := range states {
if c.voiceStates[state.GuildId] == nil {
c.voiceStates[state.GuildId] = make(map[uint64]guild.CachedVoiceState)
if state.GuildId == nil {
continue
}
guildId := *state.GuildId
if c.voiceStates[guildId] == nil {
c.voiceStates[guildId] = make(map[uint64]guild.CachedVoiceState)
}

c.voiceStates[state.GuildId][state.UserId] = state.ToCachedVoiceState()
c.voiceStates[guildId][state.UserId] = state.ToCachedVoiceState()
}
}

Expand All @@ -702,11 +708,8 @@ func (c *MemoryCache) GetVoiceState(ctx context.Context, userId, guildId uint64)
// get member
m, err := c.GetMember(ctx, guildId, userId)
if err == ErrNotFound {
m = member.Member{
User: user.User{
Id: userId,
},
}
u := user.User{Id: userId}
m = member.Member{User: &u}
} else if err != nil {
return guild.VoiceState{}, err
}
Expand All @@ -730,11 +733,8 @@ func (c *MemoryCache) GetGuildVoiceStates(ctx context.Context, guildId uint64) (
// get member
m, err := c.GetMember(ctx, guildId, userId)
if err == ErrNotFound {
m = member.Member{
User: user.User{
Id: userId,
},
}
u := user.User{Id: userId}
m = member.Member{User: &u}
} else if err != nil {
return nil, err
}
Expand Down
29 changes: 23 additions & 6 deletions cache/pgcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,11 @@ func (c *PgCache) StoreGuilds(ctx context.Context, guilds []guild.Guild) error {
return err
}

batch.Queue(`INSERT INTO channels("channel_id", "guild_id", "data") VALUES($1, $2, $3) ON CONFLICT("channel_id") DO UPDATE SET "data" = $3;`, channel.Id, channel.GuildId, string(encoded))
var chGuildId uint64
if channel.GuildId != nil {
chGuildId = *channel.GuildId
}
batch.Queue(`INSERT INTO channels("channel_id", "guild_id", "data") VALUES($1, $2, $3) ON CONFLICT("channel_id") DO UPDATE SET "data" = $3;`, channel.Id, chGuildId, string(encoded))
}
}

Expand Down Expand Up @@ -316,7 +320,8 @@ func (c *PgCache) StoreGuild(ctx context.Context, g guild.Guild) error {
}

for i, channel := range g.Channels {
channel.GuildId = g.Id
gId := g.Id
channel.GuildId = &gId
g.Channels[i] = channel
}

Expand Down Expand Up @@ -362,10 +367,10 @@ func (c *PgCache) GetGuildChannels(ctx context.Context, guildId uint64) ([]chann
}

rows, err := c.Query(ctx, queryGetGuildChannels, guildId)
defer rows.Close()
if err != nil {
return nil, err
}
defer rows.Close()

var channels []channel.Channel
for rows.Next() {
Expand Down Expand Up @@ -615,7 +620,11 @@ func (c *PgCache) StoreChannel(ctx context.Context, ch channel.Channel) error {
return err
}

_, err = c.Exec(ctx, queryInsertChannel, ch.Id, ch.GuildId, string(encoded))
var guildId uint64
if ch.GuildId != nil {
guildId = *ch.GuildId
}
_, err = c.Exec(ctx, queryInsertChannel, ch.Id, guildId, string(encoded))
return err
}

Expand All @@ -632,7 +641,11 @@ func (c *PgCache) StoreChannels(ctx context.Context, channels []channel.Channel)
return err
}

batch.Queue(queryInsertChannel, ch.Id, ch.GuildId, string(encoded))
var chGuildId uint64
if ch.GuildId != nil {
chGuildId = *ch.GuildId
}
batch.Queue(queryInsertChannel, ch.Id, chGuildId, string(encoded))
}

br := c.SendBatch(ctx, batch)
Expand Down Expand Up @@ -664,7 +677,11 @@ func (c *PgCache) ReplaceChannels(ctx context.Context, guildId uint64, channels
return err
}

if _, err := tx.Exec(ctx, queryInsertChannel, ch.Id, ch.GuildId, string(encoded)); err != nil {
var txGuildId uint64
if ch.GuildId != nil {
txGuildId = *ch.GuildId
}
if _, err := tx.Exec(ctx, queryInsertChannel, ch.Id, txGuildId, string(encoded)); err != nil {
return err
}
}
Expand Down
8 changes: 4 additions & 4 deletions command/commandhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ func (h *CommandHandler) commandListener(s *gateway.Shard, e *events.MessageCrea
}

for _, cmd := range h.commands {
match := strings.ToLower(cmd.Name) == strings.ToLower(root)
match := strings.EqualFold(cmd.Name, root)

// check aliases
if !match {
for _, alias := range cmd.Aliases {
if strings.ToLower(cmd.Name) == strings.ToLower(alias) {
if strings.EqualFold(cmd.Name, alias) {
match = true
break
}
Expand All @@ -76,12 +76,12 @@ func (h *CommandHandler) commandListener(s *gateway.Shard, e *events.MessageCrea
argloop:
for i, arg := range args {
for _, sub := range cmd.SubCommands {
subMatch := strings.ToLower(arg) == strings.ToLower(sub.Name)
subMatch := strings.EqualFold(arg, sub.Name)

// check aliases
if !subMatch {
for _, alias := range sub.Aliases {
if strings.ToLower(arg) == strings.ToLower(alias) {
if strings.EqualFold(arg, alias) {
subMatch = true
break
}
Expand Down
27 changes: 4 additions & 23 deletions examples/avatar/avatar.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
package main

import (
"context"
"fmt"
"net/http"

"github.com/TicketsBot-cloud/gdl/cache"
"github.com/TicketsBot-cloud/gdl/command"
"github.com/TicketsBot-cloud/gdl/gateway"
"github.com/TicketsBot-cloud/gdl/rest"
"github.com/TicketsBot-cloud/gdl/rest/ratelimit"
"github.com/sirupsen/logrus"
)

func main() {
cacheFactory := cache.BoltCacheFactory(cache.CacheOptions{
cacheFactory := cache.MemoryCacheFactory(cache.CacheOptions{
Users: true,
}, cache.BoltOptions{
ClearOnRestart: false,
Path: "bolt.db",
FileMode: 600,
Options: nil,
})

shardOptions := gateway.ShardOptions{
Expand Down Expand Up @@ -55,27 +49,14 @@ func registerCommands(sm *gateway.ShardManager) {

func onCommand(ctx command.CommandContext) {
if len(ctx.Mentions) == 0 {
_, _ = ctx.Shard.CreateMessage(ctx.ChannelId, "You need to mention a user")
_, _ = ctx.Shard.CreateMessage(context.Background(), ctx.ChannelId, "You need to mention a user")
return
}

for _, mention := range ctx.Mentions {
res, err := http.Get(mention.AvatarUrl(2048))
_, err := ctx.Shard.CreateMessage(context.Background(), ctx.ChannelId, fmt.Sprintf("%s's avatar is: %s", mention.Username, mention.AvatarUrl(2048)))
if err != nil {
logrus.Warn(err.Error())
continue
}
defer res.Body.Close()

data := rest.CreateMessageData{
Content: fmt.Sprintf("%s's avatar is:", mention.Username),
File: &rest.File{
Name: "avatar.png",
ContentType: res.Header.Get("Content-Type"),
Reader: res.Body,
},
}

ctx.Shard.CreateMessageComplex(ctx.ChannelId, data)
}
}
17 changes: 7 additions & 10 deletions examples/starboard/starboard.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"context"

"github.com/TicketsBot-cloud/gdl/cache"
"github.com/TicketsBot-cloud/gdl/gateway"
"github.com/TicketsBot-cloud/gdl/gateway/payloads/events"
Expand All @@ -16,14 +18,9 @@ const (
)

func main() {
cacheFactory := cache.BoltCacheFactory(cache.CacheOptions{
cacheFactory := cache.MemoryCacheFactory(cache.CacheOptions{
Guilds: true,
Users: true,
}, cache.BoltOptions{
ClearOnRestart: false,
Path: "bolt.db",
FileMode: 600,
Options: nil,
})

shardOptions := gateway.ShardOptions{
Expand All @@ -47,20 +44,20 @@ func main() {

func reactListener(s *gateway.Shard, e *events.MessageReactionAdd) {
// check the new reaction is a star
if e.Emoji.Name != "⭐" {
if *e.Emoji.Name != "⭐" {
return
}

// get people who have reacted with a star so we can check if we've met the threshold
reactors, err := s.GetReactions(e.ChannelId, e.MessageId, "⭐", rest.GetReactionsData{})
reactors, err := s.GetReactions(context.Background(), e.ChannelId, e.MessageId, "⭐", rest.GetReactionsData{})
if err != nil {
logrus.Warn(err)
return
}

if len(reactors) >= StarThreshold {
// get the message object so we can get the content & sender
msg, err := s.GetChannelMessage(e.ChannelId, e.MessageId)
msg, err := s.GetChannelMessage(context.Background(), e.ChannelId, e.MessageId)
if err != nil {
logrus.Warn(err)
return
Expand All @@ -72,7 +69,7 @@ func reactListener(s *gateway.Shard, e *events.MessageReactionAdd) {
SetAuthor(msg.Author.Username, "", msg.Author.AvatarUrl(256)).
SetDescription(msg.Content)

if _, err := s.CreateMessageEmbed(StarboardChannelId, embed); err != nil {
if _, err := s.CreateMessageEmbed(context.Background(), StarboardChannelId, embed); err != nil {
logrus.Warn(err)
return
}
Expand Down
2 changes: 1 addition & 1 deletion gateway/cachelisteners.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func guildMemberRemoveListener(s *Shard, e *events.GuildMemberRemove) {

func guildMemberUpdateListener(s *Shard, e *events.GuildMemberUpdate) {
s.Cache.StoreMember(context.Background(), member.Member{
User: e.User,
User: &e.User,
Nick: e.Nick,
Roles: e.Roles,
PremiumSince: e.PremiumSince,
Expand Down
5 changes: 2 additions & 3 deletions gateway/payloads/events/eventbus.go → gateway/eventbus.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package events
package gateway

type EventBus struct {
Listeners []interface{}
}

func NewEventBus() *EventBus {
return &EventBus{
}
return &EventBus{}
}

func (e *EventBus) RegisterListener(fn interface{}) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package events

import "github.com/TicketsBot-cloud/gdl/objects/interaction"

type ApplicationCommandPermissionsUpdate struct {
interaction.GuildApplicationCommandPermissions
}
Loading
Loading