From aa8eec1821efa64e3d3f6691621d6c2db5ab4c92 Mon Sep 17 00:00:00 2001 From: mlnrDev Date: Tue, 29 Aug 2023 00:22:49 +0200 Subject: [PATCH 01/10] Add PermissionSetVoiceChannelStatus --- discord/permissions.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/discord/permissions.go b/discord/permissions.go index fe5a826a6..b402dc01c 100644 --- a/discord/permissions.go +++ b/discord/permissions.go @@ -63,6 +63,8 @@ const ( _ PermissionUseExternalSounds PermissionSendVoiceMessages + _ + PermissionSetVoiceChannelStatus PermissionsAllText = PermissionViewChannel | PermissionSendMessages | @@ -91,7 +93,8 @@ const ( PermissionUseSoundboard | PermissionUseExternalSounds | PermissionRequestToSpeak | - PermissionUseEmbeddedActivities + PermissionUseEmbeddedActivities | + PermissionSetVoiceChannelStatus PermissionsAllChannel = PermissionsAllText | PermissionsAllThread | @@ -168,6 +171,7 @@ var permissions = map[Permissions]string{ PermissionStream: "Video", PermissionViewGuildInsights: "View Server Insights", PermissionSendVoiceMessages: "Send Voice Messages", + PermissionSetVoiceChannelStatus: "Set Voice Channel Status", } func (p Permissions) String() string { From 622725609a7126e951cf361fec56ca5c51f138bc Mon Sep 17 00:00:00 2001 From: mlnrDev Date: Sun, 3 Sep 2023 22:35:35 +0200 Subject: [PATCH 02/10] Add voice channel status --- discord/channel.go | 11 +++++++++++ discord/channels_raw.go | 1 + events/guild_voice_events.go | 5 +++++ events/listener_adapter.go | 15 ++++++++++----- gateway/gateway_event_type.go | 1 + gateway/gateway_events.go | 9 +++++++++ gateway/gateway_messages.go | 5 +++++ handlers/all_handlers.go | 1 + handlers/voice_handlers.go | 7 +++++++ rest/channels.go | 4 ++++ rest/rest_endpoints.go | 2 ++ 11 files changed, 56 insertions(+), 5 deletions(-) diff --git a/discord/channel.go b/discord/channel.go index 4b0e9caf6..447522fe0 100644 --- a/discord/channel.go +++ b/discord/channel.go @@ -444,6 +444,7 @@ type GuildVoiceChannel struct { lastMessageID *snowflake.ID lastPinTimestamp *time.Time topic *string + status *string nsfw bool defaultAutoArchiveDuration AutoArchiveDuration rateLimitPerUser int @@ -468,6 +469,7 @@ func (c *GuildVoiceChannel) UnmarshalJSON(data []byte) error { c.lastMessageID = v.LastMessageID c.lastPinTimestamp = v.LastPinTimestamp c.topic = v.Topic + c.status = v.Status c.nsfw = v.NSFW c.defaultAutoArchiveDuration = v.DefaultAutoArchiveDuration c.rateLimitPerUser = v.RateLimitPerUser @@ -490,6 +492,7 @@ func (c GuildVoiceChannel) MarshalJSON() ([]byte, error) { LastMessageID: c.lastMessageID, LastPinTimestamp: c.lastPinTimestamp, Topic: c.topic, + Status: c.status, NSFW: c.nsfw, DefaultAutoArchiveDuration: c.defaultAutoArchiveDuration, RateLimitPerUser: c.rateLimitPerUser, @@ -552,6 +555,10 @@ func (c GuildVoiceChannel) Topic() *string { return c.topic } +func (c GuildVoiceChannel) Status() *string { + return c.status +} + func (c GuildVoiceChannel) NSFW() bool { return c.nsfw } @@ -1268,6 +1275,10 @@ type PartialChannel struct { Type ChannelType `json:"type"` } +type VoiceStatusUpdate struct { + Status string `json:"status"` +} + // VideoQualityMode https://com/developers/docs/resources/channel#channel-object-video-quality-modes type VideoQualityMode int diff --git a/discord/channels_raw.go b/discord/channels_raw.go index 33f75e8a3..689d0c677 100644 --- a/discord/channels_raw.go +++ b/discord/channels_raw.go @@ -131,6 +131,7 @@ type guildVoiceChannel struct { LastMessageID *snowflake.ID `json:"last_message_id"` LastPinTimestamp *time.Time `json:"last_pin_timestamp"` Topic *string `json:"topic"` + Status *string `json:"status"` NSFW bool `json:"nsfw"` DefaultAutoArchiveDuration AutoArchiveDuration `json:"default_auto_archive_duration"` RateLimitPerUser int `json:"rate_limit_per_user"` diff --git a/events/guild_voice_events.go b/events/guild_voice_events.go index bc3a5cbbb..e4e4035a7 100644 --- a/events/guild_voice_events.go +++ b/events/guild_voice_events.go @@ -40,3 +40,8 @@ type VoiceServerUpdate struct { *GenericEvent gateway.EventVoiceServerUpdate } + +type VoiceChannelStatusUpdate struct { + *GenericEvent + gateway.EventVoiceChannelStatusUpdate +} diff --git a/events/listener_adapter.go b/events/listener_adapter.go index ca82951ef..d79a255f3 100644 --- a/events/listener_adapter.go +++ b/events/listener_adapter.go @@ -104,11 +104,12 @@ type ListenerAdapter struct { OnGuildMessageReactionRemoveAll func(event *GuildMessageReactionRemoveAll) // Guild Voice Events - OnVoiceServerUpdate func(event *VoiceServerUpdate) - OnGuildVoiceStateUpdate func(event *GuildVoiceStateUpdate) - OnGuildVoiceJoin func(event *GuildVoiceJoin) - OnGuildVoiceMove func(event *GuildVoiceMove) - OnGuildVoiceLeave func(event *GuildVoiceLeave) + OnVoiceChannelStatusUpdate func(event *VoiceChannelStatusUpdate) + OnVoiceServerUpdate func(event *VoiceServerUpdate) + OnGuildVoiceStateUpdate func(event *GuildVoiceStateUpdate) + OnGuildVoiceJoin func(event *GuildVoiceJoin) + OnGuildVoiceMove func(event *GuildVoiceMove) + OnGuildVoiceLeave func(event *GuildVoiceLeave) // Guild StageInstance Events OnStageInstanceCreate func(event *StageInstanceCreate) @@ -445,6 +446,10 @@ func (l *ListenerAdapter) OnEvent(event bot.Event) { } // Guild Voice Events + case *VoiceChannelStatusUpdate: + if listener := l.OnVoiceChannelStatusUpdate; listener != nil { + listener(e) + } case *VoiceServerUpdate: if listener := l.OnVoiceServerUpdate; listener != nil { listener(e) diff --git a/gateway/gateway_event_type.go b/gateway/gateway_event_type.go index 88ebd49c4..1bd2376eb 100644 --- a/gateway/gateway_event_type.go +++ b/gateway/gateway_event_type.go @@ -66,6 +66,7 @@ const ( EventTypeStageInstanceUpdate EventType = "STAGE_INSTANCE_UPDATE" EventTypeTypingStart EventType = "TYPING_START" EventTypeUserUpdate EventType = "USER_UPDATE" + EventTypeVoiceChannelStatusUpdate EventType = "VOICE_CHANNEL_STATUS_UPDATE" EventTypeVoiceStateUpdate EventType = "VOICE_STATE_UPDATE" EventTypeVoiceServerUpdate EventType = "VOICE_SERVER_UPDATE" EventTypeWebhooksUpdate EventType = "WEBHOOKS_UPDATE" diff --git a/gateway/gateway_events.go b/gateway/gateway_events.go index 34a85a6b9..f59ec1639 100644 --- a/gateway/gateway_events.go +++ b/gateway/gateway_events.go @@ -568,6 +568,15 @@ type EventUserUpdate struct { func (EventUserUpdate) messageData() {} func (EventUserUpdate) eventData() {} +type EventVoiceChannelStatusUpdate struct { + ID snowflake.ID `json:"id"` + GuildID snowflake.ID `json:"guild_id"` + Status *string `json:"status"` +} + +func (EventVoiceChannelStatusUpdate) messageData() {} +func (EventVoiceChannelStatusUpdate) eventData() {} + type EventVoiceStateUpdate struct { discord.VoiceState Member discord.Member `json:"member"` diff --git a/gateway/gateway_messages.go b/gateway/gateway_messages.go index 8eca2e0f4..4a92f930e 100644 --- a/gateway/gateway_messages.go +++ b/gateway/gateway_messages.go @@ -394,6 +394,11 @@ func UnmarshalEventData(data []byte, eventType EventType) (EventData, error) { err = json.Unmarshal(data, &d) eventData = d + case EventTypeVoiceChannelStatusUpdate: + var d EventVoiceChannelStatusUpdate + err = json.Unmarshal(data, &d) + eventData = d + case EventTypeVoiceStateUpdate: var d EventVoiceStateUpdate err = json.Unmarshal(data, &d) diff --git a/handlers/all_handlers.go b/handlers/all_handlers.go index 5e1f2b5b0..cde8c5cc4 100644 --- a/handlers/all_handlers.go +++ b/handlers/all_handlers.go @@ -111,6 +111,7 @@ var allEventHandlers = []bot.GatewayEventHandler{ bot.NewGatewayEventHandler(gateway.EventTypeTypingStart, gatewayHandlerTypingStart), bot.NewGatewayEventHandler(gateway.EventTypeUserUpdate, gatewayHandlerUserUpdate), + bot.NewGatewayEventHandler(gateway.EventTypeVoiceChannelStatusUpdate, gatewayHandlerVoiceChannelStatusUpdate), bot.NewGatewayEventHandler(gateway.EventTypeVoiceStateUpdate, gatewayHandlerVoiceStateUpdate), bot.NewGatewayEventHandler(gateway.EventTypeVoiceServerUpdate, gatewayHandlerVoiceServerUpdate), diff --git a/handlers/voice_handlers.go b/handlers/voice_handlers.go index ea906ccc3..97f24a52c 100644 --- a/handlers/voice_handlers.go +++ b/handlers/voice_handlers.go @@ -61,3 +61,10 @@ func gatewayHandlerVoiceServerUpdate(client bot.Client, sequenceNumber int, shar EventVoiceServerUpdate: event, }) } + +func gatewayHandlerVoiceChannelStatusUpdate(client bot.Client, sequenceNumber int, shardID int, event gateway.EventVoiceChannelStatusUpdate) { + client.EventManager().DispatchEvent(&events.VoiceChannelStatusUpdate{ + GenericEvent: events.NewGenericEvent(client, sequenceNumber, shardID), + EventVoiceChannelStatusUpdate: event, + }) +} diff --git a/rest/channels.go b/rest/channels.go index 1ae7dee40..08ddac983 100644 --- a/rest/channels.go +++ b/rest/channels.go @@ -222,3 +222,7 @@ func (s *channelImpl) Follow(channelID snowflake.ID, targetChannelID snowflake.I err = s.client.Do(FollowChannel.Compile(nil, channelID), discord.FollowChannel{ChannelID: targetChannelID}, &followedChannel, opts...) return } + +func (s *channelImpl) UpdateVoiceStatus(channelID snowflake.ID, status string, opts ...RequestOpt) error { + return s.client.Do(UpdateVoiceStatus.Compile(nil, channelID), discord.VoiceStatusUpdate{Status: status}, nil, opts...) +} diff --git a/rest/rest_endpoints.go b/rest/rest_endpoints.go index 1cb2a12d7..edc9d0bcf 100644 --- a/rest/rest_endpoints.go +++ b/rest/rest_endpoints.go @@ -170,6 +170,8 @@ var ( SendTyping = NewEndpoint(http.MethodPost, "/channels/{channel.id}/typing") FollowChannel = NewEndpoint(http.MethodPost, "/channels/{channel.id}/followers") + + UpdateVoiceStatus = NewEndpoint(http.MethodPut, "/channels/{channel.id}/voice-status") ) // Threads From c66d4c6ef26db023f968243b6d304d1372b997c0 Mon Sep 17 00:00:00 2001 From: mlnrDev Date: Thu, 31 Aug 2023 18:28:07 +0200 Subject: [PATCH 03/10] Fix incorrect docs for Channel() funcs --- events/guild_invite_events.go | 2 +- events/guild_member_events.go | 2 +- events/guild_message_events.go | 2 +- events/guild_webhooks_update_events.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/events/guild_invite_events.go b/events/guild_invite_events.go index a733f017e..756bf22c4 100644 --- a/events/guild_invite_events.go +++ b/events/guild_invite_events.go @@ -14,7 +14,7 @@ type GenericInvite struct { Code string } -// Channel returns the Channel the GenericInvite happened in. +// Channel returns the discord.GuildChannel the GenericInvite happened in. func (e *GenericInvite) Channel() (discord.GuildChannel, bool) { return e.Client().Caches().Channel(e.ChannelID) } diff --git a/events/guild_member_events.go b/events/guild_member_events.go index 6189a5d79..4f649d9e3 100644 --- a/events/guild_member_events.go +++ b/events/guild_member_events.go @@ -47,7 +47,7 @@ type GuildMemberTypingStart struct { Member discord.Member } -// Channel returns the discord.BaseGuildMessageChannel the GuildMemberTypingStart happened in +// Channel returns the discord.GuildMessageChannel the GuildMemberTypingStart happened in func (e *GuildMemberTypingStart) Channel() (discord.GuildMessageChannel, bool) { return e.Client().Caches().GuildMessageChannel(e.ChannelID) } diff --git a/events/guild_message_events.go b/events/guild_message_events.go index 67e973e42..184cc68eb 100644 --- a/events/guild_message_events.go +++ b/events/guild_message_events.go @@ -21,7 +21,7 @@ func (e *GenericGuildMessage) Guild() (discord.Guild, bool) { return e.Client().Caches().Guild(e.GuildID) } -// Channel returns the discord.DMChannel where the GenericGuildMessage happened +// Channel returns the discord.GuildMessageChannel where the GenericGuildMessage happened func (e *GenericGuildMessage) Channel() (discord.GuildMessageChannel, bool) { return e.Client().Caches().GuildMessageChannel(e.ChannelID) } diff --git a/events/guild_webhooks_update_events.go b/events/guild_webhooks_update_events.go index e41fbf944..f1f44d95e 100644 --- a/events/guild_webhooks_update_events.go +++ b/events/guild_webhooks_update_events.go @@ -19,7 +19,7 @@ func (e *WebhooksUpdate) Guild() (discord.Guild, bool) { return e.Client().Caches().Guild(e.GuildId) } -// Channel returns the Channel the webhook was updated in. +// Channel returns the discord.GuildMessageChannel webhook was updated in. // This will only return cached channels! func (e *WebhooksUpdate) Channel() (discord.GuildMessageChannel, bool) { return e.Client().Caches().GuildMessageChannel(e.ChannelID) From d8c606f1b87f4322bb172c8f543e8f673f5be1a8 Mon Sep 17 00:00:00 2001 From: cane Date: Sun, 3 Sep 2023 21:21:37 +0200 Subject: [PATCH 04/10] Fix typo in func name (#307) --- bot/config.go | 8 ++++---- gateway/gateway_config.go | 12 ++++++------ rest/rest_client.go | 2 +- rest/rest_config.go | 22 +++++++++++----------- sharding/shard_manager_config.go | 14 +++++++------- sharding/shard_rate_limiter_impl.go | 4 ++-- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/bot/config.go b/bot/config.go index a0575299f..4108ccb4d 100644 --- a/bot/config.go +++ b/bot/config.go @@ -231,7 +231,7 @@ func BuildClient(token string, config Config, gatewayEventHandlerFunc func(clien rest.WithUserAgent(fmt.Sprintf("DiscordBot (%s, %s)", github, version)), rest.WithLogger(client.logger), func(config *rest.Config) { - config.RateRateLimiterConfigOpts = append([]rest.RateLimiterConfigOpt{rest.WithRateLimiterLogger(client.logger)}, config.RateRateLimiterConfigOpts...) + config.RateLimiterConfigOpts = append([]rest.RateLimiterConfigOpt{rest.WithRateLimiterLogger(client.logger)}, config.RateLimiterConfigOpts...) }, }, config.RestClientConfigOpts...) @@ -267,7 +267,7 @@ func BuildClient(token string, config Config, gatewayEventHandlerFunc func(clien gateway.WithBrowser(name), gateway.WithDevice(name), func(config *gateway.Config) { - config.RateRateLimiterConfigOpts = append([]gateway.RateLimiterConfigOpt{gateway.WithRateLimiterLogger(client.logger)}, config.RateRateLimiterConfigOpts...) + config.RateLimiterConfigOpts = append([]gateway.RateLimiterConfigOpt{gateway.WithRateLimiterLogger(client.logger)}, config.RateLimiterConfigOpts...) }, }, config.GatewayConfigOpts...) @@ -297,12 +297,12 @@ func BuildClient(token string, config Config, gatewayEventHandlerFunc func(clien gateway.WithBrowser(name), gateway.WithDevice(name), func(config *gateway.Config) { - config.RateRateLimiterConfigOpts = append([]gateway.RateLimiterConfigOpt{gateway.WithRateLimiterLogger(client.logger)}, config.RateRateLimiterConfigOpts...) + config.RateLimiterConfigOpts = append([]gateway.RateLimiterConfigOpt{gateway.WithRateLimiterLogger(client.logger)}, config.RateLimiterConfigOpts...) }, ), sharding.WithLogger(client.logger), func(config *sharding.Config) { - config.RateRateLimiterConfigOpts = append([]sharding.RateLimiterConfigOpt{sharding.WithRateLimiterLogger(client.logger), sharding.WithMaxConcurrency(gatewayBotRs.SessionStartLimit.MaxConcurrency)}, config.RateRateLimiterConfigOpts...) + config.RateLimiterConfigOpts = append([]sharding.RateLimiterConfigOpt{sharding.WithRateLimiterLogger(client.logger), sharding.WithMaxConcurrency(gatewayBotRs.SessionStartLimit.MaxConcurrency)}, config.RateLimiterConfigOpts...) }, }, config.ShardManagerConfigOpts...) diff --git a/gateway/gateway_config.go b/gateway/gateway_config.go index bb02be4d1..26d17df68 100644 --- a/gateway/gateway_config.go +++ b/gateway/gateway_config.go @@ -54,8 +54,8 @@ type Config struct { EnableResumeURL bool // RateLimiter is the RateLimiter of the Gateway. Defaults to NewRateLimiter(). RateLimiter RateLimiter - // RateRateLimiterConfigOpts is the RateLimiterConfigOpts of the Gateway. Defaults to nil. - RateRateLimiterConfigOpts []RateLimiterConfigOpt + // RateLimiterConfigOpts is the RateLimiterConfigOpts of the Gateway. Defaults to nil. + RateLimiterConfigOpts []RateLimiterConfigOpt // Presence is the presence it should send on login. Defaults to nil. Presence *MessageDataPresenceUpdate // OS is the OS it should send on login. Defaults to runtime.GOOS. @@ -75,7 +75,7 @@ func (c *Config) Apply(opts []ConfigOpt) { opt(c) } if c.RateLimiter == nil { - c.RateLimiter = NewRateLimiter(c.RateRateLimiterConfigOpts...) + c.RateLimiter = NewRateLimiter(c.RateLimiterConfigOpts...) } } @@ -184,10 +184,10 @@ func WithRateLimiter(rateLimiter RateLimiter) ConfigOpt { } } -// WithRateRateLimiterConfigOpts lets you configure the default RateLimiter. -func WithRateRateLimiterConfigOpts(opts ...RateLimiterConfigOpt) ConfigOpt { +// WithRateLimiterConfigOpts lets you configure the default RateLimiter. +func WithRateLimiterConfigOpts(opts ...RateLimiterConfigOpt) ConfigOpt { return func(config *Config) { - config.RateRateLimiterConfigOpts = append(config.RateRateLimiterConfigOpts, opts...) + config.RateLimiterConfigOpts = append(config.RateLimiterConfigOpts, opts...) } } diff --git a/rest/rest_client.go b/rest/rest_client.go index 8330178b9..e50edf6d3 100644 --- a/rest/rest_client.go +++ b/rest/rest_client.go @@ -32,7 +32,7 @@ type Client interface { // HTTPClient returns the http.Client the rest client uses HTTPClient() *http.Client - // RateLimiter returns the rrate.RateLimiter the rest client uses + // RateLimiter returns the RateLimiter the rest client uses RateLimiter() RateLimiter // Close closes the rest client and awaits all pending requests to finish. You can use a cancelling context to abort the waiting diff --git a/rest/rest_config.go b/rest/rest_config.go index 799b49037..65de4cc15 100644 --- a/rest/rest_config.go +++ b/rest/rest_config.go @@ -19,12 +19,12 @@ func DefaultConfig() *Config { // Config is the configuration for the rest client type Config struct { - Logger log.Logger - HTTPClient *http.Client - RateLimiter RateLimiter - RateRateLimiterConfigOpts []RateLimiterConfigOpt - URL string - UserAgent string + Logger log.Logger + HTTPClient *http.Client + RateLimiter RateLimiter + RateLimiterConfigOpts []RateLimiterConfigOpt + URL string + UserAgent string } // ConfigOpt can be used to supply optional parameters to NewClient @@ -36,7 +36,7 @@ func (c *Config) Apply(opts []ConfigOpt) { opt(c) } if c.RateLimiter == nil { - c.RateLimiter = NewRateLimiter(c.RateRateLimiterConfigOpts...) + c.RateLimiter = NewRateLimiter(c.RateLimiterConfigOpts...) } } @@ -54,17 +54,17 @@ func WithHTTPClient(httpClient *http.Client) ConfigOpt { } } -// WithRateLimiter applies a custom rrate.RateLimiter to the rest client +// WithRateLimiter applies a custom RateLimiter to the rest client func WithRateLimiter(rateLimiter RateLimiter) ConfigOpt { return func(config *Config) { config.RateLimiter = rateLimiter } } -// WithRateRateLimiterConfigOpts applies rrate.ConfigOpt for the rrate.RateLimiter to the rest rate limiter -func WithRateRateLimiterConfigOpts(opts ...RateLimiterConfigOpt) ConfigOpt { +// WithRateLimiterConfigOpts applies RateLimiterConfigOpt to the RateLimiter +func WithRateLimiterConfigOpts(opts ...RateLimiterConfigOpt) ConfigOpt { return func(config *Config) { - config.RateRateLimiterConfigOpts = append(config.RateRateLimiterConfigOpts, opts...) + config.RateLimiterConfigOpts = append(config.RateLimiterConfigOpts, opts...) } } diff --git a/sharding/shard_manager_config.go b/sharding/shard_manager_config.go index bb2ecb3d4..36adb92cf 100644 --- a/sharding/shard_manager_config.go +++ b/sharding/shard_manager_config.go @@ -33,8 +33,8 @@ type Config struct { GatewayConfigOpts []gateway.ConfigOpt // RateLimiter is the RateLimiter which is used by the ShardManager. Defaults to NewRateLimiter() RateLimiter RateLimiter - // RateRateLimiterConfigOpts are the RateLimiterConfigOpt(s) which are applied to the RateLimiter. - RateRateLimiterConfigOpts []RateLimiterConfigOpt + // RateLimiterConfigOpts are the RateLimiterConfigOpt(s) which are applied to the RateLimiter. + RateLimiterConfigOpts []RateLimiterConfigOpt } // ConfigOpt is a type alias for a function that takes a Config and is used to configure your Server. @@ -46,7 +46,7 @@ func (c *Config) Apply(opts []ConfigOpt) { opt(c) } if c.RateLimiter == nil { - c.RateLimiter = NewRateLimiter(c.RateRateLimiterConfigOpts...) + c.RateLimiter = NewRateLimiter(c.RateLimiterConfigOpts...) } } @@ -105,16 +105,16 @@ func WithGatewayConfigOpts(opts ...gateway.ConfigOpt) ConfigOpt { } } -// WithRateLimiter lets you inject your own srate.RateLimiter into the ShardManager. +// WithRateLimiter lets you inject your own RateLimiter into the ShardManager. func WithRateLimiter(rateLimiter RateLimiter) ConfigOpt { return func(config *Config) { config.RateLimiter = rateLimiter } } -// WithRateRateLimiterConfigOpt lets you configure the default srate.RateLimiter used by the ShardManager. -func WithRateRateLimiterConfigOpt(opts ...RateLimiterConfigOpt) ConfigOpt { +// WithRateLimiterConfigOpt lets you configure the default RateLimiter used by the ShardManager. +func WithRateLimiterConfigOpt(opts ...RateLimiterConfigOpt) ConfigOpt { return func(config *Config) { - config.RateRateLimiterConfigOpts = append(config.RateRateLimiterConfigOpts, opts...) + config.RateLimiterConfigOpts = append(config.RateLimiterConfigOpts, opts...) } } diff --git a/sharding/shard_rate_limiter_impl.go b/sharding/shard_rate_limiter_impl.go index ed4305275..315487538 100644 --- a/sharding/shard_rate_limiter_impl.go +++ b/sharding/shard_rate_limiter_impl.go @@ -46,10 +46,10 @@ func (r *rateLimiterImpl) Close(ctx context.Context) { } func (r *rateLimiterImpl) getBucket(shardID int, create bool) *bucket { - r.config.Logger.Debug("locking shard srate limiter") + r.config.Logger.Debug("locking shard rate limiter") r.mu.Lock() defer func() { - r.config.Logger.Debug("unlocking shard srate limiter") + r.config.Logger.Debug("unlocking shard rate limiter") r.mu.Unlock() }() key := ShardMaxConcurrencyKey(shardID, r.config.MaxConcurrency) From c579050b8e7361d646fe4f1438759f673b9c526a Mon Sep 17 00:00:00 2001 From: mlnrDev Date: Sun, 3 Sep 2023 21:31:35 +0200 Subject: [PATCH 05/10] I made a typo while fixing one --- events/guild_webhooks_update_events.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/events/guild_webhooks_update_events.go b/events/guild_webhooks_update_events.go index f1f44d95e..25857a76d 100644 --- a/events/guild_webhooks_update_events.go +++ b/events/guild_webhooks_update_events.go @@ -19,7 +19,7 @@ func (e *WebhooksUpdate) Guild() (discord.Guild, bool) { return e.Client().Caches().Guild(e.GuildId) } -// Channel returns the discord.GuildMessageChannel webhook was updated in. +// Channel returns the discord.GuildMessageChannel the webhook was updated in. // This will only return cached channels! func (e *WebhooksUpdate) Channel() (discord.GuildMessageChannel, bool) { return e.Client().Caches().GuildMessageChannel(e.ChannelID) From c820ef6dac2cb011cf3e776bf832d728d481b0e2 Mon Sep 17 00:00:00 2001 From: mlnrDev Date: Sun, 3 Sep 2023 22:41:50 +0200 Subject: [PATCH 06/10] Add missing func to interface --- rest/channels.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest/channels.go b/rest/channels.go index 08ddac983..a5c1419f6 100644 --- a/rest/channels.go +++ b/rest/channels.go @@ -46,7 +46,7 @@ type Channels interface { GetPinnedMessages(channelID snowflake.ID, opts ...RequestOpt) ([]discord.Message, error) PinMessage(channelID snowflake.ID, messageID snowflake.ID, opts ...RequestOpt) error UnpinMessage(channelID snowflake.ID, messageID snowflake.ID, opts ...RequestOpt) error - // TODO: add missing endpoints + Follow(channelID snowflake.ID, targetChannelID snowflake.ID, opts ...RequestOpt) (*discord.FollowedChannel, error) } type channelImpl struct { From 26a7bf9ad1bfefdcfdc0f4907c42435a4d2e320f Mon Sep 17 00:00:00 2001 From: mlnrDev Date: Sun, 3 Sep 2023 22:44:32 +0200 Subject: [PATCH 07/10] add func to interface shut the fuck up --- rest/channels.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rest/channels.go b/rest/channels.go index a5c1419f6..642b19206 100644 --- a/rest/channels.go +++ b/rest/channels.go @@ -47,6 +47,8 @@ type Channels interface { PinMessage(channelID snowflake.ID, messageID snowflake.ID, opts ...RequestOpt) error UnpinMessage(channelID snowflake.ID, messageID snowflake.ID, opts ...RequestOpt) error Follow(channelID snowflake.ID, targetChannelID snowflake.ID, opts ...RequestOpt) (*discord.FollowedChannel, error) + + UpdateVoiceStatus(channelID snowflake.ID, status string, opts ...RequestOpt) error } type channelImpl struct { From 9c65f448adff5393af7467197921cb61d11fff16 Mon Sep 17 00:00:00 2001 From: mlnrDev Date: Sun, 3 Sep 2023 22:51:41 +0200 Subject: [PATCH 08/10] add audit log events --- discord/audit_log.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/discord/audit_log.go b/discord/audit_log.go index 4135c5581..a962dfab4 100644 --- a/discord/audit_log.go +++ b/discord/audit_log.go @@ -122,6 +122,11 @@ const ( AuditLogCreatorMonetizationTermsAccepted ) +const ( + AuditLogVoiceChannelStatusCreate AuditLogEvent = iota + 192 + AuditLogVoiceChannelStatusUpdate +) + // AuditLog (https://discord.com/developers/docs/resources/audit-log) These are logs of events that occurred, accessible via the Discord type AuditLog struct { ApplicationCommands []ApplicationCommand `json:"application_commands"` From 6dd0eab124604c2e1b8b5c42e585f92f0255fb8f Mon Sep 17 00:00:00 2001 From: mlnrDev Date: Mon, 4 Sep 2023 19:57:48 +0200 Subject: [PATCH 09/10] add Status to OptionalAuditLogEntryInfo --- discord/audit_log.go | 1 + 1 file changed, 1 insertion(+) diff --git a/discord/audit_log.go b/discord/audit_log.go index a962dfab4..c4be6eb80 100644 --- a/discord/audit_log.go +++ b/discord/audit_log.go @@ -260,4 +260,5 @@ type OptionalAuditLogEntryInfo struct { AutoModerationRuleName *string `json:"auto_moderation_rule_name"` AutoModerationRuleTriggerType *AutoModerationTriggerType `json:"auto_moderation_rule_trigger_type,string"` IntegrationType *IntegrationType `json:"integration_type"` + Status *string `json:"status"` } From ee08f4f73f4e3b0f71099a5038b97341281efabc Mon Sep 17 00:00:00 2001 From: mlnrDev Date: Wed, 6 Sep 2023 16:09:22 +0200 Subject: [PATCH 10/10] fix audit log even const name --- discord/audit_log.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/audit_log.go b/discord/audit_log.go index c4be6eb80..8a0008073 100644 --- a/discord/audit_log.go +++ b/discord/audit_log.go @@ -124,7 +124,7 @@ const ( const ( AuditLogVoiceChannelStatusCreate AuditLogEvent = iota + 192 - AuditLogVoiceChannelStatusUpdate + AuditLogVoiceChannelStatusDelete ) // AuditLog (https://discord.com/developers/docs/resources/audit-log) These are logs of events that occurred, accessible via the Discord