diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4d9d29c9..c161cf18e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,7 @@ on: push: + branches: + - master pull_request: name: CI @@ -8,12 +10,12 @@ jobs: format: runs-on: ubuntu-latest steps: + - name: Code + uses: actions/checkout@v4 - name: Install Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: - go-version: 1.18 - - name: Code - uses: actions/checkout@v3 + go-version: "1.22" - name: Check diff between gofmt and code run: diff <(gofmt -d .) <(echo -n) @@ -21,40 +23,32 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go-version: [1.13, 1.14, 1.15, 1.16, 1.17, 1.18] + go-version: ["1.13", "1.14", "1.15", "1.16", "1.17", "1.18", "1.19", "1.20", "1.21", "1.22"] steps: + - name: Code + uses: actions/checkout@v4 - name: Install Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} - - name: Code - uses: actions/checkout@v3 - run: go test -v -race ./... lint: runs-on: ubuntu-latest steps: + - name: Code + uses: actions/checkout@v4 - name: Install Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: - go-version: 1.18 - - name: Code - uses: actions/checkout@v3 + go-version: "1.22" - name: Go vet run: go vet -x ./... - name: GolangCI-Lint uses: golangci/golangci-lint-action@v3 - if: github.event.name == 'pull_request' with: - only-new-issues: true skip-pkg-cache: true skip-build-cache: true - - - name: GolangCI-Lint - if: github.event.name != 'pull_request' # See https://github.com/golangci/golangci-lint-action/issues/362 - run: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.45.2 - - $(go env GOPATH)/bin/golangci-lint run - + version: v1.54 + args: --out-format colored-line-number diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e80d490bd..000000000 --- a/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: go -go: - - 1.13.x - - 1.14.x - - 1.15.x - - 1.16.x - - 1.17.x - - 1.18.x -env: - - GO111MODULE=on -install: - - go get github.com/bwmarrin/discordgo - - go get -v . - - go get -v golang.org/x/lint/golint -script: - - diff <(gofmt -d .) <(echo -n) - - go vet -x ./... - - golint -set_exit_status ./... - - go test -v -race ./... diff --git a/discord.go b/discord.go index 584e567df..faf386110 100644 --- a/discord.go +++ b/discord.go @@ -26,9 +26,12 @@ const VERSION = "0.27.1" // New creates a new Discord session with provided token. // If the token is for a bot, it must be prefixed with "Bot " -// e.g. "Bot ..." +// +// e.g. "Bot ..." +// // Or if it is an OAuth2 token, it must be prefixed with "Bearer " -// e.g. "Bearer ..." +// +// e.g. "Bearer ..." func New(token string) (s *Session, err error) { // Create an empty Session interface. diff --git a/discord_test.go b/discord_test.go index df5239785..49f8ca417 100644 --- a/discord_test.go +++ b/discord_test.go @@ -9,8 +9,8 @@ import ( "time" ) -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////// VARS NEEDED FOR TESTING +// //////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////// VARS NEEDED FOR TESTING var ( dg *Session // Stores a global discordgo user session dgBot *Session // Stores a global discordgo bot session diff --git a/event.go b/event.go index 84dbdc7fb..941085d70 100644 --- a/event.go +++ b/event.go @@ -102,12 +102,14 @@ func (s *Session) addEventHandlerOnce(eventHandler EventHandler) func() { // to a struct corresponding to the event for which you want to listen. // // eg: -// Session.AddHandler(func(s *discordgo.Session, m *discordgo.MessageCreate) { -// }) +// +// Session.AddHandler(func(s *discordgo.Session, m *discordgo.MessageCreate) { +// }) // // or: -// Session.AddHandler(func(s *discordgo.Session, m *discordgo.PresenceUpdate) { -// }) +// +// Session.AddHandler(func(s *discordgo.Session, m *discordgo.PresenceUpdate) { +// }) // // List of events can be found at this page, with corresponding names in the // library for each event: https://discord.com/developers/docs/topics/gateway#event-names diff --git a/logging.go b/logging.go index b798d3e87..ffb9342c1 100644 --- a/logging.go +++ b/logging.go @@ -39,10 +39,11 @@ var Logger func(msgL, caller int, format string, a ...interface{}) // msglog provides package wide logging consistency for discordgo // the format, a... portion this command follows that of fmt.Printf -// msgL : LogLevel of the message -// caller : 1 + the number of callers away from the message source -// format : Printf style message format -// a ... : comma separated list of values to pass +// +// msgL : LogLevel of the message +// caller : 1 + the number of callers away from the message source +// format : Printf style message format +// a ... : comma separated list of values to pass func msglog(msgL, caller int, format string, a ...interface{}) { if Logger != nil { diff --git a/oauth2.go b/oauth2.go index 2fa2d8d54..492aa4174 100644 --- a/oauth2.go +++ b/oauth2.go @@ -41,7 +41,8 @@ type Team struct { } // Application returns an Application structure of a specific Application -// appID : The ID of an Application +// +// appID : The ID of an Application func (s *Session) Application(appID string) (st *Application, err error) { body, err := s.RequestWithBucketID("GET", EndpointOAuth2Application(appID), nil, EndpointOAuth2Application("")) @@ -66,8 +67,9 @@ func (s *Session) Applications() (st []*Application, err error) { } // ApplicationCreate creates a new Application -// name : Name of Application / Bot -// uris : Redirect URIs (Not required) +// +// name : Name of Application / Bot +// uris : Redirect URIs (Not required) func (s *Session) ApplicationCreate(ap *Application) (st *Application, err error) { data := struct { @@ -85,7 +87,8 @@ func (s *Session) ApplicationCreate(ap *Application) (st *Application, err error } // ApplicationUpdate updates an existing Application -// var : desc +// +// var : desc func (s *Session) ApplicationUpdate(appID string, ap *Application) (st *Application, err error) { data := struct { @@ -103,7 +106,8 @@ func (s *Session) ApplicationUpdate(appID string, ap *Application) (st *Applicat } // ApplicationDelete deletes an existing Application -// appID : The ID of an Application +// +// appID : The ID of an Application func (s *Session) ApplicationDelete(appID string) (err error) { _, err = s.RequestWithBucketID("DELETE", EndpointOAuth2Application(appID), nil, EndpointOAuth2Application("")) @@ -139,7 +143,7 @@ func (s *Session) ApplicationAssets(appID string) (ass []*Asset, err error) { // ApplicationBotCreate creates an Application Bot Account // -// appID : The ID of an Application +// appID : The ID of an Application // // NOTE: func name may change, if I can think up something better. func (s *Session) ApplicationBotCreate(appID string) (st *User, err error) { diff --git a/state.go b/state.go index d0c7b4222..92e3825f7 100644 --- a/state.go +++ b/state.go @@ -175,8 +175,9 @@ func (s *State) GuildRemove(guild *Guild) error { // Guild gets a guild by ID. // Useful for querying if @me is in a guild: -// _, err := discordgo.Session.State.Guild(guildID) -// isInGuild := err == nil +// +// _, err := discordgo.Session.State.Guild(guildID) +// isInGuild := err == nil func (s *State) Guild(guildID string) (*Guild, error) { if s == nil { return nil, ErrNilState diff --git a/wsapi.go b/wsapi.go index f63cfdbe0..542df94cb 100644 --- a/wsapi.go +++ b/wsapi.go @@ -682,10 +682,10 @@ type voiceChannelJoinOp struct { // ChannelVoiceJoin joins the session user to a voice channel. // -// gID : Guild ID of the channel to join. -// cID : Channel ID of the channel to join. -// mute : If true, you will be set to muted upon joining. -// deaf : If true, you will be set to deafened upon joining. +// gID : Guild ID of the channel to join. +// cID : Channel ID of the channel to join. +// mute : If true, you will be set to muted upon joining. +// deaf : If true, you will be set to deafened upon joining. func (s *Session) ChannelVoiceJoin(gID, cID string, mute, deaf bool) (voice *VoiceConnection, err error) { s.log(LogInformational, "called") @@ -729,10 +729,10 @@ func (s *Session) ChannelVoiceJoin(gID, cID string, mute, deaf bool) (voice *Voi // // This should only be used when the VoiceServerUpdate will be intercepted and used elsewhere. // -// gID : Guild ID of the channel to join. -// cID : Channel ID of the channel to join, leave empty to disconnect. -// mute : If true, you will be set to muted upon joining. -// deaf : If true, you will be set to deafened upon joining. +// gID : Guild ID of the channel to join. +// cID : Channel ID of the channel to join, leave empty to disconnect. +// mute : If true, you will be set to muted upon joining. +// deaf : If true, you will be set to deafened upon joining. func (s *Session) ChannelVoiceJoinManual(gID, cID string, mute, deaf bool) (err error) { s.log(LogInformational, "called")