emote command
This commit is contained in:
parent
1593736c70
commit
4aa208ee69
|
@ -0,0 +1,37 @@
|
||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/Cynosphere/comcord/lib"
|
||||||
|
"github.com/Cynosphere/comcord/state"
|
||||||
|
"github.com/bwmarrin/discordgo"
|
||||||
|
)
|
||||||
|
|
||||||
|
func EmoteCommand(session *discordgo.Session) {
|
||||||
|
channelId := state.GetCurrentChannel()
|
||||||
|
if channelId == "" {
|
||||||
|
fmt.Print("<not in a channel>\n\r")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
prompt := ":emote> "
|
||||||
|
lib.MakePrompt(session, prompt, true, func(session *discordgo.Session, input string, interrupt bool) {
|
||||||
|
if input == "" {
|
||||||
|
if interrupt {
|
||||||
|
fmt.Print("^C<no message sent>\n\r")
|
||||||
|
} else {
|
||||||
|
fmt.Print(prompt, "<no message sent>\n\r")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Print(prompt, input, "\n\r")
|
||||||
|
_, err := session.ChannelMessageSend(channelId, "*" + input + "*")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Print("<failed to send message: ", err, ">\n\r")
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: update afk state
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
|
@ -26,6 +26,11 @@ func Setup() {
|
||||||
Run: ClearCommand,
|
Run: ClearCommand,
|
||||||
Description: "clear",
|
Description: "clear",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
commandMap["e"] = Command{
|
||||||
|
Run: EmoteCommand,
|
||||||
|
Description: "emote",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCommand(key string) (Command, bool) {
|
func GetCommand(key string) (Command, bool) {
|
||||||
|
|
|
@ -15,11 +15,9 @@ func SendMode(session *discordgo.Session) {
|
||||||
channelId := state.GetCurrentChannel()
|
channelId := state.GetCurrentChannel()
|
||||||
if channelId == "" {
|
if channelId == "" {
|
||||||
fmt.Print("<not in a channel>\n\r")
|
fmt.Print("<not in a channel>\n\r")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
state.SetInPrompt(true)
|
|
||||||
|
|
||||||
length := utf8.RuneCountInString(session.State.User.Username) + 2
|
length := utf8.RuneCountInString(session.State.User.Username) + 2
|
||||||
curLength := state.GetNameLength()
|
curLength := state.GetNameLength()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue