Skip to content

Commit 67ddd7c

Browse files
committed
change Interaction.Channel from PartialChannel to InteractionChannel
1 parent 3eb45b6 commit 67ddd7c

File tree

4 files changed

+16
-42
lines changed

4 files changed

+16
-42
lines changed

discord/interaction.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ type rawInteraction struct {
2828
Version int `json:"version"`
2929
GuildID *snowflake.ID `json:"guild_id,omitempty"`
3030
// Deprecated: Use Channel instead
31-
ChannelID snowflake.ID `json:"channel_id,omitempty"`
32-
Channel *PartialChannel `json:"channel,omitempty"`
33-
Locale Locale `json:"locale,omitempty"`
34-
GuildLocale *Locale `json:"guild_locale,omitempty"`
35-
Member *ResolvedMember `json:"member,omitempty"`
36-
User *User `json:"user,omitempty"`
37-
AppPermissions *Permissions `json:"app_permissions,omitempty"`
31+
ChannelID snowflake.ID `json:"channel_id,omitempty"`
32+
Channel InteractionChannel `json:"channel,omitempty"`
33+
Locale Locale `json:"locale,omitempty"`
34+
GuildLocale *Locale `json:"guild_locale,omitempty"`
35+
Member *ResolvedMember `json:"member,omitempty"`
36+
User *User `json:"user,omitempty"`
37+
AppPermissions *Permissions `json:"app_permissions,omitempty"`
3838
}
3939

4040
// Interaction is used for easier unmarshalling of different Interaction(s)
@@ -47,7 +47,7 @@ type Interaction interface {
4747
GuildID() *snowflake.ID
4848
// Deprecated: Use Interaction.Channel instead
4949
ChannelID() snowflake.ID
50-
Channel() *PartialChannel
50+
Channel() InteractionChannel
5151
Locale() Locale
5252
GuildLocale() *Locale
5353
Member() *ResolvedMember
@@ -121,4 +121,8 @@ type (
121121
ThreadMetadata ThreadMetadata `json:"thread_metadata"`
122122
ParentID snowflake.ID `json:"parent_id"`
123123
}
124+
InteractionChannel struct {
125+
MessageChannel
126+
Permissions Permissions `json:"permissions"`
127+
}
124128
)

discord/interaction_base.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type baseInteraction struct {
1313
version int
1414
guildID *snowflake.ID
1515
channelID snowflake.ID
16-
channel *PartialChannel
16+
channel InteractionChannel
1717
locale Locale
1818
guildLocale *Locale
1919
member *ResolvedMember
@@ -41,7 +41,7 @@ func (i baseInteraction) GuildID() *snowflake.ID {
4141
func (i baseInteraction) ChannelID() snowflake.ID {
4242
return i.channelID
4343
}
44-
func (i baseInteraction) Channel() *PartialChannel {
44+
func (i baseInteraction) Channel() InteractionChannel {
4545
return i.channel
4646
}
4747
func (i baseInteraction) Locale() Locale {

discord/interaction_ping.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ func (PingInteraction) ChannelID() snowflake.ID {
7272
return 0
7373
}
7474

75-
func (PingInteraction) Channel() *PartialChannel {
76-
return nil
75+
func (PingInteraction) Channel() InteractionChannel {
76+
return InteractionChannel{}
7777
}
7878

7979
func (PingInteraction) Locale() Locale {

events/interaction_events.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ func (e *InteractionCreate) Guild() (discord.Guild, bool) {
2525
return discord.Guild{}, false
2626
}
2727

28-
// MessageChannel returns the discord.GuildMessageChannel that the interaction happened in.
29-
// This only returns cached channels.
30-
func (e *InteractionCreate) MessageChannel() (discord.GuildMessageChannel, bool) {
31-
return e.Client().Caches().GuildMessageChannel(e.Channel().ID)
32-
}
33-
3428
// ApplicationCommandInteractionCreate is the base struct for all application command interaction create events.
3529
type ApplicationCommandInteractionCreate struct {
3630
*GenericEvent
@@ -48,12 +42,6 @@ func (e *ApplicationCommandInteractionCreate) Guild() (discord.Guild, bool) {
4842
return discord.Guild{}, false
4943
}
5044

51-
// MessageChannel returns the discord.GuildMessageChannel that the interaction happened in.
52-
// This only returns cached channels.
53-
func (e *ApplicationCommandInteractionCreate) MessageChannel() (discord.GuildMessageChannel, bool) {
54-
return e.Client().Caches().GuildMessageChannel(e.Channel().ID)
55-
}
56-
5745
// CreateMessage responds to the interaction with a new message.
5846
func (e *ApplicationCommandInteractionCreate) CreateMessage(messageCreate discord.MessageCreate, opts ...rest.RequestOpt) error {
5947
return e.Respond(discord.InteractionResponseTypeCreateMessage, messageCreate, opts...)
@@ -90,12 +78,6 @@ func (e *ComponentInteractionCreate) Guild() (discord.Guild, bool) {
9078
return discord.Guild{}, false
9179
}
9280

93-
// MessageChannel returns the discord.GuildMessageChannel that the interaction happened in.
94-
// This only returns cached channels.
95-
func (e *ComponentInteractionCreate) MessageChannel() (discord.GuildMessageChannel, bool) {
96-
return e.Client().Caches().GuildMessageChannel(e.Channel().ID)
97-
}
98-
9981
// CreateMessage responds to the interaction with a new message.
10082
func (e *ComponentInteractionCreate) CreateMessage(messageCreate discord.MessageCreate, opts ...rest.RequestOpt) error {
10183
return e.Respond(discord.InteractionResponseTypeCreateMessage, messageCreate, opts...)
@@ -142,12 +124,6 @@ func (e *AutocompleteInteractionCreate) Guild() (discord.Guild, bool) {
142124
return discord.Guild{}, false
143125
}
144126

145-
// MessageChannel returns the discord.GuildMessageChannel that the interaction happened in.
146-
// This only returns cached channels.
147-
func (e *AutocompleteInteractionCreate) MessageChannel() (discord.GuildMessageChannel, bool) {
148-
return e.Client().Caches().GuildMessageChannel(e.Channel().ID)
149-
}
150-
151127
// Result responds to the interaction with a slice of choices.
152128
func (e *AutocompleteInteractionCreate) Result(choices []discord.AutocompleteChoice, opts ...rest.RequestOpt) error {
153129
return e.Respond(discord.InteractionResponseTypeApplicationCommandAutocompleteResult, discord.AutocompleteResult{Choices: choices}, opts...)
@@ -170,12 +146,6 @@ func (e *ModalSubmitInteractionCreate) Guild() (discord.Guild, bool) {
170146
return discord.Guild{}, false
171147
}
172148

173-
// MessageChannel returns the discord.GuildMessageChannel that the interaction happened in.
174-
// This only returns cached channels.
175-
func (e *ModalSubmitInteractionCreate) MessageChannel() (discord.GuildMessageChannel, bool) {
176-
return e.Client().Caches().GuildMessageChannel(e.Channel().ID)
177-
}
178-
179149
// CreateMessage responds to the interaction with a new message.
180150
func (e *ModalSubmitInteractionCreate) CreateMessage(messageCreate discord.MessageCreate, opts ...rest.RequestOpt) error {
181151
return e.Respond(discord.InteractionResponseTypeCreateMessage, messageCreate, opts...)

0 commit comments

Comments
 (0)