diff --git a/internal/engine/command/command.go b/internal/engine/command/command.go index 96144e2..3776d06 100644 --- a/internal/engine/command/command.go +++ b/internal/engine/command/command.go @@ -5,6 +5,7 @@ import ( "slices" "github.com/pagu-project/Pagu/internal/entity" + "github.com/pagu-project/Pagu/pkg/color" ) var ( @@ -40,7 +41,7 @@ type HandlerFunc func(caller *entity.User, cmd *Command, args map[string]string) type Command struct { Emoji string - Color string + Color color.ColorCode Name string Help string Args []Args // should be nil for commands. @@ -52,7 +53,7 @@ type Command struct { } type CommandResult struct { - Color string + Color color.ColorCode Title string Error string Message string diff --git a/internal/platforms/discord/discord.go b/internal/platforms/discord/discord.go index b875c01..1713072 100644 --- a/internal/platforms/discord/discord.go +++ b/internal/platforms/discord/discord.go @@ -12,14 +12,15 @@ import ( "github.com/pagu-project/Pagu/internal/engine" "github.com/pagu-project/Pagu/internal/engine/command" "github.com/pagu-project/Pagu/internal/entity" + "github.com/pagu-project/Pagu/pkg/color" "github.com/pagu-project/Pagu/pkg/log" "github.com/pagu-project/Pagu/pkg/utils" ) type Bot struct { + cfg *config.DiscordBot Session *discordgo.Session engine *engine.BotEngine - cfg *config.DiscordBot target string } @@ -220,7 +221,7 @@ func (bot *Bot) respondErrMsg(errStr string, s *discordgo.Session, i *discordgo. errorEmbed := &discordgo.MessageEmbed{ Title: "Error", Description: errStr, - Color: RED, + Color: color.Yellow.ToInt(), } bot.respondEmbed(errorEmbed, s, i) } @@ -231,13 +232,13 @@ func (bot *Bot) respondResultMsg(res command.CommandResult, s *discordgo.Session resEmbed = &discordgo.MessageEmbed{ Title: "Successful", Description: res.Message, - Color: GREEN, + Color: color.Green.ToInt(), } } else { resEmbed = &discordgo.MessageEmbed{ Title: "Failed", Description: res.Message, - Color: YELLOW, + Color: color.Yellow.ToInt(), } } diff --git a/internal/platforms/discord/utils.go b/internal/platforms/discord/utils.go index 27bd8a0..a5e8e84 100644 --- a/internal/platforms/discord/utils.go +++ b/internal/platforms/discord/utils.go @@ -6,13 +6,6 @@ import ( "github.com/bwmarrin/discordgo" ) -const ( - GREEN = 0x008000 - RED = 0xFF0000 - YELLOW = 0xFFFF00 - PACTUS = 0x052D5A -) - func newStatus(name string, value any) discordgo.UpdateStatusData { return discordgo.UpdateStatusData{ Status: "online", diff --git a/pkg/color/color.go b/pkg/color/color.go new file mode 100644 index 0000000..e1a821c --- /dev/null +++ b/pkg/color/color.go @@ -0,0 +1,19 @@ +package color + +type ColorCode int + +const ( + Green ColorCode = 0x008000 + Red ColorCode = 0xFF0000 + Yellow ColorCode = 0xFFFF00 + Black ColorCode = 0x000000 + Pactus ColorCode = 0x052D5A +) + +func (ColorCode) String() string { + return "todo" +} + +func (c ColorCode) ToInt() int { + return int(c) +}