Modify UserAgent & Identify properties for user accounts

This commit is contained in:
rigormorrtiss 2021-07-27 21:51:21 +04:00
parent fe1f0432c3
commit 9651934c16

View file

@ -71,6 +71,11 @@ func onLoginModalDone(buttonIndex int, buttonLabel string) {
}
func newSession(email string, password string, token string) *discordgo.Session {
userAgent := "" +
"Mozilla/5.0 (X11; Linux x86_64) " +
"AppleWebKit/537.36 (KHTML, like Gecko) " +
"Chrome/91.0.4472.164 Safari/537.36"
var sess *discordgo.Session
var err error
if email != "" && password != "" {
@ -79,6 +84,10 @@ func newSession(email string, password string, token string) *discordgo.Session
panic(err)
}
sess.UserAgent = userAgent
sess.Identify.Properties.Browser = "Chrome"
sess.Identify.Properties.OS = "Linux"
sess.AddHandler(onReady)
} else if token != "" {
sess, err = discordgo.New(token)
@ -87,14 +96,16 @@ func newSession(email string, password string, token string) *discordgo.Session
}
if !strings.HasPrefix(token, "Bot ") {
sess.UserAgent = userAgent
sess.Identify.Properties.Browser = "Chrome"
sess.Identify.Properties.OS = "Linux"
sess.AddHandler(onReady)
}
}
sess.AddHandler(onGuildCreate)
sess.AddHandler(onMessageCreate)
sess.Identify.Intents = discordgo.IntentsAllWithoutPrivileged
if err = sess.Open(); err != nil {
panic(err)
}