Skip to content

Commit

Permalink
Add /embed (#48)
Browse files Browse the repository at this point in the history
* Added /embed create and stubbed out /embed update

* Added /embed update

* Added /embed add-field

* Added /embed delete-field

* Fixed typo and updated README.md

* Updated docker-compose.yml for v1.10.0

* Added 'preview' opt to /embed create
  • Loading branch information
Kardbord authored Jan 9, 2022
1 parent 5ce28cd commit 0b05bad
Show file tree
Hide file tree
Showing 5 changed files with 575 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ A discord bot destined for greatness.
- [x] Build memes from provided templates and user provided text
- [x] Generate a story from a user's prompt
- [x] Allow server admins to generate and edit a role selection menu
- [x] Allow users to create embeds
- [ ] Inform users when Kard-bot is updated
- [ ] Mock certain questions or phrases
- [ ] "Quack" any time a user types an expletive
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: "3.9"
services:
kardbot:
image: tkvarfordt/kardbot:v1.9.2
container_name: kardbot-v1.9.2
image: tkvarfordt/kardbot:v1.10.0
container_name: kardbot-v1.10.0
volumes:
- ./config:/app/config
- ./assets/pasta:/app/assets/pasta
Expand Down
6 changes: 6 additions & 0 deletions kardbot/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ func getCommands() []*discordgo.ApplicationCommand {
Description: "Allow users to select roles for themselves",
Options: roleSelectCmdOpts(),
},
{
Name: embedCmd,
Description: "Build a custom embed",
Options: embedCmdOpts(),
},
{
Name: "help",
Description: "Get helpful information about the bot.",
Expand Down Expand Up @@ -355,6 +360,7 @@ func getCommandImpls() map[string]onInteractionHandler {
delBotDMCmd: deleteBotDMs,
storyTimeCmd: storyTime,
roleSelectMenuCommand: handleRoleSelectMenuCommand,
embedCmd: handleEmbedCmd,
}
}

Expand Down
13 changes: 13 additions & 0 deletions kardbot/dg_helpers/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,16 @@ func (e *Embed) SetTimestamp() *Embed {
e.Timestamp = time.Now().Format(time.RFC3339)
return e
}

func (e *Embed) IsEmpty() bool {
return e.Title == "" && e.Description == "" && (e.Footer == nil || e.Footer.Text == "") && (e.Image == nil || e.Image.URL == "") && (e.Thumbnail == nil || e.Thumbnail.URL == "") && (e.Provider == nil || e.Provider.Name == "") && (e.Author == nil || e.Author.Name == "") && len(e.Fields) == 0
}

func (e *Embed) AppendToFooter(str string) *Embed {
if e.Footer == nil {
e.SetFooter(str)
} else {
e.SetFooter(e.Footer.Text + str)
}
return e
}
Loading

0 comments on commit 0b05bad

Please sign in to comment.