This repository has been archived by the owner on Sep 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
msgLogging.go
67 lines (56 loc) · 1.99 KB
/
msgLogging.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
package main
import (
"fmt"
"github.com/bwmarrin/discordgo"
)
func init() {
newCommand("logging",
discordgo.PermissionAdministrator|discordgo.PermissionManageServer,
true, msgLogging).setHelp("Args: none\n\nToggles user presence logging.\n\nExample:\n`!owo logging`").add()
newCommand("logChannel",
discordgo.PermissionAdministrator|discordgo.PermissionManageServer,
true, msgLogChannel).setHelp("Args: [channelID,channel tag]\n\nSets the log channel to the given channel.\nAdmin only.\n\nExample:\n`!owo logChannel 312292616089894924`\n`!owo logChannel #bot-channel`").add()
}
func msgLogChannel(s *discordgo.Session, m *discordgo.MessageCreate, msglist []string) {
guild, err := guildDetails(m.ChannelID, "", s)
if err != nil {
s.ChannelMessageSend(m.ChannelID, "There was a problem setting the details :( Try again please~")
return
}
if len(msglist) < 2 {
return
}
var channelID string
channelIDMatch := channelRegex.FindStringSubmatch(msglist[1])
if len(channelIDMatch) != 2 {
s.ChannelMessageSend(m.ChannelID, "Not a valid channel!")
return
}
channelID = channelIDMatch[1]
var chanList []string
for _, channel := range guild.Channels {
chanList = append(chanList, channel.ID)
}
if !isIn(channelID, chanList) {
s.ChannelMessageSend(m.ChannelID, "That channel isn't in this server <:2BThink:333694872802426880>")
return
}
if guild, ok := sMap.server(guild.ID); ok && !guild.Kicked {
guild.LogChannel = channelID
saveServers()
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("Log channel changed to <#%s>", channelID))
}
return
}
func msgLogging(s *discordgo.Session, m *discordgo.MessageCreate, msglist []string) {
guild, err := guildDetails(m.ChannelID, "", s)
if err != nil {
s.ChannelMessageSend(m.ChannelID, "There was a problem toggling logging :( Try again please~")
return
}
if guild, ok := sMap.server(guild.ID); ok && !guild.Kicked {
guild.Log = !guild.Log
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("Logging %t", guild.Log))
saveServers()
}
}