-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.go
111 lines (100 loc) · 3.79 KB
/
events.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package main
import (
"fmt"
"log"
"regexp"
"strings"
"time"
"github.com/bwmarrin/discordgo"
)
var isTimerActive bool
func messageReactionAdd(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
if m.Emoji.ID != "1117969363627159622" {
return
}
message, err := s.ChannelMessage(m.ChannelID, m.MessageID)
if err != nil {
log.Println("Error retrieving message for reaction checking!")
return
}
if message.Author.ID != s.State.User.ID {
return
}
if !strings.Contains(message.Content, "Remember to grab your") {
return
}
regex := regexp.MustCompile("<@&(\\d+)>")
roleID := regex.FindStringSubmatch(message.Content)[1]
err = s.GuildMemberRoleRemove(guildID, m.UserID, roleID)
if err != nil {
log.Printf("Error removing timed role (ID: %s) from user %s\n", roleID, m.Member.User.Username)
return
}
infoLog.Printf("Successfully removed timed role (ID: %s) from user %s\n", roleID, m.Member.User.Username)
}
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
if m.Author.ID == s.State.User.ID {
return
}
if m.ChannelID == dropsChannelID && m.Author.ID == "1287938268423524352" && !isTimerActive {
isTimerActive = true
time.AfterFunc(10*time.Minute, func() {
replyStr := fmt.Sprintf("Hey <@&%s>! Check out this ^ drop/giveaway.", dropsRoleID)
ReplyToMsg(s, m.Message, replyStr)
isTimerActive = false
})
return
}
if m.Author.Bot {
return
}
if m.Member == nil {
// Ignore messages not coming from a guild
return
}
msg := strings.ToLower(m.Content)
/////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////// Check for discord invites /////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
if !IsStaff(m.Member) &&
(strings.Contains(msg, "discord.gg/") || strings.Contains(msg, "discord.com/invite/")) {
s.ChannelMessageDelete(m.ChannelID, m.ID)
return
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////// Check for proof-of-completion channel misuse //////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
if m.ChannelID == proofChannelID && !IsStaff(m.Member) && !strings.Contains(msg, "manual check") {
if (strings.Contains(msg, "mcc") && !strings.Contains(msg, "master")) ||
strings.Contains(msg, "chief collection") ||
strings.Contains(msg, "china") || strings.Contains(msg, "cn") ||
strings.Contains(msg, "infinite") ||
strings.Contains(msg, "legacy") ||
strings.Contains(msg, "modern") ||
strings.Contains(msg, "halo completionist") ||
strings.Contains(msg, "hc") {
str := fmt.Sprintf("<@%s> You can obtain that role **only** by using me in <#%s>! Use /rolecheck in there to begin.", m.Author.ID, botChannelID)
s.ChannelMessageSend(proofChannelID, str)
s.ChannelMessageDelete(proofChannelID, m.ID)
return
} else {
saidAcceptedWords := func(msg string) bool {
return strings.Contains(msg, "franchise") ||
strings.Contains(msg, "lasochist") ||
strings.Contains(msg, "mcc master") ||
strings.Contains(msg, "ice") ||
strings.Contains(msg, "fire") ||
strings.Contains(msg, "jacker") ||
strings.Contains(msg, "jackal")
}
for _, attach := range m.Attachments {
if attach != nil && attach.Height != 0 && !saidAcceptedWords(msg) { // Posted image but didn't say an acceptable proof role or keyword
str := fmt.Sprintf("<@%s> Please state the exact name of the vanity role you wish to obtain in the same message as the image!", m.Author.ID)
s.ChannelMessageSend(proofChannelID, str)
s.ChannelMessageDelete(proofChannelID, m.ID)
return
}
}
}
}
}