-
Notifications
You must be signed in to change notification settings - Fork 942
/
Copy pathcustomembed.go
30 lines (27 loc) · 940 Bytes
/
customembed.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package customembed
import (
"encoding/json"
"github.com/jonas747/dcmd/v4"
"github.com/jonas747/discordgo/v2"
"github.com/jonas747/yagpdb/commands"
)
var Command = &commands.YAGCommand{
CmdCategory: commands.CategoryFun,
Name: "CustomEmbed",
Aliases: []string{"ce"},
Description: "Creates an embed from what you give it in json form: https://docs.yagpdb.xyz/others/custom-embeds",
LongDescription: "Example: `-ce {\"title\": \"hello\", \"description\": \"wew\"}`",
RequiredArgs: 1,
RequireDiscordPerms: []int64{discordgo.PermissionManageMessages},
Arguments: []*dcmd.ArgDef{
{Name: "Json", Type: dcmd.String},
},
RunFunc: func(data *dcmd.Data) (interface{}, error) {
var parsed *discordgo.MessageEmbed
err := json.Unmarshal([]byte(data.Args[0].Str()), &parsed)
if err != nil {
return "Failed parsing json: " + err.Error(), err
}
return parsed, nil
},
}