43 lines
1.4 KiB
Go
43 lines
1.4 KiB
Go
|
package commands
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
|
||
|
"github.com/bwmarrin/discordgo"
|
||
|
|
||
|
"PermissionGacha/modules/starboard"
|
||
|
)
|
||
|
|
||
|
func handleStarCommand(s *discordgo.Session, args []string, m *discordgo.MessageCreate) error {
|
||
|
if len(args) == 1 {
|
||
|
s.ChannelMessageSend(m.ChannelID, "**STAR > **It doesn't seem like you've sent a valid message link!")
|
||
|
return nil
|
||
|
}
|
||
|
linkSplit := strings.SplitN(args[1], "/", 7)
|
||
|
if len(linkSplit) < 7 {
|
||
|
s.ChannelMessageSend(m.ChannelID, "**STAR > **It doesn't seem like you've sent a valid message link!")
|
||
|
return nil
|
||
|
}
|
||
|
if linkSplit[0] != "https:" && linkSplit[0] != "http:" {
|
||
|
s.ChannelMessageSend(m.ChannelID, "**STAR > **It doesn't seem like you've sent a valid message link!")
|
||
|
return nil
|
||
|
}
|
||
|
if linkSplit[2] != "discordapp.com" && !strings.HasSuffix(linkSplit[2], ".discordapp.com") {
|
||
|
s.ChannelMessageSend(m.ChannelID, "**STAR > **It doesn't seem like you've sent a valid message link!")
|
||
|
return nil
|
||
|
}
|
||
|
if linkSplit[3] != "channels" {
|
||
|
s.ChannelMessageSend(m.ChannelID, "**STAR > **It doesn't seem like you've sent a valid message link!")
|
||
|
return nil
|
||
|
}
|
||
|
if linkSplit[4] != m.GuildID {
|
||
|
s.ChannelMessageSend(m.ChannelID, "**STAR > **It doesn't seem like you've sent a valid message link!")
|
||
|
return nil
|
||
|
}
|
||
|
err := starboard.AddReact(s, linkSplit[5], linkSplit[6])
|
||
|
if err != nil {
|
||
|
s.ChannelMessageSend(m.ChannelID, "**STAR > **It doesn't seem like you've sent a valid message link!")
|
||
|
}
|
||
|
return nil
|
||
|
}
|