Skip to content

Commit

Permalink
Merge branch 'master' into patch/guild-incidents
Browse files Browse the repository at this point in the history
  • Loading branch information
sebm253 authored Jan 24, 2025
2 parents eaee5bf + e5d0cac commit 9da10d4
Show file tree
Hide file tree
Showing 213 changed files with 5,921 additions and 1,548 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ ij_go_wrap_func_result_newline_before_rparen = true
indent_style = tab
max_line_length = 600
ij_smart_tabs = true

[{*.yaml,*.yml}]
indent_size = 2
35 changes: 35 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# branch names
"type:bugfix":
- head-branch: [ '^fix/', '^bugfix/', '^hotfix/']
"type:docs":
- head-branch: [ '^docs/', '^documentation/' ]
"type:enhancement":
- head-branch: [ '^feature/', '^feat/' ]
"type:refactor":
- head-branch: [ '^refactor/' ]

# changed files
"t:caching":
- changed-files:
- any-glob-to-any-file: [ 'cache/*' ]
"t:gateway":
- changed-files:
- any-glob-to-any-file: [ 'gateway/*' ]
"t:handler":
- changed-files:
- any-glob-to-any-file: [ 'handler/*' ]
"t:oauth2":
- changed-files:
- any-glob-to-any-file: [ 'oauth2/*' ]
"t:ratelimits":
- changed-files:
- any-glob-to-any-file: [ 'rest/rest_rate_limiter_*', 'gateway/gateway_rate_limiter_*' ]
"t:rest":
- changed-files:
- any-glob-to-any-file: [ 'rest/*' ]
"t:sharding":
- changed-files:
- any-glob-to-any-file: [ 'sharding/*' ]
"t:voice":
- changed-files:
- any-glob-to-any-file: [ 'voice/*' ]
48 changes: 48 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Go

on:
push:
paths:
- '**/*.go'
- '**/go.mod'
- '**/go.sum'
- '.github/workflows/go.yml'
pull_request_target:
paths:
- '**/*.go'
- '**/go.mod'
- '**/go.sum'
- '.github/workflows/go.yml'

jobs:
gobuild:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.21
- uses: actions/checkout@v3
- name: go build
run: go build -v ./...

gotest:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.21
- uses: actions/checkout@v3
- name: go build
run: go test -v ./...

golangci:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.21
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
12 changes: 12 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "Label pull request"
on:
- pull_request_target

jobs:
labeler:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
36 changes: 0 additions & 36 deletions .github/workflows/lint.yml

This file was deleted.

