Rename package discordgolus to discordutil
RENAME
internal/discordgoplus/channel.go
internal/discordutil/channel.go
-package discordgoplus
+package discordutil
import (
"fmt"

RENAME
internal/discordgoplus/guilds.go
internal/discordutil/guilds.go
-package discordgoplus
+package discordutil
import (
"sort"

RENAME
internal/discordgoplus/users.go
internal/discordutil/users.go
-package discordgoplus
+package discordutil
import (
"crypto/rand"

MODIFY
internal/ui/channeltree.go
internal/ui/channeltree.go
@@ -4,7 +4,7 @@ import (
"sort"
"github.com/Bios-Marcel/cordless/internal/config"
- "github.com/Bios-Marcel/cordless/internal/discordgoplus"
+ "github.com/Bios-Marcel/cordless/internal/discordutil"
"github.com/Bios-Marcel/discordgo"
"github.com/Bios-Marcel/tview"
"github.com/gdamore/tcell"
@@ -119,7 +119,7 @@ func (channelTree *ChannelTree) LoadGuild(guildID string) error {
}
func createChannelNode(channel *discordgo.Channel) *tview.TreeNode {
- channelNode := tview.NewTreeNode(discordgoplus.GetChannelNameForTree(channel))
+ channelNode := tview.NewTreeNode(discordutil.GetChannelNameForTree(channel))
channelNode.SetReference(channel.ID)
return channelNode
}
@@ -140,7 +140,7 @@ func (channelTree *ChannelTree) AddOrUpdateChannel(channel *discordgo.Channel) {
}*/
updated = true
- node.SetText(discordgoplus.GetChannelNameForTree(channel))
+ node.SetText(discordutil.GetChannelNameForTree(channel))
return false
}
@@ -243,7 +243,7 @@ func (channelTree *ChannelTree) MarkChannelAsMentioned(channelID string) {
channelTree.channelStates[node] = channelMentioned
channel, stateError := channelTree.state.Channel(channelID)
if stateError == nil {
- node.SetText("(@You) " + discordgoplus.GetChannelNameForTree(channel))
+ node.SetText("(@You) " + discordutil.GetChannelNameForTree(channel))
}
node.SetColor(tcell.ColorRed)
@@ -271,7 +271,7 @@ func (channelTree *ChannelTree) MarkChannelAsLoaded(channelID string) {
channelTree.channelStates[node] = channelLoaded
channel, stateError := channelTree.state.Channel(channelID)
if stateError == nil {
- node.SetText(discordgoplus.GetChannelNameForTree(channel))
+ node.SetText(discordutil.GetChannelNameForTree(channel))
}
node.SetColor(tview.Styles.ContrastBackgroundColor)
return false

MODIFY
internal/ui/chatview.go
internal/ui/chatview.go
@@ -9,7 +9,7 @@ import (
linkshortener "github.com/Bios-Marcel/shortnotforlong"
- "github.com/Bios-Marcel/cordless/internal/discordgoplus"
+ "github.com/Bios-Marcel/cordless/internal/discordutil"
"github.com/Bios-Marcel/cordless/internal/times"
"github.com/gdamore/tcell"
@@ -331,12 +331,12 @@ func (chatView *ChatView) formatMessage(message *discordgo.Message) string {
if message.GuildID != "" {
member, cacheError := chatView.session.State.Member(message.GuildID, user.ID)
if cacheError == nil {
- userName = discordgoplus.GetMemberName(member)
+ userName = discordutil.GetMemberName(member)
}
}
if userName == "" {
- userName = discordgoplus.GetUserName(user)
+ userName = discordutil.GetUserName(user)
}
var color string
@@ -475,16 +475,16 @@ func (chatView *ChatView) formatMessage(message *discordgo.Message) string {
if message.GuildID != "" {
member, cacheError := chatView.session.State.Member(message.GuildID, message.Author.ID)
if cacheError == nil {
- messageAuthor = discordgoplus.GetMemberName(member)
+ messageAuthor = discordutil.GetMemberName(member)
}
}
if messageAuthor == "" {
- messageAuthor = discordgoplus.GetUserName(message.Author)
+ messageAuthor = discordutil.GetUserName(message.Author)
}
if config.GetConfig().UseRandomUserColors {
- messageAuthor = "[" + discordgoplus.GetUserColor(message.Author) + "]" + messageAuthor
+ messageAuthor = "[" + discordutil.GetUserColor(message.Author) + "]" + messageAuthor
} else {
messageAuthor = "[#44e544]" + messageAuthor
}

MODIFY
internal/ui/privatechats.go
internal/ui/privatechats.go
package ui
import (
- "github.com/Bios-Marcel/cordless/internal/discordgoplus"
+ "github.com/Bios-Marcel/cordless/internal/discordutil"
"github.com/gdamore/tcell"
"github.com/Bios-Marcel/cordless/internal/config"
@@ -83,7 +83,7 @@ func (privateList *PrivateChatList) AddOrUpdateChannel(channel *discordgo.Channe
for _, node := range privateList.chatsNode.GetChildren() {
referenceChannelID, ok := node.GetReference().(string)
if ok && referenceChannelID == channel.ID {
- node.SetText(discordgoplus.GetPrivateChannelName(channel))
+ node.SetText(discordutil.GetPrivateChannelName(channel))
return
}
}
@@ -112,7 +112,7 @@ func (privateList *PrivateChatList) addChannel(channel *discordgo.Channel) {
}
func createPrivateChannelNode(channel *discordgo.Channel) *tview.TreeNode {
- channelNode := tview.NewTreeNode(discordgoplus.GetPrivateChannelName(channel))
+ channelNode := tview.NewTreeNode(discordutil.GetPrivateChannelName(channel))
channelNode.SetReference(channel.ID)
return channelNode
}
@@ -126,7 +126,7 @@ func (privateList *PrivateChatList) AddOrUpdateFriend(user *discordgo.User) {
channel, stateError := privateList.state.Channel(refrenceChannelID)
if stateError == nil && channel.Type == discordgo.ChannelTypeDM {
if channel.Recipients[0].ID == user.ID {
- node.SetText(discordgoplus.GetUserName(user))
+ node.SetText(discordutil.GetUserName(user))
return
}
}
@@ -136,7 +136,7 @@ func (privateList *PrivateChatList) AddOrUpdateFriend(user *discordgo.User) {
for _, node := range privateList.friendsNode.GetChildren() {
referenceUserID, ok := node.GetReference().(string)
if ok && referenceUserID == user.ID {
- node.SetText(discordgoplus.GetUserName(user))
+ node.SetText(discordutil.GetUserName(user))
return
}
}
@@ -242,7 +242,7 @@ func (privateList *PrivateChatList) SetOnChannelSelect(handler func(node *tview.
func (privateList *PrivateChatList) Load() {
privateChannels := make([]*discordgo.Channel, len(privateList.state.PrivateChannels))
copy(privateChannels, privateList.state.PrivateChannels)
- discordgoplus.SortPrivateChannels(privateChannels)
+ discordutil.SortPrivateChannels(privateChannels)
for _, channel := range privateChannels {
privateList.addChannel(channel)

MODIFY
internal/ui/usertree.go
internal/ui/usertree.go
@@ -4,7 +4,7 @@ import (
"sort"
"github.com/Bios-Marcel/cordless/internal/config"
- "github.com/Bios-Marcel/cordless/internal/discordgoplus"
+ "github.com/Bios-Marcel/cordless/internal/discordutil"
"github.com/Bios-Marcel/discordgo"
"github.com/Bios-Marcel/tview"
"github.com/gdamore/tcell"
@@ -141,9 +141,9 @@ func (userTree *UserTree) loadGuildRoles(guildID string) ([]*discordgo.Role, err
// AddOrUpdateMember adds the passed member to the tree, unless it is
// already part of the tree, in that case the nodes name is updated.
func (userTree *UserTree) AddOrUpdateMember(member *discordgo.Member) {
- nameToUse := discordgoplus.GetMemberName(member)
+ nameToUse := discordutil.GetMemberName(member)
if config.GetConfig().UseRandomUserColors {
- nameToUse = "[" + discordgoplus.GetUserColor(member.User) + "]" + nameToUse
+ nameToUse = "[" + discordutil.GetUserColor(member.User) + "]" + nameToUse
}
userNode, contains := userTree.userNodes[member.User.ID]
@@ -155,7 +155,7 @@ func (userTree *UserTree) AddOrUpdateMember(member *discordgo.Member) {
userNode = tview.NewTreeNode(nameToUse)
userTree.userNodes[member.User.ID] = userNode
- discordgoplus.SortUserRoles(member.Roles, userTree.roles)
+ discordutil.SortUserRoles(member.Roles, userTree.roles)
for _, userRole := range member.Roles {
roleNode, exists := userTree.roleNodes[userRole]
@@ -171,9 +171,9 @@ func (userTree *UserTree) AddOrUpdateMember(member *discordgo.Member) {
// AddOrUpdateUser adds a user to the tree, unless the user already exists,
// in that case the users node gets updated.
func (userTree *UserTree) AddOrUpdateUser(user *discordgo.User) {
- nameToUse := discordgoplus.GetUserName(user)
+ nameToUse := discordutil.GetUserName(user)
if config.GetConfig().UseRandomUserColors {
- nameToUse = "[" + discordgoplus.GetUserColor(user) + "]" + nameToUse
+ nameToUse = "[" + discordutil.GetUserColor(user) + "]" + nameToUse
}
userNode, contains := userTree.userNodes[user.ID]

MODIFY
internal/ui/window.go
internal/ui/window.go
@@ -12,7 +12,7 @@ import (
"github.com/Bios-Marcel/cordless/internal/commands"
"github.com/Bios-Marcel/cordless/internal/config"
- "github.com/Bios-Marcel/cordless/internal/discordgoplus"
+ "github.com/Bios-Marcel/cordless/internal/discordutil"
"github.com/Bios-Marcel/cordless/internal/maths"
"github.com/Bios-Marcel/cordless/internal/scripting"
"github.com/Bios-Marcel/cordless/internal/scripting/js"
@@ -99,7 +99,7 @@ func NewWindow(doRestart chan bool, app *tview.Application, session *discordgo.S
return nil, err
}
- guilds, discordError := discordgoplus.LoadGuilds(window.session)
+ guilds, discordError := discordutil.LoadGuilds(window.session)
if discordError != nil {
return nil, discordError
}
@@ -143,7 +143,7 @@ func NewWindow(doRestart chan bool, app *tview.Application, session *discordgo.S
window.registerGuildMemberHandlers()
- discordgoplus.SortGuilds(window.session.State.Settings, guilds)
+ discordutil.SortGuilds(window.session.State.Settings, guilds)
for _, tempGuild := range guilds {
guild := tempGuild
@@ -1222,7 +1222,7 @@ func (window *Window) LoadChannel(channel *discordgo.Channel) error {
messages = channel.Messages
}
- discordgoplus.SortMessagesByTimestamp(messages)
+ discordutil.SortMessagesByTimestamp(messages)
window.chatView.SetMessages(messages)
window.chatView.ClearSelection()
@@ -1283,7 +1283,7 @@ func (window *Window) UpdateChatHeader(channel *discordgo.Channel) {
} else if channel.Type == discordgo.ChannelTypeDM {
window.chatView.SetTitle(channel.Recipients[0].Username)
} else {
- window.chatView.SetTitle(discordgoplus.GetPrivateChannelName(channel))
+ window.chatView.SetTitle(discordutil.GetPrivateChannelName(channel))
}
}
}

Rename package discordgolus to discordutil