Compare commits
5 Commits
new/vc-sup
...
7376e8f857
Author | SHA1 | Date | |
---|---|---|---|
7376e8f857 | |||
c196e25e0c
|
|||
d70dd8c3a4
|
|||
6504336d01 | |||
a310fd4533
|
@@ -44,6 +44,10 @@ The React method will react to the command message by adding the requested emoji
|
|||||||
func (m *Message) Respond(res string) error
|
func (m *Message) Respond(res string) error
|
||||||
```
|
```
|
||||||
The Respond method will send the value of <b>res</b> in response to the command message.
|
The Respond method will send the value of <b>res</b> in response to the command message.
|
||||||
|
```go
|
||||||
|
func Delete() error
|
||||||
|
```
|
||||||
|
The Delete method will delete the message from the text channel
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
```go
|
```go
|
||||||
|
28
bolt.go
28
bolt.go
@@ -1,7 +1,6 @@
|
|||||||
package bolt
|
package bolt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
@@ -44,7 +43,6 @@ type Bolt interface {
|
|||||||
getRemainingTimeout(timeout time.Time) string
|
getRemainingTimeout(timeout time.Time) string
|
||||||
roleCheck(guild string, roles []string, s *dg.Session, run Command) (bool, error)
|
roleCheck(guild string, roles []string, s *dg.Session, run Command) (bool, error)
|
||||||
timeoutCheck(msgID, channelID, guildID string, s *dg.Session, run Command) (bool, error)
|
timeoutCheck(msgID, channelID, guildID string, s *dg.Session, run Command) (bool, error)
|
||||||
joinUserVoice(guild, user string, s *dg.Session) (*dg.VoiceConnection, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a new bolt interface
|
// create a new bolt interface
|
||||||
@@ -330,29 +328,3 @@ func (b *bolt) timeoutCheck(msgID, channelID, guildID string, s *dg.Session, run
|
|||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bolt) joinUserVoice(guild, user string, s *dg.Session) (*dg.VoiceConnection, error) {
|
|
||||||
g, err := s.State.Guild(guild)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var chanID string
|
|
||||||
for _, x := range g.VoiceStates {
|
|
||||||
if user == x.UserID {
|
|
||||||
chanID = x.ChannelID
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if chanID == "" {
|
|
||||||
return nil, errors.New("user is not in a voice channel")
|
|
||||||
}
|
|
||||||
|
|
||||||
//joining voice channel: false = not muted, true = deafened
|
|
||||||
dgv, err := s.ChannelVoiceJoin(guild, chanID, false, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return dgv, nil
|
|
||||||
}
|
|
||||||
|
104
message.go
104
message.go
@@ -6,71 +6,8 @@ import (
|
|||||||
dg "github.com/bwmarrin/discordgo"
|
dg "github.com/bwmarrin/discordgo"
|
||||||
)
|
)
|
||||||
|
|
||||||
// built-in Discord reactions
|
// the message struct is passed to the command payload providing basic
|
||||||
type Reaction string
|
// message information and needed methods
|
||||||
|
|
||||||
// a few easy-to-use emojis, Discordgo/Discord API requires them to be saved like this.
|
|
||||||
const (
|
|
||||||
ReactionThumbsUp Reaction = "👍"
|
|
||||||
ReactionThumbsDown Reaction = "👎"
|
|
||||||
ReactionHundred Reaction = "💯"
|
|
||||||
ReactionHeart Reaction = "❤️"
|
|
||||||
ReactionPinkHeart Reaction = "🩷"
|
|
||||||
ReactionOrangeHeart Reaction = "🧡"
|
|
||||||
ReactionYellowHeart Reaction = "💛"
|
|
||||||
ReactionGreenHeart Reaction = "💚"
|
|
||||||
ReactionBlueHeart Reaction = "💙"
|
|
||||||
ReactionBlackHeart Reaction = "🖤"
|
|
||||||
ReactionPointUp Reaction = "☝️"
|
|
||||||
ReactionPointDown Reaction = "👇"
|
|
||||||
ReactionHotdog Reaction = "🌭"
|
|
||||||
ReactionDog Reaction = "🐶"
|
|
||||||
ReactionCat Reaction = "🐱"
|
|
||||||
ReactionMonkey Reaction = "🐒"
|
|
||||||
ReactionGiraffe Reaction = "🦒"
|
|
||||||
ReactionDuck Reaction = "🦆"
|
|
||||||
ReactionGoose Reaction = "🪿"
|
|
||||||
ReactionWatermelon Reaction = "🍉"
|
|
||||||
ReactionHoney Reaction = "🍯"
|
|
||||||
ReactionSandwich Reaction = "🥪"
|
|
||||||
ReactionPepper Reaction = "🌶️"
|
|
||||||
ReactionNoPedestrians Reaction = "🚷"
|
|
||||||
ReactionExclamation Reaction = "❗"
|
|
||||||
ReactionDoubleExclamation Reaction = "‼️"
|
|
||||||
ReactionSkull Reaction = "💀"
|
|
||||||
ReactionSpeakingHead Reaction = "🗣️"
|
|
||||||
ReactionGreenCheck Reaction = "✅"
|
|
||||||
ReactionDragon Reaction = "🐉"
|
|
||||||
)
|
|
||||||
|
|
||||||
// struct containing message event fields to prevent passing MessageCreate events and holding up routines
|
|
||||||
type MessageCreateEvent struct {
|
|
||||||
AuthorUsername string
|
|
||||||
AuthorID string
|
|
||||||
AuthorRoles []string
|
|
||||||
MsgID string
|
|
||||||
Msg string
|
|
||||||
MsgChanID string
|
|
||||||
MsgChanName string
|
|
||||||
MsgGuildID string
|
|
||||||
MsgGuildName string
|
|
||||||
MsgAttachments []*dg.MessageAttachment
|
|
||||||
}
|
|
||||||
|
|
||||||
// information about attachments to messages
|
|
||||||
type MessageAttachment struct {
|
|
||||||
ID string
|
|
||||||
URL string
|
|
||||||
ProxyURL string
|
|
||||||
Filename string
|
|
||||||
ContentType string
|
|
||||||
Width int
|
|
||||||
Height int
|
|
||||||
Size int
|
|
||||||
DurationSecs float64
|
|
||||||
}
|
|
||||||
|
|
||||||
// represents a Discord message
|
|
||||||
type Message struct {
|
type Message struct {
|
||||||
Author string //username of message author
|
Author string //username of message author
|
||||||
ID string //discord ID of message author
|
ID string //discord ID of message author
|
||||||
@@ -90,15 +27,42 @@ func (m *Message) React(emoji Reaction) error {
|
|||||||
return m.sesh.MessageReactionAdd(m.channelID, m.msgID, fmt.Sprint(emoji))
|
return m.sesh.MessageReactionAdd(m.channelID, m.msgID, fmt.Sprint(emoji))
|
||||||
}
|
}
|
||||||
|
|
||||||
// sends the value of res in response to the message
|
// sends response to message
|
||||||
func (m *Message) Respond(res string) error {
|
func (m *Message) Respond(res string) error {
|
||||||
rep := m.sesh.createReply(res, m.msgID, m.channelID, m.serverID)
|
rep := m.sesh.createReply(res, m.msgID, m.channelID, m.serverID)
|
||||||
_, err := m.sesh.ChannelMessageSendComplex(m.channelID, rep)
|
_, err := m.sesh.ChannelMessageSendComplex(m.channelID, rep)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// joins the message author's voice channel. Returns the voice connection object, this connection must be cleaned
|
// deletes the message from the channel
|
||||||
// up by the client to prevent issues
|
func (m *Message) Delete() error {
|
||||||
func (m *Message) JoinVoiceChannel() (*dg.VoiceConnection, error) {
|
return m.sesh.ChannelMessageDelete(m.channelID, m.msgID, nil)
|
||||||
return m.sesh.joinUserVoice(m.serverID, m.ID, m.sesh.Session)
|
}
|
||||||
|
|
||||||
|
// this struct has all of the needed information from the messageCreate event so that
|
||||||
|
// commands can be run asynchronously. Passing the messageCreate to payloads can block routines
|
||||||
|
type MessageCreateEvent struct {
|
||||||
|
AuthorUsername string
|
||||||
|
AuthorID string
|
||||||
|
AuthorRoles []string
|
||||||
|
MsgID string
|
||||||
|
Msg string
|
||||||
|
MsgChanID string
|
||||||
|
MsgChanName string
|
||||||
|
MsgGuildID string
|
||||||
|
MsgGuildName string
|
||||||
|
MsgAttachments []*dg.MessageAttachment
|
||||||
|
}
|
||||||
|
|
||||||
|
// message attachment details
|
||||||
|
type MessageAttachment struct {
|
||||||
|
ID string
|
||||||
|
URL string
|
||||||
|
ProxyURL string
|
||||||
|
Filename string
|
||||||
|
ContentType string
|
||||||
|
Width int
|
||||||
|
Height int
|
||||||
|
Size int
|
||||||
|
DurationSecs float64
|
||||||
}
|
}
|
||||||
|
38
reaction.go
Normal file
38
reaction.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package bolt
|
||||||
|
|
||||||
|
// built-in Discord reactions
|
||||||
|
type Reaction string
|
||||||
|
|
||||||
|
// a few easy-to-use emojis, Discordgo/Discord API requires them to be saved like this.
|
||||||
|
const (
|
||||||
|
ReactionThumbsUp Reaction = "👍"
|
||||||
|
ReactionThumbsDown Reaction = "👎"
|
||||||
|
ReactionHundred Reaction = "💯"
|
||||||
|
ReactionHeart Reaction = "❤️"
|
||||||
|
ReactionPinkHeart Reaction = "🩷"
|
||||||
|
ReactionOrangeHeart Reaction = "🧡"
|
||||||
|
ReactionYellowHeart Reaction = "💛"
|
||||||
|
ReactionGreenHeart Reaction = "💚"
|
||||||
|
ReactionBlueHeart Reaction = "💙"
|
||||||
|
ReactionBlackHeart Reaction = "🖤"
|
||||||
|
ReactionPointUp Reaction = "☝️"
|
||||||
|
ReactionPointDown Reaction = "👇"
|
||||||
|
ReactionHotdog Reaction = "🌭"
|
||||||
|
ReactionDog Reaction = "🐶"
|
||||||
|
ReactionCat Reaction = "🐱"
|
||||||
|
ReactionMonkey Reaction = "🐒"
|
||||||
|
ReactionGiraffe Reaction = "🦒"
|
||||||
|
ReactionDuck Reaction = "🦆"
|
||||||
|
ReactionGoose Reaction = "🪿"
|
||||||
|
ReactionWatermelon Reaction = "🍉"
|
||||||
|
ReactionHoney Reaction = "🍯"
|
||||||
|
ReactionSandwich Reaction = "🥪"
|
||||||
|
ReactionPepper Reaction = "🌶️"
|
||||||
|
ReactionNoPedestrians Reaction = "🚷"
|
||||||
|
ReactionExclamation Reaction = "❗"
|
||||||
|
ReactionDoubleExclamation Reaction = "‼️"
|
||||||
|
ReactionSkull Reaction = "💀"
|
||||||
|
ReactionSpeakingHead Reaction = "🗣️"
|
||||||
|
ReactionGreenCheck Reaction = "✅"
|
||||||
|
ReactionDragon Reaction = "🐉"
|
||||||
|
)
|
Reference in New Issue
Block a user