-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathmocker.go
81 lines (70 loc) · 1.87 KB
/
mocker.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
package main
import (
"fmt"
"log"
"time"
"github.com/bwmarrin/discordgo"
)
func canDMBot(userId string) bool {
member, err := GetMember(userId)
if err != nil || member == nil {
return false
}
return !includes(member.Roles, muteRoles[help])
}
// inform when someone DMs the bot because the messages are humorous
func onMessageSent2(session *discordgo.Session, m *discordgo.MessageCreate) {
msg := m.Message
if msg == nil || msg.Author == nil || msg.Type != discordgo.MessageTypeDefault {
return // wtf
}
author := msg.Author.ID
// Don't talk to oneself
if author == myselfID {
return
}
if msg.GuildID != "" {
return // DMs only!
}
if !canDMBot(author) {
return
}
if match := prefixPattern.FindString(msg.Content); match != "" {
return // this is a command
}
embed := &discordgo.MessageEmbed{
Author: &discordgo.MessageEmbedAuthor{},
Color: prettyembedcolor,
Description: "",
Fields: []*discordgo.MessageEmbedField{
{
Name: ":rotating_light: :wheelchair: I have received a DM :wheelchair: :rotating_light:",
Value: msg.Content,
},
},
Footer: &discordgo.MessageEmbedFooter{
Text: "from @" + msg.Author.Username + "#" + msg.Author.Discriminator,
},
}
_, err := session.ChannelMessageSendEmbed(impactBotLog, embed)
if err != nil {
log.Println(err)
}
go func() {
time.Sleep(1 * time.Second)
ch, err := discord.UserChannelCreate(author)
if err != nil {
log.Println(err)
return
}
err = discord.ChannelTyping(ch.ID)
if err != nil {
log.Println(err)
}
time.Sleep(2 * time.Second)
_, err = discord.ChannelMessageSend(ch.ID, fmt.Sprintf("Hey, do you need some help? Checkout <#%s>!\n\nYour Discord User ID is `"+author+"`\n\n**Go to https://impactclient.net/discord.html?discord="+author+"** to verify your account and be able to talk on the server.", help))
if err != nil {
log.Println(err)
}
}()
}