@@ -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
1920var (
@@ -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+
4455func 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}
0 commit comments