made simplefun plugin
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
module struct_cmd
|
||||
module github.com/vaporvee/acecore/cmd
|
||||
|
||||
go 1.22.1
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package struct_cmd
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/disgoorg/disgo/discord"
|
@@ -11,10 +11,10 @@ import (
|
||||
"github.com/disgoorg/disgo/events"
|
||||
"github.com/disgoorg/json"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vaporvee/acecore/struct_cmd"
|
||||
"github.com/vaporvee/acecore/cmd"
|
||||
)
|
||||
|
||||
var cmd_addemoji struct_cmd.Command = struct_cmd.Command{
|
||||
var cmd_addemoji cmd.Command = cmd.Command{
|
||||
Definition: discord.SlashCommandCreate{
|
||||
Name: "add-emoji",
|
||||
Description: "Add an external emoji directly to the server.",
|
||||
|
@@ -5,10 +5,10 @@ import (
|
||||
"github.com/disgoorg/disgo/events"
|
||||
"github.com/disgoorg/json"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vaporvee/acecore/struct_cmd"
|
||||
"github.com/vaporvee/acecore/cmd"
|
||||
)
|
||||
|
||||
var cmd_autojoinroles struct_cmd.Command = struct_cmd.Command{
|
||||
var cmd_autojoinroles cmd.Command = cmd.Command{
|
||||
Definition: discord.SlashCommandCreate{
|
||||
Name: "autojoinroles",
|
||||
Description: "Give users a role when they join",
|
||||
|
@@ -5,10 +5,10 @@ import (
|
||||
"github.com/disgoorg/disgo/events"
|
||||
"github.com/disgoorg/json"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vaporvee/acecore/struct_cmd"
|
||||
"github.com/vaporvee/acecore/cmd"
|
||||
)
|
||||
|
||||
var cmd_autopublish struct_cmd.Command = struct_cmd.Command{
|
||||
var cmd_autopublish cmd.Command = cmd.Command{
|
||||
Definition: discord.SlashCommandCreate{
|
||||
Name: "autopublish",
|
||||
Description: "Toggle automatically publishing every post in a announcement channel",
|
||||
|
@@ -5,10 +5,10 @@ import (
|
||||
"github.com/disgoorg/disgo/events"
|
||||
"github.com/disgoorg/json"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vaporvee/acecore/struct_cmd"
|
||||
"github.com/vaporvee/acecore/cmd"
|
||||
)
|
||||
|
||||
var cmd_blockpolls struct_cmd.Command = struct_cmd.Command{
|
||||
var cmd_blockpolls cmd.Command = cmd.Command{
|
||||
Definition: discord.SlashCommandCreate{
|
||||
Name: "block-polls",
|
||||
Description: "Block polls from beeing posted in this channel.",
|
||||
|
@@ -12,11 +12,11 @@ import (
|
||||
"github.com/disgoorg/snowflake/v2"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vaporvee/acecore/cmd"
|
||||
"github.com/vaporvee/acecore/custom"
|
||||
"github.com/vaporvee/acecore/struct_cmd"
|
||||
)
|
||||
|
||||
var cmd_form struct_cmd.Command = struct_cmd.Command{
|
||||
var cmd_form cmd.Command = cmd.Command{
|
||||
Definition: discord.SlashCommandCreate{
|
||||
Name: "form",
|
||||
DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageChannels),
|
||||
@@ -335,7 +335,7 @@ var cmd_form struct_cmd.Command = struct_cmd.Command{
|
||||
},
|
||||
}
|
||||
|
||||
var cmd_ticket_form struct_cmd.Command = struct_cmd.Command{
|
||||
var cmd_ticket_form cmd.Command = cmd.Command{
|
||||
Definition: discord.SlashCommandCreate{
|
||||
Name: "ticket",
|
||||
DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageChannels),
|
||||
|
@@ -8,8 +8,8 @@ import (
|
||||
"github.com/disgoorg/disgo/discord"
|
||||
"github.com/disgoorg/disgo/events"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vaporvee/acecore/cmd"
|
||||
"github.com/vaporvee/acecore/custom"
|
||||
"github.com/vaporvee/acecore/struct_cmd"
|
||||
)
|
||||
|
||||
type UserExtend struct {
|
||||
@@ -40,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)",
|
||||
}
|
||||
|
||||
var cmd_userinfo struct_cmd.Command = struct_cmd.Command{
|
||||
var cmd_userinfo cmd.Command = cmd.Command{
|
||||
Definition: discord.SlashCommandCreate{
|
||||
Name: "info",
|
||||
Description: "Gives you information about a user or this bot.",
|
||||
|
@@ -8,11 +8,11 @@ import (
|
||||
"github.com/disgoorg/disgo/discord"
|
||||
"github.com/disgoorg/disgo/events"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vaporvee/acecore/cmd"
|
||||
"github.com/vaporvee/acecore/custom"
|
||||
"github.com/vaporvee/acecore/struct_cmd"
|
||||
)
|
||||
|
||||
var cmd_ping struct_cmd.Command = struct_cmd.Command{
|
||||
var cmd_ping cmd.Command = cmd.Command{
|
||||
Definition: discord.SlashCommandCreate{
|
||||
Name: "ping",
|
||||
Description: "Returns the ping of the bot",
|
||||
|
@@ -6,11 +6,11 @@ import (
|
||||
"github.com/disgoorg/json"
|
||||
"github.com/disgoorg/snowflake/v2"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vaporvee/acecore/cmd"
|
||||
"github.com/vaporvee/acecore/custom"
|
||||
"github.com/vaporvee/acecore/struct_cmd"
|
||||
)
|
||||
|
||||
var cmd_sticky struct_cmd.Command = struct_cmd.Command{
|
||||
var cmd_sticky cmd.Command = cmd.Command{
|
||||
Definition: discord.SlashCommandCreate{
|
||||
Name: "sticky",
|
||||
Description: "Stick or unstick messages to the bottom of the current channel",
|
||||
@@ -56,7 +56,7 @@ var cmd_sticky struct_cmd.Command = struct_cmd.Command{
|
||||
},
|
||||
}
|
||||
|
||||
var context_sticky struct_cmd.Command = struct_cmd.Command{
|
||||
var context_sticky cmd.Command = cmd.Command{
|
||||
Definition: discord.MessageCommandCreate{
|
||||
Name: "Stick to channel",
|
||||
DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageMessages),
|
||||
|
@@ -5,11 +5,11 @@ import (
|
||||
"github.com/disgoorg/disgo/events"
|
||||
"github.com/disgoorg/json"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vaporvee/acecore/struct_cmd"
|
||||
"github.com/vaporvee/acecore/cmd"
|
||||
)
|
||||
|
||||
// TODO: make user installable tag command using userIDs instead of guildIDs
|
||||
var cmd_tag struct_cmd.Command = struct_cmd.Command{
|
||||
var cmd_tag cmd.Command = cmd.Command{
|
||||
Definition: discord.SlashCommandCreate{
|
||||
Name: "tag",
|
||||
DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageGuild),
|
||||
@@ -83,7 +83,7 @@ var cmd_tag struct_cmd.Command = struct_cmd.Command{
|
||||
},
|
||||
}
|
||||
|
||||
var cmd_tag_short struct_cmd.Command = struct_cmd.Command{
|
||||
var cmd_tag_short cmd.Command = cmd.Command{
|
||||
Definition: discord.SlashCommandCreate{
|
||||
Name: "g",
|
||||
Description: "A short command to get presaved messages.",
|
||||
@@ -109,7 +109,7 @@ var cmd_tag_short struct_cmd.Command = struct_cmd.Command{
|
||||
},
|
||||
}
|
||||
|
||||
var context_tag struct_cmd.Command = struct_cmd.Command{
|
||||
var context_tag cmd.Command = cmd.Command{
|
||||
Definition: discord.MessageCommandCreate{
|
||||
Name: "Save as tag",
|
||||
DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageGuild),
|
||||
|
4
go.mod
4
go.mod
@@ -15,10 +15,10 @@ require (
|
||||
require (
|
||||
github.com/gorilla/websocket v1.5.1 // indirect
|
||||
github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad // indirect
|
||||
github.com/vaporvee/acecore/struct_cmd v0.0.0-00010101000000-000000000000
|
||||
github.com/vaporvee/acecore/cmd v0.0.0-00010101000000-000000000000
|
||||
golang.org/x/crypto v0.19.0 // indirect
|
||||
golang.org/x/net v0.21.0 // indirect
|
||||
golang.org/x/sys v0.17.0 // indirect
|
||||
)
|
||||
|
||||
replace github.com/vaporvee/acecore/struct_cmd => ./struct_cmd
|
||||
replace github.com/vaporvee/acecore/cmd => ./cmd
|
||||
|
@@ -14,11 +14,11 @@ import (
|
||||
"github.com/disgoorg/disgo/events"
|
||||
"github.com/disgoorg/snowflake/v2"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vaporvee/acecore/cmd"
|
||||
"github.com/vaporvee/acecore/custom"
|
||||
"github.com/vaporvee/acecore/struct_cmd"
|
||||
)
|
||||
|
||||
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}
|
||||
var commands []cmd.Command = []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}
|
||||
|
||||
func ready(e *events.Ready) {
|
||||
logrus.Info("Starting up...")
|
||||
@@ -88,7 +88,7 @@ func loadPlugins(directory string, e *events.Ready) error {
|
||||
continue
|
||||
}
|
||||
|
||||
pluginPtr, ok := symPlugin.(**struct_cmd.Plugin)
|
||||
pluginPtr, ok := symPlugin.(**cmd.Plugin)
|
||||
if !ok {
|
||||
logrus.Errorf("Plugin does not match expected type")
|
||||
continue
|
||||
|
@@ -4,10 +4,10 @@ import (
|
||||
"github.com/disgoorg/disgo/discord"
|
||||
"github.com/disgoorg/disgo/events"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vaporvee/acecore/struct_cmd"
|
||||
"github.com/vaporvee/acecore/cmd"
|
||||
)
|
||||
|
||||
var Plugin = &struct_cmd.Plugin{
|
||||
var Plugin = &cmd.Plugin{
|
||||
Name: "testplugin",
|
||||
Register: func(e *events.Ready) error {
|
||||
app, err := e.Client().Rest().GetCurrentApplication()
|
||||
@@ -17,7 +17,7 @@ var Plugin = &struct_cmd.Plugin{
|
||||
logrus.Infof("%s has a working plugin called \"testplugin\"", app.Bot.Username)
|
||||
return nil
|
||||
},
|
||||
Commands: []struct_cmd.Command{
|
||||
Commands: []cmd.Command{
|
||||
{
|
||||
Definition: discord.SlashCommandCreate{
|
||||
Name: "testplugincommand",
|
||||
|
@@ -4,11 +4,11 @@ import (
|
||||
"github.com/disgoorg/disgo/discord"
|
||||
"github.com/disgoorg/disgo/events"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vaporvee/acecore/cmd"
|
||||
"github.com/vaporvee/acecore/custom"
|
||||
"github.com/vaporvee/acecore/struct_cmd"
|
||||
)
|
||||
|
||||
var cmd_ask = struct_cmd.Command{
|
||||
var cmd_ask = cmd.Command{
|
||||
Definition: discord.SlashCommandCreate{
|
||||
Name: "ask",
|
||||
Description: "Ask anything and get a gif as response!",
|
@@ -8,11 +8,11 @@ import (
|
||||
"github.com/disgoorg/disgo/discord"
|
||||
"github.com/disgoorg/disgo/events"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vaporvee/acecore/cmd"
|
||||
"github.com/vaporvee/acecore/custom"
|
||||
"github.com/vaporvee/acecore/struct_cmd"
|
||||
)
|
||||
|
||||
var cmd_cat = struct_cmd.Command{
|
||||
var cmd_cat = cmd.Command{
|
||||
Definition: discord.SlashCommandCreate{
|
||||
Name: "cat",
|
||||
Description: "Random cat pictures",
|
@@ -4,10 +4,10 @@ import (
|
||||
"github.com/disgoorg/disgo/discord"
|
||||
"github.com/disgoorg/disgo/events"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vaporvee/acecore/struct_cmd"
|
||||
"github.com/vaporvee/acecore/cmd"
|
||||
)
|
||||
|
||||
var cmd_dadjoke = struct_cmd.Command{
|
||||
var cmd_dadjoke = cmd.Command{
|
||||
Definition: discord.SlashCommandCreate{
|
||||
Name: "dadjoke",
|
||||
Description: "Gives you a random joke that is as bad as your dad would tell them",
|
3
plugin_src/simplefun/go.mod
Normal file
3
plugin_src/simplefun/go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module simplefun
|
||||
|
||||
go 1.22.1
|
20
plugin_src/simplefun/main.go
Normal file
20
plugin_src/simplefun/main.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/disgoorg/disgo/events"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vaporvee/acecore/cmd"
|
||||
)
|
||||
|
||||
var Plugin = &cmd.Plugin{
|
||||
Name: "Simple Fun",
|
||||
Register: func(e *events.Ready) error {
|
||||
app, err := e.Client().Rest().GetCurrentApplication()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logrus.Infof("%s has a working plugin called \"testplugin\"", app.Bot.Username)
|
||||
return nil
|
||||
},
|
||||
Commands: []cmd.Command{cmd_ask, cmd_cat, cmd_dadjoke},
|
||||
}
|
34
plugin_src/simplefun/tool.go
Normal file
34
plugin_src/simplefun/tool.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func simpleGetFromAPI(key string, url string) interface{} {
|
||||
client := &http.Client{}
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
logrus.Error("Error creating request:", err)
|
||||
}
|
||||
req.Header.Set("Accept", "application/json")
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
logrus.Error("Error making request:", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
logrus.Error("Error reading response body:", err)
|
||||
}
|
||||
|
||||
var result map[string]interface{}
|
||||
err = json.Unmarshal(body, &result)
|
||||
if err != nil {
|
||||
logrus.Error("Error decoding JSON:", err)
|
||||
}
|
||||
return result[key]
|
||||
}
|
@@ -43,7 +43,7 @@
|
||||
services.
|
||||
</li>
|
||||
<li>
|
||||
struct_cmd.Command usage: We store data about some commands that you use within
|
||||
cmd.Command usage: We store data about some commands that you use within
|
||||
acecore in order to make the commands usable and functioning.
|
||||
</li>
|
||||
<li>
|
||||
|
Reference in New Issue
Block a user