Fix small bugs, replace deprecated usages and sort imports
This commit is contained in:
parent
98dac29cb0
commit
3a350a9e4f
|
@ -2,10 +2,11 @@ package commands
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Bios-Marcel/cordless/config"
|
||||
"github.com/Bios-Marcel/cordless/ui/tviewutil"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/Bios-Marcel/cordless/config"
|
||||
"github.com/Bios-Marcel/cordless/ui/tviewutil"
|
||||
)
|
||||
|
||||
// Command represents a command that is executable by the user.
|
||||
|
|
|
@ -2,10 +2,10 @@ package commandimpls
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Bios-Marcel/cordless/commands"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/Bios-Marcel/cordless/commands"
|
||||
"github.com/Bios-Marcel/cordless/config"
|
||||
"github.com/Bios-Marcel/cordless/ui"
|
||||
"github.com/Bios-Marcel/cordless/ui/tviewutil"
|
||||
|
|
|
@ -3,14 +3,16 @@ package commandimpls
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
|
||||
"github.com/Bios-Marcel/discordgo"
|
||||
|
||||
"github.com/Bios-Marcel/cordless/config"
|
||||
"github.com/Bios-Marcel/cordless/ui"
|
||||
"github.com/Bios-Marcel/cordless/ui/tviewutil"
|
||||
"github.com/Bios-Marcel/cordless/util/files"
|
||||
"github.com/Bios-Marcel/discordgo"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
)
|
||||
|
||||
const fileSendDocumentation = `[::b]NAME
|
||||
|
@ -18,7 +20,7 @@ const fileSendDocumentation = `[::b]NAME
|
|||
|
||||
[::b]SYNOPSIS
|
||||
[::b]file-send <FILE_PATH>...
|
||||
|
||||
|
||||
[::b]DESCRIPTION
|
||||
The file-send command allows you to send multiple files to your current channel.
|
||||
|
||||
|
|
|
@ -2,11 +2,13 @@ package commandimpls
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Bios-Marcel/cordless/commands"
|
||||
"github.com/Bios-Marcel/discordemojimap"
|
||||
"github.com/Bios-Marcel/discordgo"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/Bios-Marcel/discordemojimap"
|
||||
"github.com/Bios-Marcel/discordgo"
|
||||
|
||||
"github.com/Bios-Marcel/cordless/commands"
|
||||
)
|
||||
|
||||
type NickSetCmd struct {
|
||||
|
|
|
@ -183,7 +183,7 @@ func (cmd *TFADisableCmd) Execute(writer io.Writer, parameters []string) {
|
|||
config.UpdateCurrentToken(cmd.session.Token)
|
||||
configError := config.PersistConfig()
|
||||
if configError != nil {
|
||||
commands.PrintError(writer, "Error updating access token in configuration. You might have to log in again.", disableError.Error())
|
||||
commands.PrintError(writer, "Error updating access token in configuration. You might have to log in again.", configError.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package commandimpls
|
|||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"github.com/Bios-Marcel/discordemojimap"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
@ -11,10 +10,13 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/Bios-Marcel/discordemojimap"
|
||||
|
||||
"github.com/Bios-Marcel/discordgo"
|
||||
|
||||
"github.com/Bios-Marcel/cordless/config"
|
||||
"github.com/Bios-Marcel/cordless/ui"
|
||||
"github.com/Bios-Marcel/cordless/ui/tviewutil"
|
||||
"github.com/Bios-Marcel/discordgo"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -2,8 +2,9 @@ package commandimpls
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Bios-Marcel/cordless/version"
|
||||
"io"
|
||||
|
||||
"github.com/Bios-Marcel/cordless/version"
|
||||
)
|
||||
|
||||
const versionDocumentation = `[::b]NAME
|
||||
|
|
|
@ -11,8 +11,6 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
//AppName is the name representing the application.
|
||||
AppName = "Cordless"
|
||||
//AppNameLowercase is the representative name, but lowercase.
|
||||
//It us used for filepaths and such.
|
||||
AppNameLowercase = "cordless"
|
||||
|
|
|
@ -69,9 +69,6 @@ func generateGuilds(start, amount int) []*discordgo.UserGuild {
|
|||
}
|
||||
|
||||
func TestLoadGuilds(t *testing.T) {
|
||||
type args struct {
|
||||
guildLoader GuildLoader
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
guildLoader GuildLoader
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package scripting
|
||||
|
||||
import (
|
||||
"github.com/Bios-Marcel/discordgo"
|
||||
"io"
|
||||
|
||||
"github.com/Bios-Marcel/discordgo"
|
||||
)
|
||||
|
||||
// Engine describes a type that is capable of handling events from the main
|
||||
|
|
|
@ -5,10 +5,11 @@ import (
|
|||
"os"
|
||||
"regexp"
|
||||
|
||||
"github.com/Bios-Marcel/cordless/config"
|
||||
"github.com/Bios-Marcel/cordless/ui/tviewutil"
|
||||
"github.com/Bios-Marcel/tview"
|
||||
"github.com/gdamore/tcell"
|
||||
|
||||
"github.com/Bios-Marcel/cordless/config"
|
||||
"github.com/Bios-Marcel/cordless/ui/tviewutil"
|
||||
)
|
||||
|
||||
func checkVT() bool {
|
||||
|
|
|
@ -208,7 +208,7 @@ func EventToString(event *tcell.EventKey) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
m := []string{}
|
||||
var m []string
|
||||
if event.Modifiers()&tcell.ModCtrl != 0 {
|
||||
m = append(m, "Ctrl")
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ func entryToEscapeSequence(table *ttyTable, entry chroma.StyleEntry) string {
|
|||
|
||||
func findClosest(table *ttyTable, seeking chroma.Colour) chroma.Colour {
|
||||
closestColour := chroma.Colour(0)
|
||||
closest := float64(math.MaxFloat64)
|
||||
closest := math.MaxFloat64
|
||||
for colour := range table.foreground {
|
||||
distance := colour.Distance(seeking)
|
||||
if distance < closest {
|
||||
|
|
|
@ -84,7 +84,7 @@ func TestAreDatesTheSameDay(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMarshalDuration(t *testing.T) {
|
||||
var duration Duration = Duration(6 * time.Second)
|
||||
duration := Duration(6 * time.Second)
|
||||
resultBytes, err := json.Marshal(duration)
|
||||
if err != nil {
|
||||
t.Errorf("error marshalling duration: %s", err)
|
||||
|
|
|
@ -6,9 +6,10 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/Bios-Marcel/cordless/config"
|
||||
"github.com/Bios-Marcel/tview"
|
||||
"github.com/gdamore/tcell"
|
||||
|
||||
"github.com/Bios-Marcel/cordless/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -196,7 +196,7 @@ func createChannelNode(channel *discordgo.Channel) *tview.TreeNode {
|
|||
// Adds a padlock prefix if the channel if not readable by the everyone group
|
||||
if config.Current.IndicateChannelAccessRestriction {
|
||||
for _, permission := range channel.PermissionOverwrites {
|
||||
if permission.Type == "role" && permission.ID == channel.GuildID && permission.Deny&discordgo.PermissionReadMessages == discordgo.PermissionReadMessages {
|
||||
if permission.Type == "role" && permission.ID == channel.GuildID && permission.Deny&discordgo.PermissionViewChannel == discordgo.PermissionViewChannel {
|
||||
prefixes += tviewutil.Escape("\U0001F512")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ func TestChannelTree(t *testing.T) {
|
|||
{
|
||||
ID: "R1",
|
||||
Type: "role",
|
||||
Deny: discordgo.PermissionReadMessages,
|
||||
Deny: discordgo.PermissionViewChannel,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ func TestChannelTree(t *testing.T) {
|
|||
r1 := &discordgo.Role{
|
||||
ID: "R1",
|
||||
Name: "Rollo",
|
||||
Permissions: discordgo.PermissionReadMessages,
|
||||
Permissions: discordgo.PermissionViewChannel,
|
||||
}
|
||||
state.RoleAdd("G1", r1)
|
||||
|
||||
|
|
|
@ -3,10 +3,11 @@ package ui
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/Bios-Marcel/discordgo"
|
||||
|
||||
"github.com/Bios-Marcel/cordless/config"
|
||||
_ "github.com/Bios-Marcel/cordless/syntax"
|
||||
"github.com/Bios-Marcel/cordless/ui/tviewutil"
|
||||
"github.com/Bios-Marcel/discordgo"
|
||||
)
|
||||
|
||||
func TestParseBoldAndUnderline(t *testing.T) {
|
||||
|
|
|
@ -4,12 +4,13 @@ import (
|
|||
"errors"
|
||||
"os"
|
||||
|
||||
"github.com/Bios-Marcel/cordless/ui/tviewutil"
|
||||
"github.com/Bios-Marcel/cordless/util/text"
|
||||
"github.com/Bios-Marcel/discordgo"
|
||||
"github.com/Bios-Marcel/tview"
|
||||
"github.com/atotto/clipboard"
|
||||
"github.com/gdamore/tcell"
|
||||
|
||||
"github.com/Bios-Marcel/cordless/ui/tviewutil"
|
||||
"github.com/Bios-Marcel/cordless/util/text"
|
||||
)
|
||||
|
||||
const splashText = `
|
||||
|
|
10
ui/window.go
10
ui/window.go
|
@ -712,7 +712,15 @@ func NewWindow(doRestart chan bool, app *tview.Application, session *discordgo.S
|
|||
if currentText == "" {
|
||||
go window.session.ChannelFileSend(targetChannel.ID, "img.png", dataChannel)
|
||||
} else {
|
||||
go window.session.ChannelFileSendWithMessage(targetChannel.ID, currentText, "img.png", dataChannel)
|
||||
messageData := &discordgo.MessageSend{
|
||||
Content: currentText,
|
||||
File: &discordgo.File{
|
||||
Name: "img.png",
|
||||
ContentType: "image/png",
|
||||
Reader: dataChannel,
|
||||
},
|
||||
}
|
||||
go window.session.ChannelMessageSendComplex(targetChannel.ID, messageData)
|
||||
window.messageInput.SetText("")
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -31,7 +31,7 @@ func ScoreAndSortRoles(searchTerm string, searchables []*discordgo.Role) []*disc
|
|||
|
||||
// Convert the results into an array.
|
||||
sortedItems := make([]*discordgo.Role, 0, len(scoredItems))
|
||||
for key, _ := range scoredItems {
|
||||
for key := range scoredItems {
|
||||
sortedItems = append(sortedItems, key)
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ func ScoreAndSortMembers(searchTerm string, searchables []*discordgo.Member) []*
|
|||
|
||||
// Convert the results into an array.
|
||||
sortedItems := make([]*discordgo.Member, 0, len(scoredItems))
|
||||
for key, _ := range scoredItems {
|
||||
for key := range scoredItems {
|
||||
sortedItems = append(sortedItems, key)
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ func ScoreAndSortUsers(searchTerm string, searchables []*discordgo.User) []*disc
|
|||
|
||||
// Convert the results into an array.
|
||||
sortedItems := make([]*discordgo.User, 0, len(scoredItems))
|
||||
for key, _ := range scoredItems {
|
||||
for key := range scoredItems {
|
||||
sortedItems = append(sortedItems, key)
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ func ScoreAndSortEmoji(searchTerm string, unicodeEmoji []string, customEmoji []*
|
|||
|
||||
// Convert the results into an array.
|
||||
sortedItems := make([]string, 0, len(scoredItems))
|
||||
for key, _ := range scoredItems {
|
||||
for key := range scoredItems {
|
||||
sortedItems = append(sortedItems, key)
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ func ScoreAndSortChannels(searchTerm string, searchables []*discordgo.Channel) [
|
|||
|
||||
// Convert the results into an array.
|
||||
sortedItems := make([]*discordgo.Channel, 0, len(scoredItems))
|
||||
for key, _ := range scoredItems {
|
||||
for key := range scoredItems {
|
||||
sortedItems = append(sortedItems, key)
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package text
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/mdp/qrterminal/v3"
|
||||
"rsc.io/qr"
|
||||
)
|
||||
|
|
|
@ -3,6 +3,7 @@ package version
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/google/go-github/v29/github"
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue