reimplemented tag comment with disgo
This commit is contained in:
33
cmd_tag.go
33
cmd_tag.go
@@ -130,6 +130,8 @@ func AddTagCommand(e *events.ApplicationCommandInteractionCreate, prevalue strin
|
||||
MaxLength: 20,
|
||||
Value: "",
|
||||
},
|
||||
},
|
||||
discord.ActionRowComponent{
|
||||
discord.TextInputComponent{
|
||||
CustomID: "tag_add_modal_content",
|
||||
Label: "Content",
|
||||
@@ -141,37 +143,6 @@ func AddTagCommand(e *events.ApplicationCommandInteractionCreate, prevalue strin
|
||||
},
|
||||
},
|
||||
})
|
||||
/*Data: &discordgo.InteractionResponseData{
|
||||
CustomID: "tag_add_modal" + i.Interaction.Member.User.ID,
|
||||
Title: "Add a custom tag command",
|
||||
Components: []discordgo.MessageComponent{
|
||||
discordgo.ActionsRow{
|
||||
Components: []discordgo.MessageComponent{
|
||||
discordgo.TextInput{
|
||||
CustomID: "tag_add_modal_name",
|
||||
Label: "Name",
|
||||
Style: discordgo.TextInputShort,
|
||||
Required: true,
|
||||
MaxLength: 20,
|
||||
Value: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
discordgo.ActionsRow{
|
||||
Components: []discordgo.MessageComponent{
|
||||
discordgo.TextInput{
|
||||
CustomID: "tag_add_modal_content",
|
||||
Label: "Content",
|
||||
Placeholder: "Content that gets returned when the tag will be run",
|
||||
Style: discordgo.TextInputParagraph,
|
||||
Required: true,
|
||||
MaxLength: 2000,
|
||||
Value: prevalue,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},*/
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
|
7
go.mod
7
go.mod
@@ -3,7 +3,9 @@ module github.com/vaporvee/acecore
|
||||
go 1.21.6
|
||||
|
||||
require (
|
||||
github.com/bwmarrin/discordgo v0.27.1
|
||||
github.com/disgoorg/disgo v0.17.2
|
||||
github.com/disgoorg/json v1.1.0
|
||||
github.com/disgoorg/snowflake/v2 v2.0.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/lib/pq v1.10.9
|
||||
@@ -11,9 +13,6 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/disgoorg/disgo v0.17.2 // indirect
|
||||
github.com/disgoorg/json v1.1.0 // indirect
|
||||
github.com/disgoorg/snowflake/v2 v2.0.1 // indirect
|
||||
github.com/gorilla/websocket v1.5.1 // indirect
|
||||
github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad // indirect
|
||||
golang.org/x/crypto v0.18.0 // indirect
|
||||
|
16
go.sum
16
go.sum
@@ -1,5 +1,3 @@
|
||||
github.com/bwmarrin/discordgo v0.27.1 h1:ib9AIc/dom1E/fSIulrBwnez0CToJE113ZGt4HoliGY=
|
||||
github.com/bwmarrin/discordgo v0.27.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@@ -11,8 +9,6 @@ github.com/disgoorg/snowflake/v2 v2.0.1 h1:CuUxGLwggUxEswZOmZ+mZ5i0xSumQdXW9tXW7
|
||||
github.com/disgoorg/snowflake/v2 v2.0.1/go.mod h1:SPU9c2CNn5DSyb86QcKtdZgix9osEtKrHLW4rMhfLCs=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
|
||||
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
@@ -26,25 +22,17 @@ github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad/go.mod h1:/pA7k3z
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg=
|
||||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
|
||||
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
|
||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
||||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
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=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
28
handlers.go
28
handlers.go
@@ -43,29 +43,27 @@ func ready(e *events.Ready) {
|
||||
}
|
||||
globalCommands := []discord.ApplicationCommandCreate{}
|
||||
for _, command := range commands {
|
||||
if !slices.Contains(existingCommandNames, command.Definition.CommandName()) || slices.Contains(os.Args, "--update="+command.Definition.CommandName()) || slices.Contains(os.Args, "--update=all") || slices.Contains(os.Args, "--clean") {
|
||||
if !slices.Contains(existingCommandNames, command.Definition.CommandName()) || slices.Contains(os.Args, "--update-all") || slices.Contains(os.Args, "--clean") {
|
||||
globalCommands = append(globalCommands, command.Definition)
|
||||
logrus.Infof("Appending command \"%s\"", command.Definition.CommandName())
|
||||
}
|
||||
}
|
||||
logrus.Infof("Attempting to add global commands %s", fmt.Sprint(globalCommands))
|
||||
_, err = e.Client().Rest().SetGlobalCommands(e.Client().ApplicationID(), globalCommands)
|
||||
if err != nil {
|
||||
logrus.Errorf("error creating global commands '%s'", err)
|
||||
} else {
|
||||
logrus.Infof("Added global commands sucessfully!")
|
||||
if len(globalCommands) > 0 {
|
||||
logrus.Infof("Attempting to add global commands %s", fmt.Sprint(globalCommands))
|
||||
_, err = e.Client().Rest().SetGlobalCommands(e.Client().ApplicationID(), globalCommands)
|
||||
if err != nil {
|
||||
logrus.Errorf("error creating global commands '%s'", err)
|
||||
} else {
|
||||
logrus.Infof("Added global commands sucessfully!")
|
||||
}
|
||||
}
|
||||
logrus.Info("Successfully started the Bot!")
|
||||
}
|
||||
|
||||
func applicationCommandInteractionCreate(e *events.ApplicationCommandInteractionCreate) {
|
||||
app, err := e.Client().Rest().GetCurrentApplication()
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
for _, command := range commands {
|
||||
if command.Interact != nil && e.SlashCommandInteractionData().CommandName() == command.Definition.CommandName() {
|
||||
if !command.AllowDM && app.GuildID.String() == "" {
|
||||
if !command.AllowDM && e.ApplicationCommandInteraction.GuildID().String() == "" {
|
||||
e.CreateMessage(discord.NewMessageCreateBuilder().
|
||||
SetContent("This command is not available in DMs.").SetEphemeral(true).
|
||||
Build())
|
||||
@@ -81,7 +79,7 @@ func applicationCommandInteractionCreate(e *events.ApplicationCommandInteraction
|
||||
func autocompleteInteractionCreate(e *events.AutocompleteInteractionCreate) {
|
||||
for _, command := range commands {
|
||||
if command.Autocomplete != nil && e.Data.CommandName == command.Definition.CommandName() {
|
||||
if !command.AllowDM && e.GuildID().String() == "" {
|
||||
if !command.AllowDM && e.AutocompleteInteraction.GuildID().String() == "" {
|
||||
err := e.AutocompleteResult(nil)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
@@ -95,7 +93,7 @@ func autocompleteInteractionCreate(e *events.AutocompleteInteractionCreate) {
|
||||
|
||||
func componentInteractionCreate(e *events.ComponentInteractionCreate) {
|
||||
for _, command := range commands {
|
||||
if !command.AllowDM && e.GuildID().String() == "" {
|
||||
if !command.AllowDM && e.ComponentInteraction.GuildID().String() == "" {
|
||||
e.CreateMessage(discord.NewMessageCreateBuilder().
|
||||
SetContent("This component is not available in DMs.").SetEphemeral(true).
|
||||
Build())
|
||||
@@ -119,7 +117,7 @@ func componentInteractionCreate(e *events.ComponentInteractionCreate) {
|
||||
|
||||
func modalSubmitInteractionCreate(e *events.ModalSubmitInteractionCreate) {
|
||||
for _, command := range commands {
|
||||
if !command.AllowDM && e.GuildID().String() == "" {
|
||||
if !command.AllowDM && e.ModalSubmitInteraction.GuildID().String() == "" {
|
||||
e.CreateMessage(discord.NewMessageCreateBuilder().
|
||||
SetContent("This modal is not available in DMs.").SetEphemeral(true).
|
||||
Build())
|
||||
|
Reference in New Issue
Block a user