mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-28 02:23:37 +01:00
fix(lint): fixing more complex formatters problems.
This commit is contained in:
@@ -4,69 +4,10 @@ import (
|
||||
"fmt"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"sort"
|
||||
"strings"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
type Player struct {
|
||||
CharName string
|
||||
QuestID int
|
||||
}
|
||||
|
||||
func getPlayerSlice(s *Server) []Player {
|
||||
var p []Player
|
||||
var questIndex int
|
||||
|
||||
for _, channel := range s.Channels {
|
||||
for _, stage := range channel.stages {
|
||||
if len(stage.clients) == 0 {
|
||||
continue
|
||||
}
|
||||
questID := 0
|
||||
if stage.isQuest() {
|
||||
questIndex++
|
||||
questID = questIndex
|
||||
}
|
||||
for client := range stage.clients {
|
||||
p = append(p, Player{
|
||||
CharName: client.Name,
|
||||
QuestID: questID,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func getCharacterList(s *Server) string {
|
||||
questEmojis := []string{
|
||||
":person_in_lotus_position:",
|
||||
":white_circle:",
|
||||
":red_circle:",
|
||||
":blue_circle:",
|
||||
":brown_circle:",
|
||||
":green_circle:",
|
||||
":purple_circle:",
|
||||
":yellow_circle:",
|
||||
":orange_circle:",
|
||||
":black_circle:",
|
||||
}
|
||||
|
||||
playerSlice := getPlayerSlice(s)
|
||||
|
||||
sort.SliceStable(playerSlice, func(i, j int) bool {
|
||||
return playerSlice[i].QuestID < playerSlice[j].QuestID
|
||||
})
|
||||
|
||||
message := fmt.Sprintf("===== Online: %d =====\n", len(playerSlice))
|
||||
for _, player := range playerSlice {
|
||||
message += fmt.Sprintf("%s %s", questEmojis[player.QuestID], player.CharName)
|
||||
}
|
||||
|
||||
return message
|
||||
}
|
||||
|
||||
// onInteraction handles slash commands
|
||||
func (s *Server) onInteraction(ds *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||
switch i.Interaction.ApplicationCommandData().Name {
|
||||
|
||||
Reference in New Issue
Block a user