|
|
|
@ -4,6 +4,7 @@ import (
|
|
|
|
|
"crypto/rand"
|
|
|
|
|
"fmt"
|
|
|
|
|
"math"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
|
|
@ -30,6 +31,9 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|
|
|
|
if m.Content == "pgqprestige" {
|
|
|
|
|
handlePrestigeRequest(s, m)
|
|
|
|
|
}
|
|
|
|
|
if strings.HasPrefix(m.Content, "pgqstar ") {
|
|
|
|
|
handleStarRequest(s, m)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func handleXPRequest(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|
|
|
@ -126,3 +130,36 @@ func checkPrestigeReact(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func handleStarRequest(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|
|
|
|
commandSplit := strings.SplitN(m.Content, " ", 2)
|
|
|
|
|
if len(commandSplit) == 1 {
|
|
|
|
|
s.ChannelMessageSend(m.ChannelID, "**STAR > **It doesn't seem like you've sent a valid message link!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
linkSplit := strings.SplitN(m.Content, "/", 7)
|
|
|
|
|
if len(linkSplit) < 7 {
|
|
|
|
|
s.ChannelMessageSend(m.ChannelID, "**STAR > **It doesn't seem like you've sent a valid message link!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
if linkSplit[3] != "channels" {
|
|
|
|
|
s.ChannelMessageSend(m.ChannelID, "**STAR > **It doesn't seem like you've sent a valid message link!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if linkSplit[4] != m.GuildID {
|
|
|
|
|
s.ChannelMessageSend(m.ChannelID, "**STAR > **It doesn't seem like you've sent a valid message link!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
err := s.MessageReactionAdd(linkSplit[5], linkSplit[6], starEmoji)
|
|
|
|
|
if err != nil {
|
|
|
|
|
s.ChannelMessageSend(m.ChannelID, "**STAR > **It doesn't seem like you've sent a valid message link!")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|