Merge branch 'plugin-system'

This commit is contained in:
2024-04-14 21:00:25 +02:00
21 changed files with 194 additions and 41 deletions

5
.gitignore vendored
View File

@@ -1,5 +1,4 @@
.env .env
data.json
# Building # Building
acecore acecore
@@ -9,6 +8,8 @@ acecore
logs/ logs/
# Web # Web
web/key.pem web/key.pem
web/cert.pem web/cert.pem
# Custom plugins
plugins/

View File

@@ -11,9 +11,10 @@ import (
"github.com/disgoorg/disgo/events" "github.com/disgoorg/disgo/events"
"github.com/disgoorg/json" "github.com/disgoorg/json"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vaporvee/acecore/struct_cmd"
) )
var cmd_addemoji Command = Command{ var cmd_addemoji struct_cmd.Command = struct_cmd.Command{
Definition: discord.SlashCommandCreate{ Definition: discord.SlashCommandCreate{
Name: "add-emoji", Name: "add-emoji",
Description: "Add an external emoji directly to the server.", Description: "Add an external emoji directly to the server.",

View File

@@ -5,9 +5,10 @@ import (
"github.com/disgoorg/disgo/events" "github.com/disgoorg/disgo/events"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vaporvee/acecore/custom" "github.com/vaporvee/acecore/custom"
"github.com/vaporvee/acecore/struct_cmd"
) )
var cmd_ask = Command{ var cmd_ask = struct_cmd.Command{
Definition: discord.SlashCommandCreate{ Definition: discord.SlashCommandCreate{
Name: "ask", Name: "ask",
Description: "Ask anything and get a gif as response!", Description: "Ask anything and get a gif as response!",

View File

@@ -5,9 +5,10 @@ import (
"github.com/disgoorg/disgo/events" "github.com/disgoorg/disgo/events"
"github.com/disgoorg/json" "github.com/disgoorg/json"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vaporvee/acecore/struct_cmd"
) )
var cmd_autojoinroles Command = Command{ var cmd_autojoinroles struct_cmd.Command = struct_cmd.Command{
Definition: discord.SlashCommandCreate{ Definition: discord.SlashCommandCreate{
Name: "autojoinroles", Name: "autojoinroles",
Description: "Give users a role when they join", Description: "Give users a role when they join",

View File

@@ -5,9 +5,10 @@ import (
"github.com/disgoorg/disgo/events" "github.com/disgoorg/disgo/events"
"github.com/disgoorg/json" "github.com/disgoorg/json"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vaporvee/acecore/struct_cmd"
) )
var cmd_autopublish Command = Command{ var cmd_autopublish struct_cmd.Command = struct_cmd.Command{
Definition: discord.SlashCommandCreate{ Definition: discord.SlashCommandCreate{
Name: "autopublish", Name: "autopublish",
Description: "Toggle automatically publishing every post in a announcement channel", Description: "Toggle automatically publishing every post in a announcement channel",

View File

@@ -5,9 +5,10 @@ import (
"github.com/disgoorg/disgo/events" "github.com/disgoorg/disgo/events"
"github.com/disgoorg/json" "github.com/disgoorg/json"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vaporvee/acecore/struct_cmd"
) )
var cmd_blockpolls Command = Command{ var cmd_blockpolls struct_cmd.Command = struct_cmd.Command{
Definition: discord.SlashCommandCreate{ Definition: discord.SlashCommandCreate{
Name: "block-polls", Name: "block-polls",
Description: "Block polls from beeing posted in this channel.", Description: "Block polls from beeing posted in this channel.",

View File

@@ -9,9 +9,10 @@ import (
"github.com/disgoorg/disgo/events" "github.com/disgoorg/disgo/events"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vaporvee/acecore/custom" "github.com/vaporvee/acecore/custom"
"github.com/vaporvee/acecore/struct_cmd"
) )
var cmd_cat = Command{ var cmd_cat = struct_cmd.Command{
Definition: discord.SlashCommandCreate{ Definition: discord.SlashCommandCreate{
Name: "cat", Name: "cat",
Description: "Random cat pictures", Description: "Random cat pictures",

View File

@@ -4,9 +4,10 @@ import (
"github.com/disgoorg/disgo/discord" "github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/events" "github.com/disgoorg/disgo/events"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vaporvee/acecore/struct_cmd"
) )
var cmd_dadjoke = Command{ var cmd_dadjoke = struct_cmd.Command{
Definition: discord.SlashCommandCreate{ Definition: discord.SlashCommandCreate{
Name: "dadjoke", Name: "dadjoke",
Description: "Gives you a random joke that is as bad as your dad would tell them", Description: "Gives you a random joke that is as bad as your dad would tell them",

View File

@@ -13,9 +13,10 @@ import (
"github.com/google/uuid" "github.com/google/uuid"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vaporvee/acecore/custom" "github.com/vaporvee/acecore/custom"
"github.com/vaporvee/acecore/struct_cmd"
) )
var cmd_form Command = Command{ var cmd_form struct_cmd.Command = struct_cmd.Command{
Definition: discord.SlashCommandCreate{ Definition: discord.SlashCommandCreate{
Name: "form", Name: "form",
DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageChannels), DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageChannels),
@@ -334,7 +335,7 @@ var cmd_form Command = Command{
}, },
} }
var cmd_ticket_form Command = Command{ var cmd_ticket_form struct_cmd.Command = struct_cmd.Command{
Definition: discord.SlashCommandCreate{ Definition: discord.SlashCommandCreate{
Name: "ticket", Name: "ticket",
DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageChannels), DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageChannels),

View File

@@ -9,6 +9,7 @@ import (
"github.com/disgoorg/disgo/events" "github.com/disgoorg/disgo/events"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vaporvee/acecore/custom" "github.com/vaporvee/acecore/custom"
"github.com/vaporvee/acecore/struct_cmd"
) )
type UserExtend struct { type UserExtend struct {
@@ -39,7 +40,7 @@ var userFlagsString map[discord.UserFlags]string = map[discord.UserFlags]string{
discord.UserFlagActiveDeveloper: "<:Active_Developer:1224708676611215380>[`Active Developer`](https://support-dev.discord.com/hc/en-us/articles/10113997751447?ref=badge)", discord.UserFlagActiveDeveloper: "<:Active_Developer:1224708676611215380>[`Active Developer`](https://support-dev.discord.com/hc/en-us/articles/10113997751447?ref=badge)",
} }
var cmd_userinfo Command = Command{ var cmd_userinfo struct_cmd.Command = struct_cmd.Command{
Definition: discord.SlashCommandCreate{ Definition: discord.SlashCommandCreate{
Name: "info", Name: "info",
Description: "Gives you information about a user or this bot.", Description: "Gives you information about a user or this bot.",

View File

@@ -9,9 +9,10 @@ import (
"github.com/disgoorg/disgo/events" "github.com/disgoorg/disgo/events"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vaporvee/acecore/custom" "github.com/vaporvee/acecore/custom"
"github.com/vaporvee/acecore/struct_cmd"
) )
var cmd_ping Command = Command{ var cmd_ping struct_cmd.Command = struct_cmd.Command{
Definition: discord.SlashCommandCreate{ Definition: discord.SlashCommandCreate{
Name: "ping", Name: "ping",
Description: "Returns the ping of the bot", Description: "Returns the ping of the bot",

View File

@@ -7,9 +7,10 @@ import (
"github.com/disgoorg/snowflake/v2" "github.com/disgoorg/snowflake/v2"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vaporvee/acecore/custom" "github.com/vaporvee/acecore/custom"
"github.com/vaporvee/acecore/struct_cmd"
) )
var cmd_sticky Command = Command{ var cmd_sticky struct_cmd.Command = struct_cmd.Command{
Definition: discord.SlashCommandCreate{ Definition: discord.SlashCommandCreate{
Name: "sticky", Name: "sticky",
Description: "Stick or unstick messages to the bottom of the current channel", Description: "Stick or unstick messages to the bottom of the current channel",
@@ -55,7 +56,7 @@ var cmd_sticky Command = Command{
}, },
} }
var context_sticky Command = Command{ var context_sticky struct_cmd.Command = struct_cmd.Command{
Definition: discord.MessageCommandCreate{ Definition: discord.MessageCommandCreate{
Name: "Stick to channel", Name: "Stick to channel",
DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageMessages), DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageMessages),

View File

@@ -5,10 +5,11 @@ import (
"github.com/disgoorg/disgo/events" "github.com/disgoorg/disgo/events"
"github.com/disgoorg/json" "github.com/disgoorg/json"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vaporvee/acecore/struct_cmd"
) )
// TODO: make user installable tag command using userIDs instead of guildIDs // TODO: make user installable tag command using userIDs instead of guildIDs
var cmd_tag Command = Command{ var cmd_tag struct_cmd.Command = struct_cmd.Command{
Definition: discord.SlashCommandCreate{ Definition: discord.SlashCommandCreate{
Name: "tag", Name: "tag",
DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageGuild), DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageGuild),
@@ -82,7 +83,7 @@ var cmd_tag Command = Command{
}, },
} }
var cmd_tag_short Command = Command{ var cmd_tag_short struct_cmd.Command = struct_cmd.Command{
Definition: discord.SlashCommandCreate{ Definition: discord.SlashCommandCreate{
Name: "g", Name: "g",
Description: "A short command to get presaved messages.", Description: "A short command to get presaved messages.",
@@ -108,7 +109,7 @@ var cmd_tag_short Command = Command{
}, },
} }
var context_tag Command = Command{ var context_tag struct_cmd.Command = struct_cmd.Command{
Definition: discord.MessageCommandCreate{ Definition: discord.MessageCommandCreate{
Name: "Save as tag", Name: "Save as tag",
DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageGuild), DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageGuild),

5
go.mod
View File

@@ -1,6 +1,6 @@
module github.com/vaporvee/acecore module github.com/vaporvee/acecore
go 1.21.6 go 1.22.1
require ( require (
github.com/disgoorg/disgo v0.18.2 github.com/disgoorg/disgo v0.18.2
@@ -15,9 +15,10 @@ require (
require ( require (
github.com/gorilla/websocket v1.5.1 // indirect github.com/gorilla/websocket v1.5.1 // indirect
github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad // indirect github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad // indirect
github.com/vaporvee/acecore/struct_cmd v0.0.0-00010101000000-000000000000
golang.org/x/crypto v0.19.0 // indirect golang.org/x/crypto v0.19.0 // indirect
golang.org/x/net v0.21.0 // indirect golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect golang.org/x/sys v0.17.0 // indirect
) )
replace github.com/vaporvee/acecore/custom => ./custom replace github.com/vaporvee/acecore/struct_cmd => ./struct_cmd

6
go.sum
View File

@@ -1,12 +1,6 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/disgoorg/disgo v0.18.1-0.20240408224120-2676e29d6e86 h1:hSRIjnKWL07TYxvZRxdSBpS78gJNf+JkAuzXY3O1Kos=
github.com/disgoorg/disgo v0.18.1-0.20240408224120-2676e29d6e86/go.mod h1:gkl6DBdbKUvmOOJayWPSvS52KPN/8uJGJ2f13gCEB1o=
github.com/disgoorg/disgo v0.18.1 h1:8g3ifRVlbdZ28bX2BAVkb04dvQnnRMwN89KUkclaniw=
github.com/disgoorg/disgo v0.18.1/go.mod h1:gkl6DBdbKUvmOOJayWPSvS52KPN/8uJGJ2f13gCEB1o=
github.com/disgoorg/disgo v0.18.2-0.20240412120702-1c2e34f76c43 h1:ADoIkRUNXQPAuafuA3SZZvxPxWUK5rXSgNTmODXXgoI=
github.com/disgoorg/disgo v0.18.2-0.20240412120702-1c2e34f76c43/go.mod h1:gkl6DBdbKUvmOOJayWPSvS52KPN/8uJGJ2f13gCEB1o=
github.com/disgoorg/disgo v0.18.2 h1:pZCvaFamfHcnXrj0XA73qtVofP0R8dYEyQfPNgv8dLE= github.com/disgoorg/disgo v0.18.2 h1:pZCvaFamfHcnXrj0XA73qtVofP0R8dYEyQfPNgv8dLE=
github.com/disgoorg/disgo v0.18.2/go.mod h1:gkl6DBdbKUvmOOJayWPSvS52KPN/8uJGJ2f13gCEB1o= github.com/disgoorg/disgo v0.18.2/go.mod h1:gkl6DBdbKUvmOOJayWPSvS52KPN/8uJGJ2f13gCEB1o=
github.com/disgoorg/json v1.1.0 h1:7xigHvomlVA9PQw9bMGO02PHGJJPqvX5AnwlYg/Tnys= github.com/disgoorg/json v1.1.0 h1:7xigHvomlVA9PQw9bMGO02PHGJJPqvX5AnwlYg/Tnys=

View File

@@ -3,6 +3,9 @@ package main
import ( import (
"fmt" "fmt"
"os" "os"
"path/filepath"
"plugin"
"runtime"
"slices" "slices"
"strings" "strings"
@@ -12,26 +15,19 @@ import (
"github.com/disgoorg/snowflake/v2" "github.com/disgoorg/snowflake/v2"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vaporvee/acecore/custom" "github.com/vaporvee/acecore/custom"
"github.com/vaporvee/acecore/struct_cmd"
) )
type Command struct { var commands []struct_cmd.Command = []struct_cmd.Command{cmd_tag, cmd_tag_short, context_tag, cmd_sticky, context_sticky, cmd_ping, cmd_userinfo, cmd_addemoji, cmd_form, cmd_ask, cmd_cat, cmd_dadjoke, cmd_ticket_form, cmd_blockpolls, cmd_autopublish, cmd_autojoinroles}
Definition discord.ApplicationCommandCreate
Interact func(e *events.ApplicationCommandInteractionCreate)
Autocomplete func(e *events.AutocompleteInteractionCreate)
ComponentInteract func(e *events.ComponentInteractionCreate)
ModalSubmit func(e *events.ModalSubmitInteractionCreate)
ComponentIDs []string
ModalIDs []string
DynamicModalIDs func() []string
DynamicComponentIDs func() []string
}
var commands []Command = []Command{cmd_tag, cmd_tag_short, context_tag, cmd_sticky, context_sticky, cmd_ping, cmd_userinfo, cmd_addemoji, cmd_form, cmd_ask, cmd_cat, cmd_dadjoke, cmd_ticket_form, cmd_blockpolls, cmd_autopublish, cmd_autojoinroles}
func ready(e *events.Ready) { func ready(e *events.Ready) {
logrus.Info("Starting up...") logrus.Info("Starting up...")
findAndDeleteUnusedMessages(e.Client()) findAndDeleteUnusedMessages(e.Client())
removeOldCommandFromAllGuilds(e.Client()) removeOldCommandFromAllGuilds(e.Client())
err := loadPlugins("plugins/", e)
if err != nil {
logrus.Error(err)
}
var existingCommandNames []string var existingCommandNames []string
existingCommands, err := e.Client().Rest().GetGlobalCommands(e.Client().ApplicationID(), false) existingCommands, err := e.Client().Rest().GetGlobalCommands(e.Client().ApplicationID(), false)
if err != nil { if err != nil {
@@ -60,6 +56,70 @@ func ready(e *events.Ready) {
logrus.Info("Successfully started the Bot!") logrus.Info("Successfully started the Bot!")
} }
func loadPlugins(directory string, e *events.Ready) error {
files, err := os.ReadDir(directory)
if err != nil {
return err
}
// Determine the appropriate file extension for dynamic libraries
var ext string
switch runtime.GOOS {
case "windows":
ext = ".dll"
case "linux":
ext = ".so"
case "darwin":
ext = ".dylib"
default:
return fmt.Errorf("unsupported operating system: %s", runtime.GOOS)
}
for _, file := range files {
if filepath.Ext(file.Name()) == ext {
p, err := plugin.Open(filepath.Join(directory, file.Name()))
if err != nil {
return err
}
symPlugin, err := p.Lookup("Plugin")
if err != nil {
logrus.Errorf("Error looking up symbol 'Plugin' in %s: %v", file.Name(), err)
continue
}
pluginPtr, ok := symPlugin.(**struct_cmd.Plugin)
if !ok {
logrus.Errorf("Plugin does not match expected type")
continue
}
plugin := *pluginPtr
if plugin.Name == "" {
logrus.Warn("Plugin is unnamed")
}
if plugin.Commands != nil {
commands = append(commands, plugin.Commands...)
} else {
logrus.Errorf("Plugin %s has no commands set", plugin.Name)
continue
}
if plugin.Register != nil {
err = plugin.Register(e)
if err == nil {
logrus.Infof("Successfully appended plugin %s for registration", plugin.Name)
} else {
logrus.Errorf("Error registering plugin %s commands: %v", plugin.Name, err)
continue
}
}
}
}
return nil
}
func applicationCommandInteractionCreate(e *events.ApplicationCommandInteractionCreate) { func applicationCommandInteractionCreate(e *events.ApplicationCommandInteractionCreate) {
for _, command := range commands { for _, command := range commands {
if command.Interact != nil && e.Data.CommandName() == command.Definition.CommandName() { if command.Interact != nil && e.Data.CommandName() == command.Definition.CommandName() {

15
struct_cmd/go.mod Normal file
View File

@@ -0,0 +1,15 @@
module struct_cmd
go 1.22.1
require github.com/disgoorg/disgo v0.18.2
require (
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.19.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
)

24
struct_cmd/go.sum Normal file
View File

@@ -0,0 +1,24 @@
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=
github.com/disgoorg/disgo v0.18.2 h1:pZCvaFamfHcnXrj0XA73qtVofP0R8dYEyQfPNgv8dLE=
github.com/disgoorg/disgo v0.18.2/go.mod h1:gkl6DBdbKUvmOOJayWPSvS52KPN/8uJGJ2f13gCEB1o=
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/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.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
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.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.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=

24
struct_cmd/main.go Normal file
View File

@@ -0,0 +1,24 @@
package struct_cmd
import (
"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/events"
)
type Command struct {
Definition discord.ApplicationCommandCreate
Interact func(e *events.ApplicationCommandInteractionCreate)
Autocomplete func(e *events.AutocompleteInteractionCreate)
ComponentInteract func(e *events.ComponentInteractionCreate)
ModalSubmit func(e *events.ModalSubmitInteractionCreate)
ComponentIDs []string
ModalIDs []string
DynamicModalIDs func() []string
DynamicComponentIDs func() []string
}
type Plugin struct {
Name string
Commands []Command
Register func(e *events.Ready) error
}

22
testplugin/main.go Normal file
View File

@@ -0,0 +1,22 @@
package main
import (
"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/events"
"github.com/vaporvee/acecore/struct_cmd"
)
var Plugin = &struct_cmd.Plugin{
Name: "testplugin",
Commands: []struct_cmd.Command{
{
Definition: discord.SlashCommandCreate{
Name: "testplugincommand",
Description: "Tesing if plugins work",
},
Interact: func(e *events.ApplicationCommandInteractionCreate) {
e.CreateMessage(discord.NewMessageCreateBuilder().SetContent("Plugins are working!").SetEphemeral(true).Build())
},
},
},
}

View File

@@ -43,7 +43,7 @@
services. services.
</li> </li>
<li> <li>
Command usage: We store data about some commands that you use within struct_cmd.Command usage: We store data about some commands that you use within
acecore in order to make the commands usable and functioning. acecore in order to make the commands usable and functioning.
</li> </li>
<li> <li>