Sfoglia il codice sorgente

Switch to astatine

ayntgl 4 anni fa
parent
commit
e4d9332eff
10 ha cambiato i file con 76 aggiunte e 124 eliminazioni
  1. 0 58
      discord/login.go
  2. 4 4
      discord/util.go
  3. 4 4
      go.mod
  4. 18 11
      go.sum
  5. 16 9
      main.go
  6. 10 14
      ui/app.go
  7. 13 13
      ui/builder.go
  8. 2 2
      ui/channels.go
  9. 4 4
      ui/guilds.go
  10. 5 5
      ui/messages.go

+ 0 - 58
discord/login.go

@@ -1,58 +0,0 @@
-package discord
-
-import (
-	"encoding/json"
-
-	"github.com/ayntgl/discordgo"
-)
-
-type LoginResponse struct {
-	Ticket string `json:"ticket"`
-	Token  string `json:"token"`
-	MFA    bool   `json:"mfa"`
-	SMS    bool   `json:"sms"`
-}
-
-func Login(s *discordgo.Session, email string, password string) (*LoginResponse, error) {
-	data := struct {
-		Email    string `json:"email"`
-		Password string `json:"password"`
-	}{email, password}
-	resp, err := s.RequestWithBucketID(
-		"POST",
-		discordgo.EndpointLogin,
-		data,
-		discordgo.EndpointLogin,
-	)
-	if err != nil {
-		return nil, err
-	}
-
-	var lr LoginResponse
-	err = json.Unmarshal(resp, &lr)
-	if err != nil {
-		return nil, err
-	}
-
-	return &lr, nil
-}
-
-func TOTP(s *discordgo.Session, code string, ticket string) (*LoginResponse, error) {
-	data := struct {
-		Code   string `json:"code"`
-		Ticket string `json:"ticket"`
-	}{code, ticket}
-	e := discordgo.EndpointAuth + "mfa/totp"
-	resp, err := s.RequestWithBucketID("POST", e, data, e)
-	if err != nil {
-		return nil, err
-	}
-
-	var lr LoginResponse
-	err = json.Unmarshal(resp, &lr)
-	if err != nil {
-		return nil, err
-	}
-
-	return &lr, nil
-}

+ 4 - 4
discord/util.go

@@ -3,10 +3,10 @@ package discord
 import (
 	"strings"
 
-	"github.com/ayntgl/discordgo"
+	"github.com/ayntgl/astatine"
 )
 
