Switch to for-range loops for cleaner syntax
This commit is contained in:
parent
dcb639a45f
commit
642e156dc8
2 changed files with 5 additions and 8 deletions
|
|
@ -112,7 +112,7 @@ func onGuildCreate(guild *gateway.GuildCreateEvent) {
|
|||
|
||||
func onReady(ready *gateway.ReadyEvent) {
|
||||
guilds = ready.Guilds
|
||||
for i := 0; i < len(guilds); i++ {
|
||||
for i := range guilds {
|
||||
guildsDropDown.AddOption(guilds[i].Name, nil)
|
||||
}
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ func onGuildsDropDownSelected(text string, _ int) {
|
|||
messageInputField = nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(guilds); i++ {
|
||||
for i := range guilds {
|
||||
guild := guilds[i]
|
||||
if guild.Name == text {
|
||||
currentGuild = guild
|
||||
|
|
@ -142,7 +142,7 @@ func onGuildsDropDownSelected(text string, _ int) {
|
|||
}
|
||||
}
|
||||
|
||||
for i := 0; i < len(currentGuild.Channels); i++ {
|
||||
for i := range currentGuild.Channels {
|
||||
channel := currentGuild.Channels[i]
|
||||
channelsList.AddItem(channel.Name, "", 0, nil)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,11 +30,8 @@ func WriteMessage(messagesTextView *tview.TextView, message discord.Message) {
|
|||
}
|
||||
|
||||
attachments := message.Attachments
|
||||
attachmentsLen := len(attachments)
|
||||
if attachmentsLen > 0 {
|
||||
for i := 0; i < attachmentsLen; i++ {
|
||||
content.WriteString("\n" + attachments[i].URL)
|
||||
}
|
||||
for i := range attachments {
|
||||
content.WriteString("\n" + attachments[i].URL)
|
||||
}
|
||||
|
||||
fmt.Fprintln(messagesTextView, content.String())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue