Linting.
This commit is contained in:
parent
68a784327f
commit
9e777a083b
6 changed files with 23 additions and 22 deletions
|
@ -60,7 +60,7 @@ func New(args ...interface{}) (s *Session, err error) {
|
||||||
|
|
||||||
case []string:
|
case []string:
|
||||||
if len(v) > 3 {
|
if len(v) > 3 {
|
||||||
err = fmt.Errorf("Too many string parameters provided.")
|
err = fmt.Errorf("too many string parameters provided")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ func New(args ...interface{}) (s *Session, err error) {
|
||||||
} else if s.Token == "" {
|
} else if s.Token == "" {
|
||||||
s.Token = v
|
s.Token = v
|
||||||
} else {
|
} else {
|
||||||
err = fmt.Errorf("Too many string parameters provided.")
|
err = fmt.Errorf("too many string parameters provided")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ func New(args ...interface{}) (s *Session, err error) {
|
||||||
// TODO: Parse configuration struct
|
// TODO: Parse configuration struct
|
||||||
|
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("Unsupported parameter type provided.")
|
err = fmt.Errorf("unsupported parameter type provided")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -960,7 +960,7 @@ func (s *Session) GuildPruneCount(guildID string, days uint32) (count uint32, er
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
if days <= 0 {
|
if days <= 0 {
|
||||||
err = errors.New("The number of days should be more than or equal to 1.")
|
err = errors.New("the number of days should be more than or equal to 1")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -990,7 +990,7 @@ func (s *Session) GuildPrune(guildID string, days uint32) (count uint32, err err
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
if days <= 0 {
|
if days <= 0 {
|
||||||
err = errors.New("The number of days should be more than or equal to 1.")
|
err = errors.New("the number of days should be more than or equal to 1")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1092,7 +1092,7 @@ func (s *Session) GuildIcon(guildID string) (img image.Image, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if g.Icon == "" {
|
if g.Icon == "" {
|
||||||
err = errors.New("Guild does not have an icon set.")
|
err = errors.New("guild does not have an icon set")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1114,7 +1114,7 @@ func (s *Session) GuildSplash(guildID string) (img image.Image, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if g.Splash == "" {
|
if g.Splash == "" {
|
||||||
err = errors.New("Guild does not have a splash set.")
|
err = errors.New("guild does not have a splash set")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
22
state.go
22
state.go
|
@ -19,7 +19,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrNilState is returned when the state is nil.
|
// ErrNilState is returned when the state is nil.
|
||||||
var ErrNilState = errors.New("State not instantiated, please use discordgo.New() or assign Session.State.")
|
var ErrNilState = errors.New("state not instantiated, please use discordgo.New() or assign Session.State")
|
||||||
|
|
||||||
// A State contains the current known state.
|
// A State contains the current known state.
|
||||||
// As discord sends this in a READY blob, it seems reasonable to simply
|
// As discord sends this in a READY blob, it seems reasonable to simply
|
||||||
|
@ -144,7 +144,7 @@ func (s *State) Guild(guildID string) (*Guild, error) {
|
||||||
return g, nil
|
return g, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, errors.New("Guild not found.")
|
return nil, errors.New("guild not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Consider moving Guild state update methods onto *Guild.
|
// TODO: Consider moving Guild state update methods onto *Guild.
|
||||||
|
@ -196,7 +196,7 @@ func (s *State) MemberRemove(member *Member) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.New("Member not found.")
|
return errors.New("member not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Member gets a member by ID from a guild.
|
// Member gets a member by ID from a guild.
|
||||||
|
@ -219,7 +219,7 @@ func (s *State) Member(guildID, userID string) (*Member, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, errors.New("Member not found.")
|
return nil, errors.New("member not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoleAdd adds a role to the current world state, or
|
// RoleAdd adds a role to the current world state, or
|
||||||
|
@ -269,7 +269,7 @@ func (s *State) RoleRemove(guildID, roleID string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.New("Role not found.")
|
return errors.New("role not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Role gets a role by ID from a guild.
|
// Role gets a role by ID from a guild.
|
||||||
|
@ -292,7 +292,7 @@ func (s *State) Role(guildID, roleID string) (*Role, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, errors.New("Role not found.")
|
return nil, errors.New("role not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChannelAdd adds a guild to the current world state, or
|
// ChannelAdd adds a guild to the current world state, or
|
||||||
|
@ -325,7 +325,7 @@ func (s *State) ChannelAdd(channel *Channel) error {
|
||||||
} else {
|
} else {
|
||||||
guild, ok := s.guildMap[channel.GuildID]
|
guild, ok := s.guildMap[channel.GuildID]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("Guild for channel not found.")
|
return errors.New("guild for channel not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
guild.Channels = append(guild.Channels, channel)
|
guild.Channels = append(guild.Channels, channel)
|
||||||
|
@ -404,7 +404,7 @@ func (s *State) Channel(channelID string) (*Channel, error) {
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, errors.New("Channel not found.")
|
return nil, errors.New("channel not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emoji returns an emoji for a guild and emoji id.
|
// Emoji returns an emoji for a guild and emoji id.
|
||||||
|
@ -427,7 +427,7 @@ func (s *State) Emoji(guildID, emojiID string) (*Emoji, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, errors.New("Emoji not found.")
|
return nil, errors.New("emoji not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// EmojiAdd adds an emoji to the current world state.
|
// EmojiAdd adds an emoji to the current world state.
|
||||||
|
@ -539,7 +539,7 @@ func (s *State) MessageRemove(message *Message) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.New("Message not found.")
|
return errors.New("message not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *State) voiceStateUpdate(update *VoiceStateUpdate) error {
|
func (s *State) voiceStateUpdate(update *VoiceStateUpdate) error {
|
||||||
|
@ -593,7 +593,7 @@ func (s *State) Message(channelID, messageID string) (*Message, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, errors.New("Message not found.")
|
return nil, errors.New("message not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnReady takes a Ready event and updates all internal state.
|
// OnReady takes a Ready event and updates all internal state.
|
||||||
|
|
|
@ -246,6 +246,7 @@ type Role struct {
|
||||||
Permissions int `json:"permissions"`
|
Permissions int `json:"permissions"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Roles are a collection of Role
|
||||||
type Roles []*Role
|
type Roles []*Role
|
||||||
|
|
||||||
func (r Roles) Len() int {
|
func (r Roles) Len() int {
|
||||||
|
|
6
voice.go
6
voice.go
|
@ -93,7 +93,7 @@ func (v *VoiceConnection) Speaking(b bool) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.wsConn == nil {
|
if v.wsConn == nil {
|
||||||
return fmt.Errorf("No VoiceConnection websocket.")
|
return fmt.Errorf("no VoiceConnection websocket")
|
||||||
}
|
}
|
||||||
|
|
||||||
data := voiceSpeakingOp{5, voiceSpeakingData{b, 0}}
|
data := voiceSpeakingOp{5, voiceSpeakingData{b, 0}}
|
||||||
|
@ -251,7 +251,7 @@ func (v *VoiceConnection) waitUntilConnected() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if i > 10 {
|
if i > 10 {
|
||||||
return fmt.Errorf("Timeout waiting for voice.")
|
return fmt.Errorf("timeout waiting for voice")
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
@ -282,7 +282,7 @@ func (v *VoiceConnection) open() (err error) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if i > 20 { // only loop for up to 1 second total
|
if i > 20 { // only loop for up to 1 second total
|
||||||
return fmt.Errorf("Did not receive voice Session ID in time.")
|
return fmt.Errorf("did not receive voice Session ID in time")
|
||||||
}
|
}
|
||||||
time.Sleep(50 * time.Millisecond)
|
time.Sleep(50 * time.Millisecond)
|
||||||
i++
|
i++
|
||||||
|
|
2
wsapi.go
2
wsapi.go
|
@ -57,7 +57,7 @@ func (s *Session) Open() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.wsConn != nil {
|
if s.wsConn != nil {
|
||||||
err = errors.New("Web socket already opened.")
|
err = errors.New("web socket already opened")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue