updates from testing
This commit is contained in:
68
message.go
68
message.go
@@ -2,7 +2,6 @@ package bolt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
dg "github.com/bwmarrin/discordgo"
|
||||
)
|
||||
@@ -17,24 +16,28 @@ const (
|
||||
// a timeout to prevent hanging for too long, this timeout can be customized with the WithTimeout
|
||||
// option.
|
||||
type Message struct {
|
||||
Author string //current username of the message author
|
||||
authorID string //discord ID of message author
|
||||
authorRoles []string
|
||||
Author Author
|
||||
ID string //message ID
|
||||
Words []string //message data split on whitespaces
|
||||
Content string //entire message data string
|
||||
Channel string //name of channel message was sent in
|
||||
channelID string //ID of channel message was sent in
|
||||
ChannelID string //ID of channel message was sent in
|
||||
Server string //name of guild message was sent in
|
||||
serverID string //ID of guild message was sent in
|
||||
ServerID string //ID of guild message was sent in
|
||||
Attachments []MessageAttachment //any attachments bound to the message
|
||||
Mentions []*dg.User
|
||||
sesh *bolt
|
||||
}
|
||||
|
||||
type Author struct {
|
||||
Name string
|
||||
ID string
|
||||
Roles []string
|
||||
}
|
||||
|
||||
// React applies reaction to the message
|
||||
func (m *Message) React(emoji Reaction) error {
|
||||
return m.sesh.MessageReactionAdd(m.channelID, m.ID, fmt.Sprint(emoji))
|
||||
return m.sesh.MessageReactionAdd(m.ChannelID, m.ID, fmt.Sprint(emoji))
|
||||
}
|
||||
|
||||
// Respond sends a response to the message, handling chunking if the message exceeds max length
|
||||
@@ -43,8 +46,8 @@ func (m *Message) Respond(res string) error {
|
||||
for len(res) > 0 {
|
||||
//send full chunk size allowed by discord
|
||||
sc := res[:MSG_MAX_LENGTH]
|
||||
rep := m.sesh.createReply(sc, m.ID, m.channelID, m.serverID)
|
||||
_, err := m.sesh.ChannelMessageSendComplex(m.channelID, rep)
|
||||
rep := m.sesh.createReply(sc, m.ID, m.ChannelID, m.ServerID)
|
||||
_, err := m.sesh.ChannelMessageSendComplex(m.ChannelID, rep)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -52,8 +55,8 @@ func (m *Message) Respond(res string) error {
|
||||
|
||||
//if we have left than a full chunk send the rest and break the loop
|
||||
if len(res) < MSG_MAX_LENGTH {
|
||||
final := m.sesh.createReply(res, m.ID, m.channelID, m.serverID)
|
||||
_, err := m.sesh.ChannelMessageSendComplex(m.channelID, final)
|
||||
final := m.sesh.createReply(res, m.ID, m.ChannelID, m.ServerID)
|
||||
_, err := m.sesh.ChannelMessageSendComplex(m.ChannelID, final)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -66,44 +69,31 @@ func (m *Message) Respond(res string) error {
|
||||
}
|
||||
|
||||
//short enough message to send in one go
|
||||
rep := m.sesh.createReply(res, m.ID, m.channelID, m.serverID)
|
||||
_, err := m.sesh.ChannelMessageSendComplex(m.channelID, rep)
|
||||
rep := m.sesh.createReply(res, m.ID, m.ChannelID, m.ServerID)
|
||||
_, err := m.sesh.ChannelMessageSendComplex(m.ChannelID, rep)
|
||||
return err
|
||||
}
|
||||
|
||||
// Delete removes the message from the current channel
|
||||
func (m *Message) Delete() error {
|
||||
return m.sesh.ChannelMessageDelete(m.channelID, m.ID, nil)
|
||||
return m.sesh.ChannelMessageDelete(m.ChannelID, m.ID, nil)
|
||||
}
|
||||
|
||||
// Timeout sets a timeout for the message author
|
||||
func (m *Message) Timeout(duration time.Time) error {
|
||||
return m.sesh.GuildMemberTimeout(m.serverID, m.authorID, &duration)
|
||||
}
|
||||
// func (m *Message) Timeout(userID string, duration time.Time) error {
|
||||
// return m.sesh.GuildMemberTimeout(m.serverID, userID, &duration)
|
||||
// }
|
||||
|
||||
// ClearTimeout removes all timeouts for the message author
|
||||
func (m *Message) ClearTimeout() error {
|
||||
return m.sesh.GuildMemberTimeout(m.serverID, m.authorID, nil)
|
||||
}
|
||||
// func (m *Message) ClearTimeout(userID string) error {
|
||||
// return m.sesh.GuildMemberTimeout(m.serverID, userID, nil)
|
||||
// }
|
||||
|
||||
// Ban removes a user from the server, banning them and removing all messages within the range of
|
||||
// the days parameter
|
||||
func (m *Message) Ban(reason string, days int) error {
|
||||
return m.sesh.GuildBanCreateWithReason(m.serverID, m.authorID, reason, days)
|
||||
}
|
||||
// func (m *Message) Mute(userID string) error {
|
||||
// return m.sesh.GuildMemberMute(m.serverID, userID, true)
|
||||
// }
|
||||
|
||||
// unban user
|
||||
|
||||
// ClearBan deletes the ban on message Authors
|
||||
|
||||
// lol this won't work, they're banned, same with all clear*
|
||||
func (m *Message) ClearBan() error {
|
||||
return m.sesh.GuildBanDelete(m.serverID, m.authorID)
|
||||
}
|
||||
|
||||
func (m *Message) Mute(username string) error {
|
||||
return m.sesh.GuildMemberMute(m.serverID, m.authorID, true)
|
||||
}
|
||||
// func (m *Author) Unmute(userID string) error {
|
||||
// return m.sesh.GuildMemberMute(m.serverID, userID, false)
|
||||
// }
|
||||
|
||||
// message attachment details
|
||||
type MessageAttachment struct {
|
||||
|
||||
Reference in New Issue
Block a user