From 056573fc26e7274264591121586f19805a2ea15b Mon Sep 17 00:00:00 2001 From: Luther Wen Xu Date: Thu, 10 Oct 2019 18:51:53 +0800 Subject: [PATCH] go: Implement basic embed creator --- GoBot/embed.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 GoBot/embed.go diff --git a/GoBot/embed.go b/GoBot/embed.go new file mode 100644 index 0000000..04d6258 --- /dev/null +++ b/GoBot/embed.go @@ -0,0 +1,44 @@ +package main + +import "github.com/bwmarrin/discordgo" + +type embed struct { + *discordgo.MessageEmbed +} + +func newEmbed() *embed { + return &embed{&discordgo.MessageEmbed{}} +} + +func (e *embed) Errorify() *embed { + e.Color = 0xE00000 + e.Title = "发生错误!An error has occurred!" + return e +} + +func (e *embed) SetTitle(title string) *embed { + e.Title = title + return e +} + +func (e *embed) SetColour(colour int) *embed { + e.Color = colour + return e +} + +func (e *embed) SetDescription(description string) *embed { + e.Description = description + return e +} + +func (e *embed) AddField(name, value string) *embed { + e.Fields = append(e.Fields, &discordgo.MessageEmbedField{ + Name: name, + Value: value, + }) + return e +} + +func (e *embed) Build() *discordgo.MessageEmbed { + return e.MessageEmbed +}