forked from Southclaws/cj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot_cmd_whois.go
61 lines (50 loc) · 1.31 KB
/
bot_cmd_whois.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
package main
import (
"github.com/bwmarrin/discordgo"
)
func commandWhois(cm CommandManager, args string, message discordgo.Message, contextual bool) (bool, bool, error) {
var (
verified bool
err error
count = 0
username string
link string
result string
)
if len(message.Mentions) == 0 {
return false, false, nil
}
for _, user := range message.Mentions {
if count == 5 {
break
}
count++
if user.ID == cm.App.config.BotID {
result += cm.App.locale.GetLangString("en", "CommandWhoisCJ") + " "
continue
}
verified, err = cm.App.IsUserVerified(user.ID)
if err != nil {
result += err.Error() + " "
continue
}
if !verified {
result += cm.App.locale.GetLangString("en", "CommandWhoisNotVerified", user.ID) + " "
} else {
username, err = cm.App.GetForumNameFromDiscordUser(user.ID)
if err != nil {
return false, false, err
}
link, err = cm.App.GetForumUserFromDiscordUser(user.ID)
if err != nil {
return false, false, err
}
result += cm.App.locale.GetLangString("en", "CommandWhoisProfile", user.ID, username, link) + " "
}
}
_, err = cm.App.discordClient.ChannelMessageSend(message.ChannelID, result)
if err != nil {
return false, false, err
}
return true, false, nil
}