made simplefun plugin

This commit is contained in:
2024-04-14 22:26:30 +02:00
parent 410c28bda9
commit d814d39cf1
22 changed files with 96 additions and 39 deletions

View File

@@ -1,4 +1,4 @@
module struct_cmd module github.com/vaporvee/acecore/cmd
go 1.22.1 go 1.22.1

View File

@@ -1,4 +1,4 @@
package struct_cmd package cmd
import ( import (
"github.com/disgoorg/disgo/discord" "github.com/disgoorg/disgo/discord"

View File

@@ -11,10 +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" "github.com/vaporvee/acecore/cmd"
) )
var cmd_addemoji struct_cmd.Command = struct_cmd.Command{ var cmd_addemoji cmd.Command = 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,10 +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" "github.com/vaporvee/acecore/cmd"
) )
var cmd_autojoinroles struct_cmd.Command = struct_cmd.Command{ var cmd_autojoinroles cmd.Command = 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,10 +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" "github.com/vaporvee/acecore/cmd"
) )
var cmd_autopublish struct_cmd.Command = struct_cmd.Command{ var cmd_autopublish cmd.Command = 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,10 +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" "github.com/vaporvee/acecore/cmd"
) )
var cmd_blockpolls struct_cmd.Command = struct_cmd.Command{ var cmd_blockpolls cmd.Command = 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

@@ -12,11 +12,11 @@ import (
"github.com/disgoorg/snowflake/v2" "github.com/disgoorg/snowflake/v2"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vaporvee/acecore/cmd"
"github.com/vaporvee/acecore/custom" "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{ Definition: discord.SlashCommandCreate{
Name: "form", Name: "form",
DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageChannels), 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{ Definition: discord.SlashCommandCreate{
Name: "ticket", Name: "ticket",
DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageChannels), DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageChannels),

View File

@@ -8,8 +8,8 @@ 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/cmd"
"github.com/vaporvee/acecore/custom" "github.com/vaporvee/acecore/custom"
"github.com/vaporvee/acecore/struct_cmd"
) )
type UserExtend struct { 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)", 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{ 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

@@ -8,11 +8,11 @@ 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/cmd"
"github.com/vaporvee/acecore/custom" "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{ Definition: discord.SlashCommandCreate{
Name: "ping", Name: "ping",
Description: "Returns the ping of the bot", Description: "Returns the ping of the bot",

View File

@@ -6,11 +6,11 @@ import (
"github.com/disgoorg/json" "github.com/disgoorg/json"
"github.com/disgoorg/snowflake/v2" "github.com/disgoorg/snowflake/v2"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vaporvee/acecore/cmd"
"github.com/vaporvee/acecore/custom" "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{ 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",
@@ -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{ Definition: discord.MessageCommandCreate{
Name: "Stick to channel", Name: "Stick to channel",
DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageMessages), DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageMessages),

View File

@@ -5,11 +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" "github.com/vaporvee/acecore/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 struct_cmd.Command = struct_cmd.Command{ var cmd_tag cmd.Command = cmd.Command{
Definition: discord.SlashCommandCreate{ Definition: discord.SlashCommandCreate{
Name: "tag", Name: "tag",
DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageGuild), 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{ Definition: discord.SlashCommandCreate{
Name: "g", Name: "g",
Description: "A short command to get presaved messages.", 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{ Definition: discord.MessageCommandCreate{
Name: "Save as tag", Name: "Save as tag",
DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageGuild), DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionManageGuild),

4
go.mod
View File

@@ -15,10 +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 github.com/vaporvee/acecore/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/struct_cmd => ./struct_cmd replace github.com/vaporvee/acecore/cmd => ./cmd

View File

@@ -14,11 +14,11 @@ import (
"github.com/disgoorg/disgo/events" "github.com/disgoorg/disgo/events"
"github.com/disgoorg/snowflake/v2" "github.com/disgoorg/snowflake/v2"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vaporvee/acecore/cmd"
"github.com/vaporvee/acecore/custom" "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) { func ready(e *events.Ready) {
logrus.Info("Starting up...") logrus.Info("Starting up...")
@@ -88,7 +88,7 @@ func loadPlugins(directory string, e *events.Ready) error {
continue continue
} }
pluginPtr, ok := symPlugin.(**struct_cmd.Plugin) pluginPtr, ok := symPlugin.(**cmd.Plugin)
if !ok { if !ok {
logrus.Errorf("Plugin does not match expected type") logrus.Errorf("Plugin does not match expected type")
continue continue

View File

@@ -4,10 +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" "github.com/vaporvee/acecore/cmd"
) )
var Plugin = &struct_cmd.Plugin{ var Plugin = &cmd.Plugin{
Name: "testplugin", Name: "testplugin",
Register: func(e *events.Ready) error { Register: func(e *events.Ready) error {
app, err := e.Client().Rest().GetCurrentApplication() 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) logrus.Infof("%s has a working plugin called \"testplugin\"", app.Bot.Username)
return nil return nil
}, },
Commands: []struct_cmd.Command{ Commands: []cmd.Command{
{ {
Definition: discord.SlashCommandCreate{ Definition: discord.SlashCommandCreate{
Name: "testplugincommand", Name: "testplugincommand",

View File

@@ -4,11 +4,11 @@ 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/cmd"
"github.com/vaporvee/acecore/custom" "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{ 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

@@ -8,11 +8,11 @@ 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/cmd"
"github.com/vaporvee/acecore/custom" "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{ Definition: discord.SlashCommandCreate{
Name: "cat", Name: "cat",
Description: "Random cat pictures", Description: "Random cat pictures",

View File

@@ -4,10 +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" "github.com/vaporvee/acecore/cmd"
) )
var cmd_dadjoke = struct_cmd.Command{ var cmd_dadjoke = 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

@@ -0,0 +1,3 @@
module simplefun
go 1.22.1

View 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},
}

View 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]
}

View File

@@ -43,7 +43,7 @@
services. services.
</li> </li>
<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. acecore in order to make the commands usable and functioning.
</li> </li>
<li> <li>