Skip to content

Commit bfbc98a

Browse files
committed
Merge remote-tracking branch 'upstream'
2 parents c4e94ba + 8ac2ef0 commit bfbc98a

File tree

244 files changed

+6115
-4325
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

244 files changed

+6115
-4325
lines changed

.editorconfig

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ end_of_line = lf
66
indent_size = 4
77
indent_style = space
88
insert_final_newline = false
9-
max_line_length = 120
9+
max_line_length = 180
1010
tab_width = 4
1111
ij_continuation_indent_size = 8
1212
ij_formatter_off_tag = @formatter:off
@@ -16,11 +16,11 @@ ij_smart_tabs = false
1616
ij_visual_guides = none
1717
ij_wrap_on_typing = false
1818

19-
[{*.go,*.go2}]
19+
[*.go]
2020
indent_style = tab
2121
ij_continuation_indent_size = 4
22-
ij_go_GROUP_CURRENT_PROJECT_IMPORTS = false
23-
ij_go_add_leading_space_to_comments = false
22+
ij_go_GROUP_CURRENT_PROJECT_IMPORTS = true
23+
ij_go_add_leading_space_to_comments = true
2424
ij_go_add_parentheses_for_single_import = false
2525
ij_go_call_parameters_new_line_after_left_paren = true
2626
ij_go_call_parameters_right_paren_on_new_line = true
@@ -42,6 +42,8 @@ ij_go_wrap_func_params_newline_before_rparen = true
4242
ij_go_wrap_func_result = off
4343
ij_go_wrap_func_result_newline_after_lparen = true
4444
ij_go_wrap_func_result_newline_before_rparen = true
45+
ij_go_local_group_mode = project
46+
ij_go_run_go_fmt_on_reformat = true
4547

4648
[{*.markdown,*.md}]
4749
indent_style = tab

.github/workflows/go.yml

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,40 @@ name: Go
33
on:
44
push:
55
paths:
6-
- '**/*.go'
7-
- '**/go.mod'
8-
- '**/go.sum'
9-
- '.github/workflows/go.yml'
10-
pull_request_target:
11-
paths:
12-
- '**/*.go'
13-
- '**/go.mod'
14-
- '**/go.sum'
15-
- '.github/workflows/go.yml'
6+
- "**/*.go"
7+
- "**/go.mod"
8+
- "**/go.sum"
9+
- ".github/workflows/go.yml"
1610

1711
jobs:
18-
gobuild:
12+
build:
1913
runs-on: ubuntu-latest
2014
steps:
2115
- uses: actions/setup-go@v5
2216
with:
23-
go-version: 1.23
17+
go-version: 1.24
2418
- uses: actions/checkout@v4
2519
- name: go build
2620
run: go build -v ./...
2721

28-
gotest:
22+
test:
2923
runs-on: ubuntu-latest
3024
steps:
3125
- uses: actions/setup-go@v5
3226
with:
33-
go-version: 1.23
27+
go-version: 1.24
3428
- uses: actions/checkout@v4
35-
- name: go build
29+
- name: go test
3630
run: go test -v ./...
3731

3832
golangci:
3933
runs-on: ubuntu-latest
4034
steps:
4135
- uses: actions/setup-go@v5
4236
with:
43-
go-version: 1.23
37+
go-version: 1.24
4438
- uses: actions/checkout@v4
4539
- name: golangci-lint
46-
uses: golangci/golangci-lint-action@v3
40+
uses: golangci/golangci-lint-action@v6
4741
with:
4842
version: latest

_examples/application_commands/gateway/example.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import (
77
"os/signal"
88
"syscall"
99

10+
"github.com/disgoorg/snowflake/v2"
11+
1012
"github.com/disgoorg/disgo"
1113
"github.com/disgoorg/disgo/bot"
1214
"github.com/disgoorg/disgo/discord"
1315
"github.com/disgoorg/disgo/events"
14-
"github.com/disgoorg/snowflake/v2"
1516
)
1617

