finished plugin system base
This commit is contained in:
@@ -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/shared"
|
||||
)
|
||||
|
||||
var cmd_ask = cmd.Command{
|
||||
var cmd_ask = shared.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/shared"
|
||||
)
|
||||
|
||||
var cmd_cat = cmd.Command{
|
||||
var cmd_cat = shared.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/cmd"
|
||||
"github.com/vaporvee/acecore/shared"
|
||||
)
|
||||
|
||||
var cmd_dadjoke = cmd.Command{
|
||||
var cmd_dadjoke = shared.Command{
|
||||
Definition: discord.SlashCommandCreate{
|
||||
Name: "dadjoke",
|
||||
Description: "Gives you a random joke that is as bad as your dad would tell them",
|
||||
|
@@ -1,20 +0,0 @@
|
||||
module github.com/vaporvee/acecore/simplefun
|
||||
|
||||
go 1.22.1
|
||||
|
||||
require (
|
||||
github.com/disgoorg/disgo v0.18.2
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/vaporvee/acecore v0.0.0-20240414202630-d814d39cf135
|
||||
github.com/vaporvee/acecore/cmd v0.0.0-20240414202630-d814d39cf135
|
||||
)
|
||||
|
||||
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
|
||||
)
|
@@ -1,36 +0,0 @@
|
||||
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=
|
||||
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/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/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/vaporvee/acecore v0.0.0-20240414202630-d814d39cf135 h1:LdMezyBJ9Q8/VIugcvc6X37/0L9poxKU6zq36ooJN3U=
|
||||
github.com/vaporvee/acecore v0.0.0-20240414202630-d814d39cf135/go.mod h1:kRHYJwIF7PW99J8BzDqVtV7c0PoitgdpR/e06emJm1s=
|
||||
github.com/vaporvee/acecore/cmd v0.0.0-20240414202630-d814d39cf135 h1:SbwOoMX4LViUCuH8syFUKPsKXBONY3PhSrkKVNmFJYc=
|
||||
github.com/vaporvee/acecore/cmd v0.0.0-20240414202630-d814d39cf135/go.mod h1:03W2NrAPbAqa7gsqAM+2K/wT28stj9BmEhC5NzeGe3A=
|
||||
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.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
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/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
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=
|
@@ -1,10 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/vaporvee/acecore/cmd"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vaporvee/acecore/shared"
|
||||
)
|
||||
|
||||
var Plugin = &cmd.Plugin{
|
||||
var Plugin = &shared.Plugin{
|
||||
Name: "Simple Fun",
|
||||
Commands: []cmd.Command{cmd_ask, cmd_cat, cmd_dadjoke},
|
||||
Commands: []shared.Command{cmd_ask, cmd_cat, cmd_dadjoke},
|
||||
}
|
||||
|
||||
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]
|
||||
}
|
||||
|
@@ -1,34 +0,0 @@
|
||||
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]
|
||||
}
|
Reference in New Issue
Block a user