-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into patch/role-subscriptions
- Loading branch information
Showing
179 changed files
with
3,287 additions
and
1,247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
.idea/ | ||
.env | ||
go.work | ||
go.work.sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,24 @@ | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/disgoorg/json v1.0.0 h1:kDhSM661fgIuNoZF3BO5/odaR5NSq80AWb937DH+Pdo= | ||
github.com/disgoorg/json v1.0.0/go.mod h1:BHDwdde0rpQFDVsRLKhma6Y7fTbQKub/zdGO5O9NqqA= | ||
github.com/disgoorg/log v1.2.0 h1:sqlXnu/ZKAlIlHV9IO+dbMto7/hCQ474vlIdMWk8QKo= | ||
github.com/disgoorg/log v1.2.0/go.mod h1:3x1KDG6DI1CE2pDwi3qlwT3wlXpeHW/5rVay+1qDqOo= | ||
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-20220317090546-adb2f9614b17 h1:pxR+aWfo+famermIZvD+SiDQ3qmF7Iy2VPZuEsKTMtA= | ||
github.com/oasisprotocol/curve25519-voi v0.0.0-20220317090546-adb2f9614b17/go.mod h1:WUcXjUd98qaCVFb6j8Xc87MsKeMCXDu9Nk8JRJ9SeC8= | ||
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/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.0.0-20210813211128-0a44fdfbc16e h1:VvfwVmMH40bpMeizC9/K7ipM5Qjucuu16RWfneFPyhQ= | ||
golang.org/x/crypto v0.0.0-20210813211128-0a44fdfbc16e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= | ||
golang.org/x/exp v0.0.0-20220325121720-054d8573a5d8 h1:Xt4/LzbTwfocTk9ZLEu4onjeFucl88iW+v4j4PWbQuE= | ||
golang.org/x/exp v0.0.0-20220325121720-054d8573a5d8/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= | ||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= | ||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0= | ||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | ||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||
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= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"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/disgo/handler" | ||
"github.com/disgoorg/disgo/handler/middleware" | ||
) | ||
|
||
var ( | ||
token = os.Getenv("disgo_token") | ||
guildID = snowflake.GetEnv("disgo_guild_id") | ||
|
||
commands = []discord.ApplicationCommandCreate{ | ||
discord.SlashCommandCreate{ | ||
Name: "ping", | ||
Description: "Replies with pong", | ||
}, | ||
discord.SlashCommandCreate{ | ||
Name: "test", | ||
Description: "Replies with test", | ||
Options: []discord.ApplicationCommandOption{ | ||
discord.ApplicationCommandOptionSubCommandGroup{ | ||
Name: "idk", | ||
Description: "Group command", | ||
Options: []discord.ApplicationCommandOptionSubCommand{ | ||
{ | ||
Name: "sub", | ||
Description: "Sub command", | ||
}, | ||
}, | ||
}, | ||
discord.ApplicationCommandOptionSubCommandGroup{ | ||
Name: "idk2", | ||
Description: "Group2 command", | ||
Options: []discord.ApplicationCommandOptionSubCommand{ | ||
{ | ||
Name: "sub", | ||
Description: "Sub command", | ||
}, | ||
}, | ||
}, | ||
discord.ApplicationCommandOptionSubCommand{ | ||
Name: "sub2", | ||
Description: "Sub2 command", | ||
}, | ||
}, | ||
}, | ||
discord.SlashCommandCreate{ | ||
Name: "ping2", | ||
Description: "Replies with pong2", | ||
}, | ||
} | ||
) | ||
|
||
func main() { | ||
log.SetLevel(log.LevelInfo) | ||
log.Info("starting example...") | ||
log.Infof("disgo version: %s", disgo.Version) | ||
|
||
r := handler.New() | ||
r.Use(middleware.Logger) | ||
r.Group(func(r handler.Router) { | ||
r.Use(middleware.Print("group1")) | ||
r.Route("/test", func(r handler.Router) { | ||
r.Command("/sub2", handleContent("/test/sub2")) | ||
r.Route("/{group}", func(r handler.Router) { | ||
r.Command("/sub", handleVariableContent) | ||
}) | ||
}) | ||
}) | ||
r.Group(func(r handler.Router) { | ||
r.Use(middleware.Print("group2")) | ||
r.Command("/ping", handlePing) | ||
r.Command("/ping2", handleContent("pong2")) | ||
r.Component("button1/{data}", handleComponent) | ||
}) | ||
r.NotFound(handleNotFound) | ||
|
||
client, err := disgo.New(token, | ||
bot.WithDefaultGateway(), | ||
bot.WithEventListeners(r), | ||
) | ||
if err != nil { | ||
log.Fatal("error while building bot: ", err) | ||
} | ||
|
||
if err = handler.SyncCommands(client, commands, []snowflake.ID{guildID}); err != nil { | ||
log.Fatal("error while syncing commands: ", err) | ||
} | ||
|
||
defer client.Close(context.TODO()) | ||
|
||
if err = client.OpenGateway(context.TODO()); err != nil { | ||
log.Fatal("error while connecting to gateway: ", err) | ||
} | ||
|
||
log.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 | ||
} | ||
|
||
func handleContent(content string) handler.CommandHandler { | ||
return func(event *handler.CommandEvent) error { | ||
return event.CreateMessage(discord.MessageCreate{Content: content}) | ||
} | ||
} | ||
|
||
func handleVariableContent(event *handler.CommandEvent) error { | ||
group := event.Variables["group"] | ||
return event.CreateMessage(discord.MessageCreate{Content: "group: " + group}) | ||
} | ||
|
||
func handlePing(event *handler.CommandEvent) error { | ||
return event.CreateMessage(discord.MessageCreate{ | ||
Content: "pong", | ||
Components: []discord.ContainerComponent{ | ||
discord.ActionRowComponent{ | ||
discord.NewPrimaryButton("button1", "button1/testData"), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func handleComponent(event *handler.ComponentEvent) error { | ||
data := event.Variables["data"] | ||
return event.CreateMessage(discord.MessageCreate{Content: "component: " + data}) | ||
} | ||
|
||
func handleNotFound(event *events.InteractionCreate) error { | ||
return event.Respond(discord.InteractionResponseTypeCreateMessage, discord.MessageCreate{Content: "not found"}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.