large guild fixes
This commit is contained in:
parent
2d2ba1fd60
commit
7af5462d54
5 changed files with 47 additions and 9 deletions
|
@ -43,6 +43,10 @@ func ListGuildsCommand(session *discordgo.Session) {
|
|||
return
|
||||
}
|
||||
|
||||
if guild.Name == "" && guildWithCounts.Name != "" {
|
||||
guild.Name = guildWithCounts.Name
|
||||
}
|
||||
|
||||
guilds = append(guilds, GuildListing{
|
||||
Name: guild.Name,
|
||||
Members: guildWithCounts.ApproximateMemberCount,
|
||||
|
@ -66,11 +70,19 @@ func GetSortedChannels(session *discordgo.Session, guildId string, withCategorie
|
|||
if err != nil {
|
||||
return channels
|
||||
}
|
||||
guildChannels := guild.Channels
|
||||
if len(guildChannels) == 0 {
|
||||
c, err := session.GuildChannels(guildId)
|
||||
if err != nil {
|
||||
return channels
|
||||
}
|
||||
guildChannels = c
|
||||
}
|
||||
|
||||
if withCategories {
|
||||
categories := make(map[string][]*discordgo.Channel)
|
||||
|
||||
for _, channel := range guild.Channels {
|
||||
for _, channel := range guildChannels {
|
||||
if channel.Type != discordgo.ChannelTypeGuildText && channel.Type != discordgo.ChannelTypeGuildNews {
|
||||
continue
|
||||
}
|
||||
|
@ -117,7 +129,7 @@ func GetSortedChannels(session *discordgo.Session, guildId string, withCategorie
|
|||
categories[id] = categoryChannels
|
||||
}
|
||||
|
||||
keys := make([]string, 0, len(categories) - 1)
|
||||
keys := make([]string, 0)
|
||||
for id := range categories {
|
||||
if id == "0" {
|
||||
continue
|
||||
|
@ -143,7 +155,7 @@ func GetSortedChannels(session *discordgo.Session, guildId string, withCategorie
|
|||
}
|
||||
}
|
||||
} else {
|
||||
for _, channel := range guild.Channels {
|
||||
for _, channel := range guildChannels {
|
||||
if channel.Type != discordgo.ChannelTypeGuildText && channel.Type != discordgo.ChannelTypeGuildNews {
|
||||
continue
|
||||
}
|
||||
|
@ -239,7 +251,7 @@ func ListChannelsCommand(session *discordgo.Session) {
|
|||
created := "??-???-??"
|
||||
timestamp, err := discordgo.SnowflakeTimestamp(channel.ID)
|
||||
if err == nil {
|
||||
created = timestamp.Format("02-Jan-06")
|
||||
created = timestamp.UTC().Format("02-Jan-06")
|
||||
}
|
||||
|
||||
fmt.Printf(" %*s %s %s\n\r", longest, name, created, topic)
|
||||
|
@ -359,6 +371,9 @@ func ListUsersCommand(session *discordgo.Session) {
|
|||
index := 0
|
||||
for _, position := range positions {
|
||||
members := membersByPosition[position]
|
||||
if len(members) > 150 {
|
||||
continue
|
||||
}
|
||||
for _, member := range members {
|
||||
|
||||
statusColor := "reset"
|
||||
|
@ -431,10 +446,13 @@ func SwitchGuild(session *discordgo.Session, input string) {
|
|||
last := state.GetLastChannel(target)
|
||||
if last == "" {
|
||||
channels := GetSortedChannels(session, target, false, false)
|
||||
topChannel := channels[0]
|
||||
// NB: ????????????????
|
||||
if len(channels) > 0 {
|
||||
topChannel := channels[0]
|
||||
|
||||
state.SetCurrentChannel(topChannel.ID)
|
||||
state.SetLastChannel(target, topChannel.ID)
|
||||
state.SetCurrentChannel(topChannel.ID)
|
||||
state.SetLastChannel(target, topChannel.ID)
|
||||
}
|
||||
} else {
|
||||
state.SetCurrentChannel(last)
|
||||
}
|
||||
|
|
|
@ -76,6 +76,11 @@ func Setup() {
|
|||
Run: CrossPeekCommand,
|
||||
Description: "cross-guild peek",
|
||||
}
|
||||
|
||||
commandMap["+"] = Command{
|
||||
Run: TimeCommand,
|
||||
Description: "current time",
|
||||
}
|
||||
}
|
||||
|
||||
func GetCommand(key string) (Command, bool) {
|
||||
|
|
14
commands/time.go
Normal file
14
commands/time.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
func TimeCommand(session *discordgo.Session) {
|
||||
now := time.Now().UTC()
|
||||
|
||||
fmt.Printf("%s\n\r", now.Format("[Mon 02-Jan-06 15:04:05]"))
|
||||
}
|
|
@ -38,7 +38,7 @@ type MessageOptions struct {
|
|||
func FormatMessage(session *discordgo.Session, options MessageOptions) []string {
|
||||
lines := make([]string, 0)
|
||||
|
||||
timestamp := options.Timestamp.Format("[15:04:05]")
|
||||
timestamp := options.Timestamp.UTC().Format("[15:04:05]")
|
||||
|
||||
nameLength := utf8.RuneCountInString(options.Name) + 2
|
||||
stateNameLength := state.GetNameLength()
|
||||
|
|
3
main.go
3
main.go
|
@ -79,7 +79,8 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
//client.LogLevel = discordgo.LogDebug
|
||||
//client.LogLevel = -1
|
||||
client.LogLevel = discordgo.LogDebug
|
||||
|
||||
client.Identify.Intents = discordgo.IntentsAll
|
||||
|
||||
|
|
Loading…
Reference in a new issue