// Handles bot operator messages, should be refactored (lmao)
Handles bot operator messages, should be refactored (lmao)
// Handles bot operator messages should be refactored ( lmao )
func handleBotControlMessages(s *discordgo.Session, m *discordgo.MessageCreate, parts []string, g *discordgo.Guild) {
    ourShard := shardContains(g.ID)
    if len(parts) >= 3 && scontains(parts[len(parts)-2], "die") {
        shard := parts[len(parts)-1]
        if len(SHARDS) == 0 || scontains(shard, SHARDS...) {
            log.Info("Got DIE request, exiting...")
            s.ChannelMessageSend(m.ChannelID, ":ok_hand: goodbye cruel world")
            os.Exit(0)
        }
    } else if scontains(parts[len(parts)-1], "info") && ourShard {
        runtime.ReadMemStats(&mem)
        t1 := time.Now()
        d := t1.Sub(t0)
        minutesPassed := d.Minutes()
        var truncate int = int(minutesPassed) % 60
        var hoursPassed int = int(minutesPassed / 60)
        w := &tabwriter.Writer{}
        buf := &bytes.Buffer{}
        w.Init(buf, 0, 4, 0, ' ', 0)
        fmt.Fprintf(w, "```\n")
        fmt.Fprintf(w, "Discordgo: \t%s\n", discordgo.VERSION)
        fmt.Fprintf(w, "Go: \t%s\n", runtime.Version())
        fmt.Fprintf(w, "maymay-bot ver.: \t%s\n", VERSION_RELEASE)
        fmt.Fprintf(w, "Time Up: \t%v hrs. %v min.\n", hoursPassed, truncate)
        fmt.Fprintf(w, "Memory: \t%d / %d (%d total)\n", mem.Alloc, mem.Sys, mem.TotalAlloc)
        fmt.Fprintf(w, "Calls: \t%d\n", COUNT)
        fmt.Fprintf(w, "Servers: \t%d\n", len(discord.State.Ready.Guilds))
        fmt.Fprintf(w, "```\n")
        w.Flush()
        s.ChannelMessageSend(m.ChannelID, buf.String())
    } else if scontains(parts[len(parts)-1], "where") && ourShard {
        s.ChannelMessageSend(m.ChannelID,
                             fmt.Sprintf("its a me, shard %v", string(g.ID[len(g.ID)-5])))
    }else if scontains(parts[len(parts)-1], "killbot") && ourShard {
        s.ChannelMessageSend(m.ChannelID,":ok_hand: goodbye cruel world")
        os.Exit(0)
    }
    return
}
func handleBotControlMessages ( s * discordgo . Session , m * discordgo . MessageCreate , parts [ ] string , g * discordgo . Guild ) { ourShard := shardContains ( g . ID ) if len ( parts ) >= 3 && scontains ( parts [ len ( parts ) - 2 ] , " " ) { shard := parts [ len ( parts ) - 1 ] if len ( SHARDS ) == 0 || scontains ( shard , SHARDS ... ) { log . Info ( " " ) s . ChannelMessageSend ( m . ChannelID , " " ) os . Exit ( 0 ) } } else if scontains ( parts [ len ( parts ) - 1 ] , " " ) && ourShard { runtime . ReadMemStats ( & mem ) t1 := time . Now ( ) d := t1 . Sub ( t0 ) minutesPassed := d . Minutes ( ) var truncate int = int ( minutesPassed ) % 60 var hoursPassed int = int ( minutesPassed / 60 ) w := & tabwriter . Writer { } buf := & bytes . Buffer { } w . Init ( buf , 0 , 4 , 0 , ' ' , 0 ) fmt . Fprintf ( w , " \n " ) fmt . Fprintf ( w , " \t \n " , discordgo . VERSION ) fmt . Fprintf ( w , " \t \n " , runtime . Version ( ) ) fmt . Fprintf ( w , " \t \n " , VERSION_RELEASE ) fmt . Fprintf ( w , " \t \n " , hoursPassed , truncate ) fmt . Fprintf ( w , " \t \n " , mem . Alloc , mem . Sys , mem . TotalAlloc ) fmt . Fprintf ( w , " \t \n " , COUNT ) fmt . Fprintf ( w , " \t \n " , len ( discord . State . Ready . Guilds ) ) fmt . Fprintf ( w , " \n " ) w . Flush ( ) s . ChannelMessageSend ( m . ChannelID , buf . String ( ) ) } else if scontains ( parts [ len ( parts ) - 1 ] , " " ) && ourShard { s . ChannelMessageSend ( m . ChannelID , fmt . Sprintf ( " " , string ( g . ID [ len ( g . ID ) - 5 ] ) ) ) } else if scontains ( parts [ len ( parts ) - 1 ] , " " ) && ourShard { s . ChannelMessageSend ( m . ChannelID , " " ) os . Exit ( 0 ) } return }
Handles bot operator messages, should be refactored (lmao)
Handles bot operator messages should be refactored ( lmao )