Add user activity
This commit is contained in:
13
config.go
13
config.go
@ -59,6 +59,7 @@ func saveConfig() {
|
||||
}
|
||||
|
||||
func adminInteraction(s *discordgo.Session, m string) {
|
||||
defer log.PanicSafe()
|
||||
admin, _ := s.GuildMember(config.GuildID, m)
|
||||
counter, ok := config.Stats[admin.User.ID]
|
||||
if !ok {
|
||||
@ -69,6 +70,18 @@ func adminInteraction(s *discordgo.Session, m string) {
|
||||
|
||||
}
|
||||
|
||||
func activeInteraction(s *discordgo.Session, m string) {
|
||||
defer log.PanicSafe()
|
||||
user, _ := s.GuildMember(config.GuildID, m)
|
||||
counter, ok := config.Stats[user.User.ID]
|
||||
if !ok {
|
||||
config.Activity[user.User.ID] = 1
|
||||
} else {
|
||||
config.Activity[user.User.ID] = counter + 1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func rebootBump() {
|
||||
time.Sleep(time.Until(config.BumpTime.Add(2 * time.Hour)))
|
||||
dg.ChannelMessageSend(config.AdminChannel, "!d bump is ready")
|
||||
|
||||
@ -29,12 +29,16 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
if m.ChannelID != config.AdminChannel {
|
||||
lastActiveChan = m.ChannelID
|
||||
lastActiveTime = time.Now()
|
||||
if len(m.Attachments) > 0 {
|
||||
activeInteraction(s, m.Author.ID)
|
||||
}
|
||||
}
|
||||
if strings.HasPrefix(m.Content, "!d bump") {
|
||||
if time.Since(config.BumpTime) < 2*time.Hour {
|
||||
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("Sorry, <@%+v> already claimed the bump. Better luck next time!", config.LastBumper))
|
||||
return
|
||||
}
|
||||
activeInteraction(s, m.Author.ID)
|
||||
config.LastBumper = m.Author.ID
|
||||
go bumpTimer(s)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user