Linting
This commit is contained in:
parent
ab465c38c4
commit
fb663ac348
9 changed files with 47 additions and 32 deletions
|
@ -64,7 +64,7 @@ func main() {
|
|||
|
||||
func ready(s *discordgo.Session, event *discordgo.Ready) {
|
||||
// Set the playing status.
|
||||
s.UpdateStatus(0, "!airhorn")
|
||||
_ = s.UpdateStatus(0, "!airhorn")
|
||||
}
|
||||
|
||||
// This function will be called (due to AddHandler above) every time a new
|
||||
|
@ -108,7 +108,7 @@ func guildCreate(s *discordgo.Session, event *discordgo.GuildCreate) {
|
|||
|
||||
for _, channel := range event.Guild.Channels {
|
||||
if channel.ID == event.Guild.ID {
|
||||
s.ChannelMessageSend(channel.ID, "Airhorn is ready! Type !airhorn while in a voice channel to play a sound.")
|
||||
_, _ = s.ChannelMessageSend(channel.ID, "Airhorn is ready! Type !airhorn while in a voice channel to play a sound.")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ func playSound(s *discordgo.Session, guildID, channelID string) (err error) {
|
|||
time.Sleep(250 * time.Millisecond)
|
||||
|
||||
// Start speaking.
|
||||
vc.Speaking(true)
|
||||
_ = vc.Speaking(true)
|
||||
|
||||
// Send the buffer data.
|
||||
for _, buff := range buffer {
|
||||
|
@ -174,13 +174,13 @@ func playSound(s *discordgo.Session, guildID, channelID string) (err error) {
|
|||
}
|
||||
|
||||
// Stop speaking
|
||||
vc.Speaking(false)
|
||||
_ = vc.Speaking(false)
|
||||
|
||||
// Sleep for a specificed amount of time before ending.
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
|
||||
// Disconnect from the provided voice channel.
|
||||
vc.Disconnect()
|
||||
_ = vc.Disconnect()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -7,12 +7,12 @@ import (
|
|||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
// Variables used for command line options
|
||||
var (
|
||||
Email string
|
||||
Password string
|
||||
Token string
|
||||
AppName string
|
||||
ConvToken string
|
||||
DeleteID string
|
||||
ListOnly bool
|
||||
)
|
||||
|
@ -30,6 +30,7 @@ func init() {
|
|||
|
||||
func main() {
|
||||
|
||||
var err error
|
||||
// Create a new Discord session using the provided login information.
|
||||
dg, err := discordgo.New(Email, Password, Token)
|
||||
if err != nil {
|
||||
|
@ -40,8 +41,8 @@ func main() {
|
|||
// If -l set, only display a list of existing applications
|
||||
// for the given account.
|
||||
if ListOnly {
|
||||
aps, err := dg.Applications()
|
||||
if err != nil {
|
||||
aps, err2 := dg.Applications()
|
||||
if err2 != nil {
|
||||
fmt.Println("error fetching applications,", err)
|
||||
return
|
||||
}
|
||||
|
@ -58,7 +59,7 @@ func main() {
|
|||
|
||||
// if -d set, delete the given Application
|
||||
if DeleteID != "" {
|
||||
err := dg.ApplicationDelete(DeleteID)
|
||||
err = dg.ApplicationDelete(DeleteID)
|
||||
if err != nil {
|
||||
fmt.Println("error deleting application,", err)
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
// Variables used for command line parameters
|
||||
var (
|
||||
Email string
|
||||
Password string
|
||||
|
@ -63,7 +64,7 @@ func changeAvatar(s *discordgo.Session) {
|
|||
|
||||
base64 := base64.StdEncoding.EncodeToString(img)
|
||||
|
||||
avatar := fmt.Sprintf("data:%s;base64,%s", http.DetectContentType(img), string(base64))
|
||||
avatar := fmt.Sprintf("data:%s;base64,%s", http.DetectContentType(img), base64)
|
||||
|
||||
_, err = s.UserUpdate("", "", BotUsername, avatar, "")
|
||||
if err != nil {
|
||||
|
|
|
@ -10,11 +10,12 @@ import (
|
|||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
// Variables used for command line parameters
|
||||
var (
|
||||
Email string
|
||||
Password string
|
||||
Token string
|
||||
Url string
|
||||
URL string
|
||||
BotID string
|
||||
BotUsername string
|
||||
)
|
||||
|
@ -24,7 +25,7 @@ func init() {
|
|||
flag.StringVar(&Email, "e", "", "Account Email")
|
||||
flag.StringVar(&Password, "p", "", "Account Password")
|
||||
flag.StringVar(&Token, "t", "", "Account Token")
|
||||
flag.StringVar(&Url, "l", "http://bwmarrin.github.io/discordgo/img/discordgo.png", "Link to the avatar image")
|
||||
flag.StringVar(&URL, "l", "http://bwmarrin.github.io/discordgo/img/discordgo.png", "Link to the avatar image")
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
|
@ -57,13 +58,15 @@ func main() {
|
|||
// Helper function to change the avatar
|
||||
func changeAvatar(s *discordgo.Session) {
|
||||
|
||||
resp, err := http.Get(Url)
|
||||
resp, err := http.Get(URL)
|
||||
if err != nil {
|
||||
fmt.Println("Error retrieving the file, ", err)
|
||||
return
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
defer func() {
|
||||
_ = resp.Body.Close()
|
||||
}()
|
||||
|
||||
img, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
|
@ -73,7 +76,7 @@ func changeAvatar(s *discordgo.Session) {
|
|||
|
||||
base64 := base64.StdEncoding.EncodeToString(img)
|
||||
|
||||
avatar := fmt.Sprintf("data:%s;base64,%s", http.DetectContentType(img), string(base64))
|
||||
avatar := fmt.Sprintf("data:%s;base64,%s", http.DetectContentType(img), base64)
|
||||
|
||||
_, err = s.UserUpdate("", "", BotUsername, avatar, "")
|
||||
if err != nil {
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
// Variables used for command line parameters
|
||||
var (
|
||||
Email string
|
||||
Password string
|
||||
|
|
|
@ -8,11 +8,11 @@ import (
|
|||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
// Variables used for command line parameters
|
||||
var (
|
||||
Email string
|
||||
Password string
|
||||
Token string
|
||||
BotID string
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -37,7 +37,11 @@ func main() {
|
|||
dg.AddHandler(messageCreate)
|
||||
|
||||
// Open the websocket and begin listening.
|
||||
dg.Open()
|
||||
err = dg.Open()
|
||||
if err != nil {
|
||||
fmt.Println("error opening connection,", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("Bot is now running. Press CTRL-C to exit.")
|
||||
// Simple way to keep program running until CTRL-C is pressed.
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
// Variables used for command line parameters
|
||||
var (
|
||||
Email string
|
||||
Password string
|
||||
|
@ -44,7 +45,11 @@ func main() {
|
|||
dg.AddHandler(messageCreate)
|
||||
|
||||
// Open the websocket and begin listening.
|
||||
dg.Open()
|
||||
err = dg.Open()
|
||||
if err != nil {
|
||||
fmt.Println("error opening connection,", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("Bot is now running. Press CTRL-C to exit.")
|
||||
// Simple way to keep program running until CTRL-C is pressed.
|
||||
|
@ -63,11 +68,11 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|||
|
||||
// If the message is "ping" reply with "Pong!"
|
||||
if m.Content == "ping" {
|
||||
s.ChannelMessageSend(m.ChannelID, "Pong!")
|
||||
_, _ = s.ChannelMessageSend(m.ChannelID, "Pong!")
|
||||
}
|
||||
|
||||
// If the message is "pong" reply with "Ping!"
|
||||
if m.Content == "pong" {
|
||||
s.ChannelMessageSend(m.ChannelID, "Ping!")
|
||||
_, _ = s.ChannelMessageSend(m.ChannelID, "Ping!")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,8 +107,8 @@ func (s *Session) request(method, urlStr, contentType string, b []byte) (respons
|
|||
return
|
||||
}
|
||||
defer func() {
|
||||
err := resp.Body.Close()
|
||||
if err != nil {
|
||||
err2 := resp.Body.Close()
|
||||
if err2 != nil {
|
||||
log.Println("error closing resp body")
|
||||
}
|
||||
}()
|
||||
|
|
8
wsapi.go
8
wsapi.go
|
@ -288,15 +288,15 @@ func (s *Session) onEvent(messageType int, message []byte) {
|
|||
// If this is a compressed message, uncompress it.
|
||||
if messageType == websocket.BinaryMessage {
|
||||
|
||||
z, err := zlib.NewReader(reader)
|
||||
if err != nil {
|
||||
z, err2 := zlib.NewReader(reader)
|
||||
if err2 != nil {
|
||||
s.log(LogError, "error uncompressing websocket message, %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
defer func() {
|
||||
err := z.Close()
|
||||
if err != nil {
|
||||
err3 := z.Close()
|
||||
if err3 != nil {
|
||||
s.log(LogWarning, "error closing zlib, %s", err)
|
||||
}
|
||||
}()
|
||||
|
|
Loading…
Reference in a new issue