2023-07-11 03:46:47 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/Cynosphere/comcord/lib"
|
|
|
|
"github.com/Cynosphere/comcord/state"
|
2023-07-27 02:27:04 +00:00
|
|
|
"github.com/diamondburned/arikawa/v3/discord"
|
2023-07-11 03:46:47 +00:00
|
|
|
)
|
|
|
|
|
2023-07-27 02:27:04 +00:00
|
|
|
func EmoteCommand() {
|
2023-07-11 03:46:47 +00:00
|
|
|
channelId := state.GetCurrentChannel()
|
|
|
|
if channelId == "" {
|
|
|
|
fmt.Print("<not in a channel>\n\r")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
prompt := ":emote> "
|
2023-07-27 02:27:04 +00:00
|
|
|
lib.MakePrompt(prompt, true, func(input string, interrupt bool) {
|
2023-07-11 03:46:47 +00:00
|
|
|
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")
|
2023-07-27 02:27:04 +00:00
|
|
|
client := state.GetClient()
|
2023-07-11 03:46:47 +00:00
|
|
|
|
2023-07-27 02:27:04 +00:00
|
|
|
snowflake, err := discord.ParseSnowflake(channelId)
|
2023-07-11 03:46:47 +00:00
|
|
|
if err != nil {
|
2023-07-27 02:27:04 +00:00
|
|
|
fmt.Print("<failed to parse channel id: ", err.Error(), ">\n\r")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = client.SendMessage(discord.ChannelID(snowflake), "*" + input + "*")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
fmt.Print("<failed to send message: ", err.Error(), ">\n\r")
|
2023-07-11 03:46:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: update afk state
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|