-func ChannelToString(c *discordgo.Channel) string {
+func ChannelToString(c *astatine.Channel) string {
 	var repr string
 	if c.Name != "" {
 		repr = "#" + c.Name
@@ -25,7 +25,7 @@ func ChannelToString(c *discordgo.Channel) string {
 	return repr
 }
 
-func FindMessageByID(ms []*discordgo.Message, mID string) (int, *discordgo.Message) {
+func FindMessageByID(ms []*astatine.Message, mID string) (int, *astatine.Message) {
 	for i, m := range ms {
 		if m.ID == mID {
 			return i, m
@@ -35,7 +35,7 @@ func FindMessageByID(ms []*discordgo.Message, mID string) (int, *discordgo.Messa
 	return -1, nil
 }
 
-func HasPermission(s *discordgo.State, cID string, p int64) bool {
+func HasPermission(s *astatine.State, cID string, p int64) bool {
 	perm, err := s.UserChannelPermissions(s.User.ID, cID)
 	if err != nil {
 		return false

+ 4 - 4
go.mod

@@ -5,11 +5,11 @@ go 1.18
 require (
 	github.com/BurntSushi/toml v1.0.0
 	github.com/atotto/clipboard v0.1.4
-	github.com/ayntgl/discordgo v0.23.3-0.20220124081725-decdb6a611b6
-	github.com/gdamore/tcell/v2 v2.4.1-0.20210905002822-f057f0a857a1
+	github.com/ayntgl/astatine v0.24.1-0.20220323171957-44de48cba9b9
+	github.com/gdamore/tcell/v2 v2.4.1-0.20220313203054-2a1a1b586447
 	github.com/rivo/tview v0.0.0-20220307222120-9994674d60a8
 	github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
-	github.com/zalando/go-keyring v0.2.0
+	github.com/zalando/go-keyring v0.2.1
 )
 
 require (
@@ -21,7 +21,7 @@ require (
 	github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
 	github.com/mattn/go-runewidth v0.0.13 // indirect
 	github.com/rivo/uniseg v0.2.0 // indirect
-	golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect
+	golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064 // indirect
 	golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect
 	golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
 	golang.org/x/text v0.3.7 // indirect

+ 18 - 11
go.sum

@@ -4,26 +4,28 @@ github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVK
 github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30=
 github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
 github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
-github.com/ayntgl/discordgo v0.23.3-0.20220124081725-decdb6a611b6 h1:NCuCGPk2FeVPqYbWBfYxR0IHH/rx8hjPiv85OiqwqVQ=
-github.com/ayntgl/discordgo v0.23.3-0.20220124081725-decdb6a611b6/go.mod h1:+adn4Eyw2HPVkt6ehSK1uWzB3N+a8LjuMxKw+1mDOh4=
+github.com/ayntgl/astatine v0.24.1-0.20220323171957-44de48cba9b9 h1:7noMugVd2FGlZcq3pawMZ0H+RZu++AFPVPPWFA370v4=
+github.com/ayntgl/astatine v0.24.1-0.20220323171957-44de48cba9b9/go.mod h1:A54lIYhmYBAYhUaiR90Ahlw+oSi5gN+70PNvQ+6xjMY=
 github.com/danieljoos/wincred v1.1.0/go.mod h1:XYlo+eRTsVA9aHGp7NGjFkPla4m+DCL7hqDjlFjiygg=
 github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0=
 github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0=
+github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
 github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
-github.com/gdamore/tcell/v2 v2.4.1-0.20210905002822-f057f0a857a1 h1:QqwPZCwh/k1uYqq6uXSb9TRDhTkfQbO80v8zhnIe5zM=
 github.com/gdamore/tcell/v2 v2.4.1-0.20210905002822-f057f0a857a1/go.mod h1:Az6Jt+M5idSED2YPGtwnfJV0kXohgdCBPmHGSYc1r04=
+github.com/gdamore/tcell/v2 v2.4.1-0.20220313203054-2a1a1b586447 h1:4idf9699cuWAc7ZIB+2RzuDWU30oRkB0X/FZTUlWOVY=
+github.com/gdamore/tcell/v2 v2.4.1-0.20220313203054-2a1a1b586447/go.mod h1:I8YJFI9gzgl4dHi9UlRDZosCW+jYkDA37AXmXvL51w4=
 github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
 github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
 github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
-github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
 github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
 github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
 github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
 github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
 github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
 github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/rivo/tview v0.0.0-20220307222120-9994674d60a8 h1:xe+mmCnDN82KhC010l3NfYlA8ZbOuzbXAzSYBa6wbMc=
 github.com/rivo/tview v0.0.0-20220307222120-9994674d60a8/go.mod h1:WIfMkQNY+oq/mWwtsjOYHIZBuwthioY2srOmljJkTnk=
@@ -31,18 +33,22 @@ github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
 github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
 github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 h1:JIAuq3EEf9cgbU6AtGPK4CTG3Zf6CKMNqf0MHTggAUA=
 github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog=
+github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
+github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/zalando/go-keyring v0.2.0 h1:IZOFhp3Gw5WeaGTVpKtKD2o/s+BeeqQkKUhtMDTQ190=
-github.com/zalando/go-keyring v0.2.0/go.mod h1:cu3uCHLkG4H4ali7PdTkEWoq2p07YHHoI+oi16YT5x8=
-golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
-golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd h1:XcWmESyNjXJMLahc3mqVQJcgSTDxFxhETVlfk9uGc38=
-golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
-golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+github.com/zalando/go-keyring v0.2.1 h1:MBRN/Z8H4U5wEKXiD67YbDAr5cj/DOStmSga70/2qKc=
+github.com/zalando/go-keyring v0.2.1/go.mod h1:g63M2PPn0w5vjmEbwAX3ib5I+41zdm4esSETOn9Y6Dw=
+golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064 h1:S25/rfnfsMVgORT4/J61MJ7rdyseOZOyvLIrZEZ7s6s=
+golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
+golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
 golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 h1:OH54vjqzRWmbJ62fjuhxy7AxFFgoHN0/DPc/UrL8cAs=
 golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
@@ -51,11 +57,12 @@ golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9sn
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
 golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

+ 16 - 9
main.go

@@ -3,8 +3,8 @@ package main
 import (
 	"flag"
 
+	"github.com/ayntgl/astatine"
 	"github.com/ayntgl/discordo/config"
-	"github.com/ayntgl/discordo/discord"
 	"github.com/ayntgl/discordo/ui"
 	"github.com/gdamore/tcell/v2"
 	"github.com/rivo/tview"
@@ -32,7 +32,8 @@ func main() {
 
 	app := ui.NewApp(c)
 	if token != "" {
-		err := app.Connect(token)
+		app.Session = astatine.New(token)
+		err := app.Connect()
 		if err != nil {
 			panic(err)
 		}
@@ -40,6 +41,8 @@ func main() {
 		app.DrawMainFlex()
 		app.SetFocus(app.GuildsList)
 	} else {
+		app.Session = astatine.New(token)
+
 		loginForm := ui.NewLoginForm(false)
 		loginForm.AddButton("Login", func() {
 			email := loginForm.GetFormItem(0).(*tview.InputField).GetText()
@@ -49,13 +52,15 @@ func main() {
 			}
 
 			// Login using the email and password
-			lr, err := discord.Login(app.Session, email, password)
+			lr, err := app.Session.Login(email, password)
 			if err != nil {
 				panic(err)
 			}
 
-			if lr.Token != "" && !lr.MFA {
-				err = app.Connect(lr.Token)
+			if lr.Token != "" && !lr.Mfa {
+				app.Session.Token = lr.Token
+				app.Session.Identify.Token = lr.Token
+				err = app.Connect()
 				if err != nil {
 					panic(err)
 				}
@@ -68,17 +73,19 @@ func main() {
 				// The account has MFA enabled, reattempt login with MFA code and ticket.
 				mfaLoginForm := ui.NewLoginForm(true)
 				mfaLoginForm.AddButton("Login", func() {
-					mfaCode := loginForm.GetFormItem(0).(*tview.InputField).GetText()
-					if mfaCode == "" {
+					code := loginForm.GetFormItem(0).(*tview.InputField).GetText()
+					if code == "" {
 						return
 					}
 
-					lr, err = discord.TOTP(app.Session, mfaCode, lr.Ticket)
+					lr, err = app.Session.Totp(code, lr.Ticket)
 					if err != nil {
 						panic(err)
 					}
 
-					err = app.Connect(lr.Token)
+					app.Session.Token = lr.Token
+					app.Session.Identify.Token = lr.Token
+					err = app.Connect()
 					if err != nil {
 						panic(err)
 					}

+ 10 - 14
ui/app.go

@@ -4,7 +4,7 @@ import (
 	"sort"
 	"strings"
 
-	"github.com/ayntgl/discordgo"
+	"github.com/ayntgl/astatine"
 	"github.com/ayntgl/discordo/config"
 	"github.com/gdamore/tcell/v2"
 	"github.com/rivo/tview"
@@ -17,8 +17,8 @@ type App struct {
 	ChannelsTreeView  *ChannelsTreeView
 	MessagesTextView  *MessagesTextView
 	MessageInputField *MessageInputField
-	Session           *discordgo.Session
-	SelectedChannel   *discordgo.Channel
+	Session           *astatine.Session
+	SelectedChannel   *astatine.Channel
 	Config            *config.Config
 	SelectedMessage   int
 }
@@ -35,8 +35,6 @@ func NewApp(c *config.Config) *App {
 	app.MessagesTextView = NewMessagesTextView(app)
 	app.MessageInputField = NewMessageInputField(app)
 
-	app.Session, _ = discordgo.New()
-
 	app.Application = tview.NewApplication()
 	app.EnableMouse(app.Config.General.Mouse)
 	app.SetInputCapture(app.onInputCapture)
@@ -44,16 +42,16 @@ func NewApp(c *config.Config) *App {
 	return app
 }
 
-func (app *App) Connect(token string) error {
+func (app *App) Connect() error {
 	// For user accounts, all of the guilds, the user is in, are dispatched in the READY gateway event.
 	// Whereas, for bot accounts, the guilds are dispatched discretely in the GUILD_CREATE gateway events.
-	if !strings.HasPrefix(token, "Bot") {
+	if !strings.HasPrefix(app.Session.Identify.Token, "Bot") {
 		app.Session.UserAgent = app.Config.General.UserAgent
-		app.Session.Identify = discordgo.Identify{
+		app.Session.Identify = astatine.Identify{
 			Compress:       false,
 			LargeThreshold: 0,
 			Intents:        0,
-			Properties: discordgo.IdentifyProperties{
+			Properties: astatine.IdentifyProperties{
 				OS:      app.Config.General.Identify.Os,
 				Browser: app.Config.General.Identify.Browser,
 			},
@@ -61,8 +59,6 @@ func (app *App) Connect(token string) error {
 		app.Session.AddHandlerOnce(app.onSessionReady)
 	}
 
-	app.Session.Token = token
-	app.Session.Identify.Token = token
 	app.Session.AddHandler(app.onSessionGuildCreate)
 	app.Session.AddHandler(app.onSessionMessageCreate)
 
@@ -110,7 +106,7 @@ func (app *App) DrawMainFlex() {
 	app.SetRoot(app.MainFlex, true)
 }
 
-func (app *App) onSessionReady(_ *discordgo.Session, r *discordgo.Ready) {
+func (app *App) onSessionReady(_ *astatine.Session, r *astatine.Ready) {
 	sort.Slice(r.Guilds, func(a, b int) bool {
 		found := false
 		for _, guildID := range r.Settings.GuildPositions {
@@ -132,11 +128,11 @@ func (app *App) onSessionReady(_ *discordgo.Session, r *discordgo.Ready) {
 	app.GuildsList.AddItem("Direct Messages", "", 0, nil)
 }
 
-func (app *App) onSessionGuildCreate(_ *discordgo.Session, g *discordgo.GuildCreate) {
+func (app *App) onSessionGuildCreate(_ *astatine.Session, g *astatine.GuildCreate) {
 	app.GuildsList.AddItem(g.Name, "", 0, nil)
 }
 
-func (app *App) onSessionMessageCreate(_ *discordgo.Session, m *discordgo.MessageCreate) {
+func (app *App) onSessionMessageCreate(_ *astatine.Session, m *astatine.MessageCreate) {
 	if app.SelectedChannel != nil && app.SelectedChannel.ID == m.ChannelID {
 		app.SelectedChannel.Messages = append(app.SelectedChannel.Messages, m.Message)
 		_, err := app.MessagesTextView.Write(buildMessage(app, m.Message))

+ 13 - 13
ui/builder.go

@@ -5,15 +5,15 @@ import (
 	"strings"
 	"time"
 
-	"github.com/ayntgl/discordgo"
+	"github.com/ayntgl/astatine"
 	"github.com/ayntgl/discordo/discord"
 )
 
-func buildMessage(app *App, m *discordgo.Message) []byte {
+func buildMessage(app *App, m *astatine.Message) []byte {
 	var b strings.Builder
 
 	switch m.Type {
-	case discordgo.MessageTypeDefault, discordgo.MessageTypeReply:
+	case astatine.MessageTypeDefault, astatine.MessageTypeReply:
 		// Define a new region and assign message ID as the region ID.
 		// Learn more:
 		// https://pkg.go.dev/github.com/rivo/tview#hdr-Regions_and_Highlights
@@ -51,19 +51,19 @@ func buildMessage(app *App, m *discordgo.Message) []byte {
 		b.WriteString("[\"\"]")
 
 		b.WriteByte('\n')
-	case discordgo.MessageTypeGuildMemberJoin:
+	case astatine.MessageTypeGuildMemberJoin:
 		b.WriteString("[#5865F2]")
 		b.WriteString(m.Author.Username)
 		b.WriteString("[-] joined the server.")
 
 		b.WriteByte('\n')
-	case discordgo.MessageTypeCall:
+	case astatine.MessageTypeCall:
 		b.WriteString("[#5865F2]")
 		b.WriteString(m.Author.Username)
 		b.WriteString("[-] started a call.")
 
 		b.WriteByte('\n')
-	case discordgo.MessageTypeChannelPinnedMessage:
+	case astatine.MessageTypeChannelPinnedMessage:
 		b.WriteString("[#5865F2]")
 		b.WriteString(m.Author.Username)
 		b.WriteString("[-] pinned a message.")
@@ -81,7 +81,7 @@ func buildMessage(app *App, m *discordgo.Message) []byte {
 	return nil
 }
 
-func buildReferencedMessage(b *strings.Builder, rm *discordgo.Message, clientID string) {
+func buildReferencedMessage(b *strings.Builder, rm *astatine.Message, clientID string) {
 	if rm != nil {
 		b.WriteString(" ╭ ")
 		b.WriteString("[::d]")
@@ -97,16 +97,16 @@ func buildReferencedMessage(b *strings.Builder, rm *discordgo.Message, clientID
 	}
 }
 
-func buildContent(b *strings.Builder, m *discordgo.Message, clientID string) {
+func buildContent(b *strings.Builder, m *astatine.Message, clientID string) {
 	if m.Content != "" {
 		m.Content = buildMentions(m.Content, m.Mentions, clientID)
 		b.WriteString(discord.ParseMarkdown(m.Content))
 	}
 }
 
-func buildEmbeds(b *strings.Builder, es []*discordgo.MessageEmbed) {
+func buildEmbeds(b *strings.Builder, es []*astatine.MessageEmbed) {
 	for _, e := range es {
-		if e.Type != discordgo.EmbedTypeRich {
+		if e.Type != astatine.EmbedTypeRich {
 			continue
 		}
 
@@ -177,7 +177,7 @@ func buildEmbeds(b *strings.Builder, es []*discordgo.MessageEmbed) {
 	}
 }
 
-func buildAttachments(b *strings.Builder, as []*discordgo.MessageAttachment) {
+func buildAttachments(b *strings.Builder, as []*astatine.MessageAttachment) {
 	for _, a := range as {
 		b.WriteByte('\n')
 		b.WriteByte('[')
@@ -187,7 +187,7 @@ func buildAttachments(b *strings.Builder, as []*discordgo.MessageAttachment) {
 	}
 }
 
-func buildMentions(content string, mentions []*discordgo.User, clientID string) string {
+func buildMentions(content string, mentions []*astatine.User, clientID string) string {
 	for _, mUser := range mentions {
 		var color string
 		if mUser.ID == clientID {
@@ -209,7 +209,7 @@ func buildMentions(content string, mentions []*discordgo.User, clientID string)
 	return content
 }
 
-func buildAuthor(b *strings.Builder, u *discordgo.User, clientID string) {
+func buildAuthor(b *strings.Builder, u *astatine.User, clientID string) {
 	if u.ID == clientID {
 		b.WriteString("[#57F287]")
 	} else {

+ 2 - 2
ui/channels.go

@@ -1,7 +1,7 @@
 package ui
 
 import (
-	"github.com/ayntgl/discordgo"
+	"github.com/ayntgl/astatine"
 	"github.com/rivo/tview"
 )
 
@@ -38,7 +38,7 @@ func (ctv *ChannelsTreeView) onSelected(n *tview.TreeNode) {
 		return
 	}
 
-	if c.Type == discordgo.ChannelTypeGuildCategory {
+	if c.Type == astatine.ChannelTypeGuildCategory {
 		n.SetExpanded(!n.IsExpanded())
 		return
 	}

+ 4 - 4
ui/guilds.go

@@ -3,7 +3,7 @@ package ui
 import (
 	"sort"
 
-	"github.com/ayntgl/discordgo"
+	"github.com/ayntgl/astatine"
 	"github.com/ayntgl/discordo/discord"
 	"github.com/rivo/tview"
 )
@@ -55,7 +55,7 @@ func (gl *GuildsList) onSelected(idx int, mainText string, secondaryText string,
 		})
 
 		for _, c := range cs {
-			if (c.Type == discordgo.ChannelTypeGuildText || c.Type == discordgo.ChannelTypeGuildNews) && (c.ParentID == "") {
+			if (c.Type == astatine.ChannelTypeGuildText || c.Type == astatine.ChannelTypeGuildNews) && (c.ParentID == "") {
 				channelTreeNode := tview.NewTreeNode(discord.ChannelToString(c)).
 					SetReference(c.ID)
 				rootTreeNode.AddChild(channelTreeNode)
@@ -64,7 +64,7 @@ func (gl *GuildsList) onSelected(idx int, mainText string, secondaryText string,
 
 	CATEGORY:
 		for _, c := range cs {
-			if c.Type == discordgo.ChannelTypeGuildCategory {
+			if c.Type == astatine.ChannelTypeGuildCategory {
 				for _, nestedChannel := range cs {
 					if nestedChannel.ParentID == c.ID {
 						channelTreeNode := tview.NewTreeNode(c.Name).
@@ -81,7 +81,7 @@ func (gl *GuildsList) onSelected(idx int, mainText string, secondaryText string,
 		}
 
 		for _, c := range cs {
-			if (c.Type == discordgo.ChannelTypeGuildText || c.Type == discordgo.ChannelTypeGuildNews) && (c.ParentID != "") {
+			if (c.Type == astatine.ChannelTypeGuildText || c.Type == astatine.ChannelTypeGuildNews) && (c.ParentID != "") {
 				var parentTreeNode *tview.TreeNode
 				rootTreeNode.Walk(func(node, _ *tview.TreeNode) bool {
 					if node.GetReference() == c.ParentID {

+ 5 - 5
ui/messages.go

@@ -11,7 +11,7 @@ import (
 	"strings"
 
 	"github.com/atotto/clipboard"
-	"github.com/ayntgl/discordgo"
+	"github.com/ayntgl/astatine"
 	"github.com/ayntgl/discordo/discord"
 	"github.com/gdamore/tcell/v2"
 	"github.com/rivo/tview"
@@ -111,7 +111,7 @@ func (mtv *MessagesTextView) onInputCapture(e *tcell.EventKey) *tcell.EventKey {
 			return nil
 		}
 
-		if discord.HasPermission(mtv.app.Session.State, mtv.app.SelectedChannel.ID, discordgo.PermissionSendMessages) {
+		if discord.HasPermission(mtv.app.Session.State, mtv.app.SelectedChannel.ID, astatine.PermissionSendMessages) {
 			messageActionsList.AddItem("Reply", "", 'r', func() {
 				mtv.app.MessageInputField.SetTitle("Replying to " + m.Author.String())
 				mtv.app.
@@ -191,7 +191,7 @@ func (mtv *MessagesTextView) onInputCapture(e *tcell.EventKey) *tcell.EventKey {
 	return e
 }
 
-func onMessageActionsListSelected(app *App, mainText string, m *discordgo.Message) {
+func onMessageActionsListSelected(app *App, mainText string, m *astatine.Message) {
 	switch mainText {
 	case "Select Reply":
 		app.SelectedMessage, _ = discord.FindMessageByID(app.SelectedChannel.Messages, m.ReferencedMessage.ID)
@@ -287,10 +287,10 @@ func (mi *MessageInputField) onInputCapture(e *tcell.EventKey) *tcell.EventKey {
 
 		if len(mi.app.MessagesTextView.GetHighlights()) != 0 {
 			_, m := discord.FindMessageByID(mi.app.SelectedChannel.Messages, mi.app.MessagesTextView.GetHighlights()[0])
-			d := &discordgo.MessageSend{
+			d := &astatine.MessageSend{
 				Content:         t,
 				Reference:       m.Reference(),
-				AllowedMentions: &discordgo.MessageAllowedMentions{RepliedUser: false},
+				AllowedMentions: &astatine.MessageAllowedMentions{RepliedUser: false},
 			}
 			if strings.HasPrefix(mi.app.MessageInputField.GetTitle(), "[@]") {
 				d.AllowedMentions.RepliedUser = true