1718
var (
@@ -53,7 +54,7 @@ func main() {
5354

5455
defer client.Close(context.TODO())
5556

56-
if _, err = client.Rest().SetGuildCommands(client.ApplicationID(), guildID, commands); err != nil {
57+
if _, err = client.Rest.SetGuildCommands(client.ApplicationID, guildID, commands); err != nil {
5758
slog.Error("error while registering commands", slog.Any("err", err))
5859
}
5960

_examples/application_commands/http/example.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import (
77
"os/signal"
88
"syscall"
99

10+
"github.com/disgoorg/snowflake/v2"
11+
"github.com/oasisprotocol/curve25519-voi/primitives/ed25519"
12+
1013
"github.com/disgoorg/disgo"
1114
"github.com/disgoorg/disgo/bot"
1215
"github.com/disgoorg/disgo/discord"
1316
"github.com/disgoorg/disgo/events"
1417
"github.com/disgoorg/disgo/httpserver"
15-
"github.com/disgoorg/snowflake/v2"
16-
"github.com/oasisprotocol/curve25519-voi/primitives/ed25519"
1718
)
1819

1920
var (
@@ -41,19 +42,26 @@ var (
4142
}
4243
)
4344

45+
type customVerifier struct{}
46+
47+
func (customVerifier) Verify(publicKey httpserver.PublicKey, message, sig []byte) bool {
48+
return ed25519.Verify(publicKey, message, sig)
49+
}
50+
51+
func (customVerifier) SignatureSize() int {
52+
return ed25519.SignatureSize
53+
}
54+
4455
func main() {
4556
slog.Info("starting example...")
4657
slog.Info("disgo version", slog.String("version", disgo.Version))
4758

48-
// use custom ed25519 verify implementation
49-
httpserver.Verify = func(publicKey httpserver.PublicKey, message, sig []byte) bool {
50-
return ed25519.Verify(publicKey, message, sig)
51-
}
52-
5359
client, err := disgo.New(token,
5460
bot.WithHTTPServerConfigOpts(publicKey,
5561
httpserver.WithURL("/interactions/callback"),
5662
httpserver.WithAddress(":80"),
63+
// use custom ed25519 verify implementation
64+
httpserver.WithVerifier(customVerifier{}),
5765
),
5866
bot.WithEventListenerFunc(commandListener),
5967
)
@@ -63,7 +71,7 @@ func main() {
6371

6472
defer client.Close(context.TODO())
6573

66-
if _, err = client.Rest().SetGuildCommands(client.ApplicationID(), guildID, commands); err != nil {
74+
if _, err = client.Rest.SetGuildCommands(client.ApplicationID, guildID, commands); err != nil {
6775
panic("error while registering commands: " + err.Error())
6876
}
6977

@@ -85,7 +93,7 @@ func commandListener(event *events.ApplicationCommandInteractionCreate) {
8593
SetEphemeral(data.Bool("ephemeral")).
8694
Build(),
8795
); err != nil {
88-
event.Client().Logger().Error("error on sending response", slog.Any("err", err))
96+
event.Client().Logger.Error("error on sending response", slog.Any("err", err))
8997
}
9098
}
9199
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
module github.com/disgoorg/disgo/_examples/application_commands/http
22

3-
go 1.21
3+
go 1.24
44

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

77
require (
8-
github.com/disgoorg/disgo v0.18.11
8+
github.com/disgoorg/disgo v0.18.15
99
github.com/disgoorg/snowflake/v2 v2.0.3
1010
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a
1111
)
1212

1313
require (
14-
github.com/disgoorg/json v1.2.0 // indirect
14+
github.com/disgoorg/json/v2 v2.0.0 // indirect
15+
github.com/disgoorg/omit v1.0.0 // indirect
1516
github.com/gorilla/websocket v1.5.3 // indirect
1617
github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad // indirect
17-
golang.org/x/crypto v0.27.0 // indirect
18-
golang.org/x/sys v0.25.0 // indirect
18+
golang.org/x/crypto v0.37.0 // indirect
19+
golang.org/x/sys v0.32.0 // indirect
1920
)
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
22
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3-
github.com/disgoorg/json v1.2.0 h1:6e/j4BCfSHIvucG1cd7tJPAOp1RgnnMFSqkvZUtEd1Y=
4-
github.com/disgoorg/json v1.2.0/go.mod h1:BHDwdde0rpQFDVsRLKhma6Y7fTbQKub/zdGO5O9NqqA=
3+
github.com/disgoorg/json/v2 v2.0.0 h1:U16yy/ARK7/aEpzjjqK1b/KaqqGHozUdeVw/DViEzQI=
4+
github.com/disgoorg/json/v2 v2.0.0/go.mod h1:jZTBC0nIE1WeetSEI3/Dka8g+qglb4FPVmp5I5HpEfI=
5+
github.com/disgoorg/omit v1.0.0 h1:y0LkVUOyUHT8ZlnhIAeOZEA22UYykeysK8bLJ0SfT78=
6+
github.com/disgoorg/omit v1.0.0/go.mod h1:RTmSARkf6PWT/UckwI0bV8XgWkWQoPppaT01rYKLcFQ=
57
github.com/disgoorg/snowflake/v2 v2.0.3 h1:3B+PpFjr7j4ad7oeJu4RlQ+nYOTadsKapJIzgvSI2Ro=
68
github.com/disgoorg/snowflake/v2 v2.0.3/go.mod h1:W6r7NUA7DwfZLwr00km6G4UnZ0zcoLBRufhkFWgAc4c=
79
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
@@ -12,11 +14,11 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
1214
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1315
github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad h1:qIQkSlF5vAUHxEmTbaqt1hkJ/t6skqEGYiMag343ucI=
1416
github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad/go.mod h1:/pA7k3zsXKdjjAiUhB5CjuKib9KJGCaLvZwtxGC8U0s=
15-
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
16-
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
17-
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
18-
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
19-
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
20-
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
17+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
18+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
19+
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
20+
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
21+
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
22+
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
2123
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
2224
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

_examples/application_commands/localization/example.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import (
77
"os/signal"
88
"syscall"
99

10+
"github.com/disgoorg/snowflake/v2"
11+
1012
"github.com/disgoorg/disgo"
1113
"github.com/disgoorg/disgo/bot"
1214
"github.com/disgoorg/disgo/discord"
1315
"github.com/disgoorg/disgo/events"
14-
"github.com/disgoorg/snowflake/v2"
1516
)
1617

1718
var (
@@ -76,7 +77,7 @@ func main() {
7677

7778
defer client.Close(context.TODO())
7879

79-
if _, err = client.Rest().SetGuildCommands(client.ApplicationID(), guildID, commands); err != nil {
80+
if _, err = client.Rest.SetGuildCommands(client.ApplicationID, guildID, commands); err != nil {
8081
panic("error while registering commands: " + err.Error())
8182
}
8283

@@ -99,7 +100,7 @@ func commandListener(event *events.ApplicationCommandInteractionCreate) {
99100
Build(),
100101
)
101102
if err != nil {
102-
event.Client().Logger().Error("error on sending response", slog.Any("err", err))
103+
event.Client().Logger.Error("error on sending response", slog.Any("err", err))
103104
}
104105
}
105106
}

_examples/auto_moderation/example.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ import (
99
"syscall"
1010
"time"
1111

12+
"github.com/disgoorg/omit"
13+
"github.com/disgoorg/snowflake/v2"
14+
1215
"github.com/disgoorg/disgo"
1316
"github.com/disgoorg/disgo/bot"
1417
"github.com/disgoorg/disgo/discord"
1518
"github.com/disgoorg/disgo/events"
1619
"github.com/disgoorg/disgo/gateway"
17-
"github.com/disgoorg/json"
18-
"github.com/disgoorg/snowflake/v2"
1920
)
2021

2122
var (
@@ -64,8 +65,8 @@ func main() {
6465
<-s
6566
}
6667

67-
func showCaseAutoMod(client bot.Client) {
68-
rule, err := client.Rest().CreateAutoModerationRule(guildID, discord.AutoModerationRuleCreate{
68+
func showCaseAutoMod(client *bot.Client) {
69+
rule, err := client.Rest.CreateAutoModerationRule(guildID, discord.AutoModerationRuleCreate{
6970
Name: "test-rule",
7071
EventType: discord.AutoModerationEventTypeMessageSend,
7172
TriggerType: discord.AutoModerationTriggerTypeKeyword,
@@ -83,7 +84,7 @@ func showCaseAutoMod(client bot.Client) {
8384
Type: discord.AutoModerationActionTypeBlockMessage,
8485
},
8586
},
86-
Enabled: json.Ptr(true),
87+
Enabled: omit.Ptr(true),
8788
})
8889
if err != nil {
8990
slog.Error("error while creating rule", slog.Any("err", err))
@@ -92,8 +93,8 @@ func showCaseAutoMod(client bot.Client) {
9293

9394
time.Sleep(time.Second * 10)
9495

95-
rule, err = client.Rest().UpdateAutoModerationRule(guildID, rule.ID, discord.AutoModerationRuleUpdate{
96-
Name: json.Ptr("test-rule-updated"),
96+
rule, err = client.Rest.UpdateAutoModerationRule(guildID, rule.ID, discord.AutoModerationRuleUpdate{
97+
Name: omit.Ptr("test-rule-updated"),
9798
TriggerMetadata: &discord.AutoModerationTriggerMetadata{
9899
KeywordFilter: []string{"*test2*"},
99100
},
@@ -113,7 +114,7 @@ func showCaseAutoMod(client bot.Client) {
113114

114115
time.Sleep(time.Second * 10)
115116

116-
err = client.Rest().DeleteAutoModerationRule(guildID, rule.ID)
117+
err = client.Rest.DeleteAutoModerationRule(guildID, rule.ID)
117118
if err != nil {
118119
slog.Error("error while deleting rule", slog.Any("err", err))
119120
return

_examples/components/example.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func main() {
2929
return
3030
}
3131
if event.Message.Content == "test" {
32-
_, _ = event.Client().Rest().CreateMessage(event.ChannelID, discord.NewMessageCreateBuilder().
32+
_, _ = event.Client().Rest.CreateMessage(event.ChannelID, discord.NewMessageCreateBuilder().
3333
AddActionRow(discord.NewDangerButton("danger", "danger")).
3434
SetMessageReferenceByID(event.Message.ID).
3535
Build(),

0 commit comments

Comments
 (0)