From 304919b92bf947babf3f0bff7ecd1abb5aba1077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20=C3=98en=20Fylling?= Date: Sat, 24 Oct 2020 20:09:04 +0200 Subject: [PATCH] replace MessageSender interfaces with Session --- channel.go | 8 ++++---- message.go | 9 ++------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/channel.go b/channel.go index 28739a70..7e39ed99 100644 --- a/channel.go +++ b/channel.go @@ -251,7 +251,7 @@ func (c *Channel) CopyOverTo(other interface{}) (err error) { } // SendMsgString same as SendMsg, however this only takes the message content (string) as a argument for the message -func (c *Channel) SendMsgString(ctx context.Context, client MessageSender, content string) (msg *Message, err error) { +func (c *Channel) SendMsgString(ctx context.Context, s Session, content string) (msg *Message, err error) { if c.ID.IsZero() { err = newErrorMissingSnowflake("snowflake ID not set for channel") return @@ -260,12 +260,12 @@ func (c *Channel) SendMsgString(ctx context.Context, client MessageSender, conte Content: content, } - msg, err = client.CreateMessage(ctx, c.ID, params) + msg, err = s.Channel(c.ID).WithContext(ctx).CreateMessage(params) return } // SendMsg sends a message to a channel -func (c *Channel) SendMsg(ctx context.Context, client MessageSender, message *Message) (msg *Message, err error) { +func (c *Channel) SendMsg(ctx context.Context, s Session, message *Message) (msg *Message, err error) { if c.ID.IsZero() { err = newErrorMissingSnowflake("snowflake ID not set for channel") return @@ -286,7 +286,7 @@ func (c *Channel) SendMsg(ctx context.Context, client MessageSender, message *Me params.Embed = message.Embeds[0] } - msg, err = client.CreateMessage(ctx, c.ID, params) + msg, err = s.Channel(c.ID).WithContext(ctx).CreateMessage(params) return } diff --git a/message.go b/message.go index 9f771085..df36b6ff 100644 --- a/message.go +++ b/message.go @@ -254,13 +254,8 @@ func (m *Message) CopyOverTo(other interface{}) (err error) { return } -// MessageSender is an interface which only holds the method needed for creating a channel message -type MessageSender interface { - CreateMessage(ctx context.Context, channelID Snowflake, params *CreateMessageParams, flags ...Flag) (ret *Message, err error) -} - // Send sends this message to discord. -func (m *Message) Send(ctx context.Context, client MessageSender, flags ...Flag) (msg *Message, err error) { +func (m *Message) Send(ctx context.Context, s Session, flags ...Flag) (msg *Message, err error) { nonce := fmt.Sprint(m.Nonce) if len(nonce) > 25 { return nil, errors.New("nonce can not be more than 25 characters") @@ -280,7 +275,7 @@ func (m *Message) Send(ctx context.Context, client MessageSender, flags ...Flag) } channelID := m.ChannelID - msg, err = client.CreateMessage(ctx, channelID, params, flags...) + msg, err = s.Channel(channelID).WithContext(ctx).CreateMessage(params, flags...) return }