Skip to content

Commit

Permalink
Fixed panic on nil pointer reference
Browse files Browse the repository at this point in the history
  • Loading branch information
V4NSH4J committed May 18, 2022
1 parent 34ce9f1 commit b608dad
Showing 1 changed file with 28 additions and 21 deletions.
49 changes: 28 additions & 21 deletions discord/profile_changer.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,16 @@ func LaunchNameChanger() {
color.Red("[%v] %v Error while changing name: %v %v", time.Now().Format("15:04:05"), instances[i].CensorToken(), r.Status, string(body))
FailedCount++
}
if instances[i].Ws.Conn != nil {
err = instances[i].Ws.Close()
if err != nil {
color.Red("[%v] Error while closing websocket: %v", time.Now().Format("15:04:05"), err)
} else {
color.Green("[%v] Websocket closed %v", time.Now().Format("15:04:05"), instances[i].CensorToken())
if instances[i].Ws != nil {
if instances[i].Ws.Conn != nil {
err = instances[i].Ws.Close()
if err != nil {
color.Red("[%v] Error while closing websocket: %v", time.Now().Format("15:04:05"), err)
} else {
color.Green("[%v] Websocket closed %v", time.Now().Format("15:04:05"), instances[i].CensorToken())
}
c.Done()
}
c.Done()
}
}(i)
}
Expand Down Expand Up @@ -183,15 +185,18 @@ func LaunchAvatarChanger() {
FailedCount++
}
}
if instances[i].Ws.Conn != nil {
err = instances[i].Ws.Close()
if err != nil {
color.Red("[%v] Error while closing websocket: %v", time.Now().Format("15:04:05"), err)
} else {
color.Green("[%v] Websocket closed %v", time.Now().Format("15:04:05"), instances[i].CensorToken())
if instances[i].Ws != nil {
if instances[i].Ws.Conn != nil {
err = instances[i].Ws.Close()
if err != nil {
color.Red("[%v] Error while closing websocket: %v", time.Now().Format("15:04:05"), err)
} else {
color.Green("[%v] Websocket closed %v", time.Now().Format("15:04:05"), instances[i].CensorToken())
}
c.Done()
}
c.Done()
}

}(i)
}
c.WaitAllDone()
Expand Down Expand Up @@ -252,14 +257,16 @@ func LaunchBioChanger() {
color.Green("[%v] %v Bio changed successfully", time.Now().Format("15:04:05"), instances[i].CensorToken())
SuccessCount++
}
if instances[i].Ws.Conn != nil {
err = instances[i].Ws.Close()
if err != nil {
color.Red("[%v] Error while closing websocket: %v", time.Now().Format("15:04:05"), err)
} else {
color.Green("[%v] Websocket closed %v", time.Now().Format("15:04:05"), instances[i].CensorToken())
if instances[i].Ws != nil {
if instances[i].Ws.Conn != nil {
err = instances[i].Ws.Close()
if err != nil {
color.Red("[%v] Error while closing websocket: %v", time.Now().Format("15:04:05"), err)
} else {
color.Green("[%v] Websocket closed %v", time.Now().Format("15:04:05"), instances[i].CensorToken())
}
c.Done()
}
c.Done()
}
}(i)
}
Expand Down

0 comments on commit b608dad

Please sign in to comment.