-
Notifications
You must be signed in to change notification settings - Fork 21
/
emoji.go
41 lines (33 loc) · 1.01 KB
/
emoji.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
package main
import (
"github.com/bwmarrin/discordgo"
"log"
emoji "github.com/tmdvs/Go-Emoji-Utils"
"regexp"
"strings"
"unicode"
)
var discordEmote = regexp.MustCompile(`<a?:[a-zA-Z0-9_]+:\d+>`)
func emojiMsg(m *discordgo.Message){
if m.ChannelID != "808248247520985130" {
return
}
stripped := strings.Map(func(r rune) rune {
if unicode.IsSpace(r) {
return -1
}
return r
}, discordEmote.ReplaceAllString(emoji.RemoveAll(m.Content), ""))
log.Println("Original message:", m.Content)
log.Println("Stripped:", stripped)
if stripped != "" {
err := discord.GuildMemberDeleteWithReason(m.GuildID, m.Author.ID, "Sending a non emoji message in the emoji-only channel")
if err != nil {
return
}
resp(m.ChannelID, "User <@" + m.Author.ID + "> was kicked for sending https://discord.com/channels/208753003996512258/808248247520985130/"+m.ID+" because it has non emoji characters: `" + stripped + "`")
}
}
func onMessageEdited(session *discordgo.Session, m *discordgo.MessageUpdate) {
emojiMsg(m.Message)
}