|
|
|
@ -6,6 +6,7 @@ import (
@@ -6,6 +6,7 @@ import (
|
|
|
|
|
"io/ioutil" |
|
|
|
|
"os" |
|
|
|
|
"time" |
|
|
|
|
"strings" |
|
|
|
|
|
|
|
|
|
"github.com/bwmarrin/discordgo" |
|
|
|
|
) |
|
|
|
@ -14,12 +15,12 @@ func status(s *discordgo.Session) {
@@ -14,12 +15,12 @@ func status(s *discordgo.Session) {
|
|
|
|
|
defer log.PanicSafe() |
|
|
|
|
status := fmt.Sprintf("Uptime: %+v\n", time.Since(startupTime)) |
|
|
|
|
status += fmt.Sprintf("Last bump: %+v\n", time.Since(config.BumpTime)) |
|
|
|
|
status += fmt.Sprintf("Last bumper: <@%+v>\n", userFromID(s, config.LastBumper).Username) |
|
|
|
|
status += fmt.Sprintf("Last bumper: <@%+v>\n", userFromID(config.LastBumper).Username) |
|
|
|
|
status += fmt.Sprintf("Bump needed: %+v\n", bump) |
|
|
|
|
if len(config.Unverified) > 0 { |
|
|
|
|
status += "Unverified users:\n```" |
|
|
|
|
for k, v := range config.Unverified { |
|
|
|
|
uvUser := userFromID(s, k) |
|
|
|
|
uvUser := userFromID(k) |
|
|
|
|
status += fmt.Sprintf("\n%+v will be removed in %+v", uvUser.Username, time.Until(v.Add(1*time.Hour))) |
|
|
|
|
} |
|
|
|
|
status += "```" |
|
|
|
@ -39,7 +40,7 @@ func status(s *discordgo.Session) {
@@ -39,7 +40,7 @@ func status(s *discordgo.Session) {
|
|
|
|
|
if len(config.Probations) > 0 { |
|
|
|
|
status += "\nThe following users are on probation: \n```" |
|
|
|
|
for uid, join := range config.Probations { |
|
|
|
|
probationUser := userFromID(s, uid) |
|
|
|
|
probationUser := userFromID(uid) |
|
|
|
|
status += fmt.Sprintf("%+v for another %+v\n", probationUser.Username, time.Until(join.Add(2*time.Hour))) |
|
|
|
|
} |
|
|
|
|
status += "```" |
|
|
|
@ -139,8 +140,8 @@ func (v Verification) prettyPrint() string {
@@ -139,8 +140,8 @@ func (v Verification) prettyPrint() string {
|
|
|
|
|
return ret |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func userFromID(s *discordgo.Session, i string) discordgo.User { |
|
|
|
|
u, err := s.GuildMember(config.GuildID, i) |
|
|
|
|
func userFromID(i string) discordgo.User { |
|
|
|
|
u, err := dg.GuildMember(config.GuildID, i) |
|
|
|
|
if err != nil { |
|
|
|
|
log.LogErrorType(err) |
|
|
|
|
return discordgo.User{} |
|
|
|
@ -148,6 +149,23 @@ func userFromID(s *discordgo.Session, i string) discordgo.User {
@@ -148,6 +149,23 @@ func userFromID(s *discordgo.Session, i string) discordgo.User {
|
|
|
|
|
return *u.User |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func idFromUsername(username string) string { |
|
|
|
|
userID := "" |
|
|
|
|
g, err := dg.GuildMembers(config.GuildID, "", 1000) |
|
|
|
|
log.LogInfo("reqPass guild is %+v.", config.GuildID) |
|
|
|
|
if err == nil { |
|
|
|
|
for _, m := range g { |
|
|
|
|
if strings.ToUpper(m.Nick) == strings.ToUpper(username) { |
|
|
|
|
userID = m.User.ID |
|
|
|
|
log.LogInfo("User ID found for %+v as %+v", username, userID) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
log.LogError("Unable to find user ID for %+v", username) |
|
|
|
|
} |
|
|
|
|
return userID |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func adminInteraction(s *discordgo.Session, m string) { |
|
|
|
|
admin, _ := s.GuildMember(config.GuildID, m) |
|
|
|
|
counter, ok := config.Stats[admin.User.ID] |
|
|
|
|