6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ A full Ping Pong example can also be found [here](https://github.com/disgoorg/di

### Logging

DisGo uses our own small [logging interface](https://github.com/disgoorg/log) which you can use with most other logging libraries. This lib also comes with a default logger which is based on the standard log package.
DisGo uses [slog](https://pkg.go.dev/log/slog) for logging.

## Documentation

Expand Down Expand Up @@ -156,10 +156,6 @@ Being used in production by FredBoat, Dyno, LewdBot, and more.

Is a [Lavalink-Client](https://github.com/freyacodes/Lavalink) which can be used to communicate with Lavalink to play/search tracks

### [DisLog](https://github.com/disgoorg/dislog)

Is a Discord webhook logger hook for [logrus](https://github.com/sirupsen/logrus)

## Other Golang Discord Libraries

* [discordgo](https://github.com/bwmarrin/discordgo)
Expand Down
20 changes: 9 additions & 11 deletions _examples/application_commands/gateway/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ package main

import (
"context"
"log/slog"
"os"
"os/signal"
"syscall"

"github.com/disgoorg/log"
"github.com/disgoorg/snowflake/v2"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/events"
"github.com/disgoorg/snowflake/v2"
)

var (
Expand Down Expand Up @@ -40,30 +39,29 @@ var (
)

func main() {
log.SetLevel(log.LevelInfo)
log.Info("starting example...")
log.Info("disgo version: ", disgo.Version)
slog.Info("starting example...")
slog.Info("disgo version", slog.String("version", disgo.Version))

client, err := disgo.New(token,
bot.WithDefaultGateway(),
bot.WithEventListenerFunc(commandListener),
)
if err != nil {
log.Fatal("error while building disgo instance: ", err)
slog.Error("error while building disgo instance", slog.Any("err", err))
return
}

defer client.Close(context.TODO())

if _, err = client.Rest().SetGuildCommands(client.ApplicationID(), guildID, commands); err != nil {
log.Fatal("error while registering commands: ", err)
slog.Error("error while registering commands", slog.Any("err", err))
}

if err = client.OpenGateway(context.TODO()); err != nil {
log.Fatal("error while connecting to gateway: ", err)
slog.Error("error while connecting to gateway", slog.Any("err", err))
}

log.Infof("example is now running. Press CTRL-C to exit.")
slog.Info("example is now running. Press CTRL-C to exit.")
s := make(chan os.Signal, 1)
signal.Notify(s, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
<-s
Expand All @@ -78,7 +76,7 @@ func commandListener(event *events.ApplicationCommandInteractionCreate) {
Build(),
)
if err != nil {
event.Client().Logger().Error("error on sending response: ", err)
slog.Error("error on sending response", slog.Any("err", err))
}
}
}
23 changes: 10 additions & 13 deletions _examples/application_commands/http/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ package main

import (
"context"
"log/slog"
"os"
"os/signal"
"syscall"

"github.com/disgoorg/log"
"github.com/disgoorg/snowflake/v2"
"github.com/oasisprotocol/curve25519-voi/primitives/ed25519"

"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/events"
"github.com/disgoorg/disgo/httpserver"
"github.com/disgoorg/snowflake/v2"
"github.com/oasisprotocol/curve25519-voi/primitives/ed25519"
)

var (
Expand Down Expand Up @@ -43,9 +42,8 @@ var (
)

func main() {
log.SetLevel(log.LevelDebug)
log.Info("starting example...")
log.Info("disgo version: ", disgo.Version)
slog.Info("starting example...")
slog.Info("disgo version", slog.String("version", disgo.Version))

// use custom ed25519 verify implementation
httpserver.Verify = func(publicKey httpserver.PublicKey, message, sig []byte) bool {
Expand All @@ -60,21 +58,20 @@ func main() {
bot.WithEventListenerFunc(commandListener),
)
if err != nil {
log.Fatal("error while building disgo instance: ", err)
return
panic("error while building disgo instance: " + err.Error())
}

defer client.Close(context.TODO())

if _, err = client.Rest().SetGuildCommands(client.ApplicationID(), guildID, commands); err != nil {
log.Fatal("error while registering commands: ", err)
panic("error while registering commands: " + err.Error())
}

if err = client.OpenHTTPServer(); err != nil {
log.Fatal("error while starting http server: ", err)
panic("error while starting http server: " + err.Error())
}

log.Info("example is now running. Press CTRL-C to exit.")
slog.Info("example is now running. Press CTRL-C to exit.")
s := make(chan os.Signal, 1)
signal.Notify(s, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
<-s
Expand All @@ -88,7 +85,7 @@ func commandListener(event *events.ApplicationCommandInteractionCreate) {
SetEphemeral(data.Bool("ephemeral")).
Build(),
); err != nil {
event.Client().Logger().Error("error on sending response: ", err)
event.Client().Logger().Error("error on sending response", slog.Any("err", err))
}
}
}
22 changes: 11 additions & 11 deletions _examples/application_commands/http/go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
module github.com/disgoorg/disgo/_examples/application_commands/http

go 1.18
go 1.21

replace github.com/disgoorg/disgo => ../../../

require (
github.com/disgoorg/disgo v0.16.8
github.com/disgoorg/log v1.2.1
github.com/disgoorg/snowflake/v2 v2.0.1
github.com/oasisprotocol/curve25519-voi v0.0.0-20230110094441-db37f07504ce
github.com/disgoorg/disgo v0.18.14
github.com/disgoorg/snowflake/v2 v2.0.3
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a
)

require (
github.com/disgoorg/json v1.1.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/sasha-s/go-csync v0.0.0-20210812194225-61421b77c44b // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b // indirect
golang.org/x/sys v0.11.0 // indirect
github.com/disgoorg/json v1.2.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/sys v0.28.0 // indirect
)
40 changes: 19 additions & 21 deletions _examples/application_commands/http/go.sum
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/disgoorg/disgo v0.16.8 h1:tvUeX+3Iu8U6koDc8RAgcQadRciWJwsI95Y7edHqq2g=
github.com/disgoorg/disgo v0.16.8/go.mod h1:5fsaUpfu6Yv0p+PfmsAeQkV395KQskVu/d1bdq8vsNI=
github.com/disgoorg/json v1.1.0 h1:7xigHvomlVA9PQw9bMGO02PHGJJPqvX5AnwlYg/Tnys=
github.com/disgoorg/json v1.1.0/go.mod h1:BHDwdde0rpQFDVsRLKhma6Y7fTbQKub/zdGO5O9NqqA=
github.com/disgoorg/log v1.2.1 h1:kZYAWkUBcGy4LbZcgYtgYu49xNVLy+xG5Uq3yz5VVQs=
github.com/disgoorg/log v1.2.1/go.mod h1:hhQWYTFTnIGzAuFPZyXJEi11IBm9wq+/TVZt/FEwX0o=
github.com/disgoorg/snowflake/v2 v2.0.1 h1:CuUxGLwggUxEswZOmZ+mZ5i0xSumQdXW9tXW7uGqe+0=
github.com/disgoorg/snowflake/v2 v2.0.1/go.mod h1:SPU9c2CNn5DSyb86QcKtdZgix9osEtKrHLW4rMhfLCs=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/oasisprotocol/curve25519-voi v0.0.0-20230110094441-db37f07504ce h1:/pEpMk55wH0X+E5zedGEMOdLuWmV8P4+4W3+LZaM6kg=
github.com/oasisprotocol/curve25519-voi v0.0.0-20230110094441-db37f07504ce/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/disgoorg/json v1.2.0 h1:6e/j4BCfSHIvucG1cd7tJPAOp1RgnnMFSqkvZUtEd1Y=
github.com/disgoorg/json v1.2.0/go.mod h1:BHDwdde0rpQFDVsRLKhma6Y7fTbQKub/zdGO5O9NqqA=
github.com/disgoorg/snowflake/v2 v2.0.3 h1:3B+PpFjr7j4ad7oeJu4RlQ+nYOTadsKapJIzgvSI2Ro=
github.com/disgoorg/snowflake/v2 v2.0.3/go.mod h1:W6r7NUA7DwfZLwr00km6G4UnZ0zcoLBRufhkFWgAc4c=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a h1:dlRvE5fWabOchtH7znfiFCcOvmIYgOeAS5ifBXBlh9Q=
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/sasha-s/go-csync v0.0.0-20210812194225-61421b77c44b h1:qYTY2tN72LhgDj2rtWG+LI6TXFl2ygFQQ4YezfVaGQE=
github.com/sasha-s/go-csync v0.0.0-20210812194225-61421b77c44b/go.mod h1:/pA7k3zsXKdjjAiUhB5CjuKib9KJGCaLvZwtxGC8U0s=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b h1:r+vk0EmXNmekl0S0BascoeeoHk/L7wmaW2QF90K+kYI=
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad h1:qIQkSlF5vAUHxEmTbaqt1hkJ/t6skqEGYiMag343ucI=
github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad/go.mod h1:/pA7k3zsXKdjjAiUhB5CjuKib9KJGCaLvZwtxGC8U0s=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading

0 comments on commit 9da10d4

Please sign in to comment.