Skip to content

Commit

Permalink
add things & add allowed mentions
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Jul 20, 2024
1 parent 6ddacac commit 3245539
Show file tree
Hide file tree
Showing 7 changed files with 4,089 additions and 6 deletions.
4 changes: 4 additions & 0 deletions commands/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/handler"
"github.com/disgoorg/snowflake/v2"
"go.deanishe.net/fuzzy"

"github.com/lavalink-devs/lavalink-bot/internal/res"
Expand Down Expand Up @@ -37,6 +38,9 @@ func (c *Commands) Read(data discord.SlashCommandInteractionData, e *handler.Com
user, ok := data.OptUser("user")
if ok {
msg.Content += fmt.Sprintf("Hey %s,\n", user.Mention())
msg.AllowedMentions = &discord.AllowedMentions{
Users: []snowflake.ID{user.ID},
}
}

thing, ok := c.Things[data.String("thing")]
Expand Down
8 changes: 4 additions & 4 deletions lavalinkbot/thing.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"embed"
"fmt"
"io"
"path/filepath"
"path"

"github.com/adrg/frontmatter"
)
Expand All @@ -22,15 +22,15 @@ func ReadThings(things embed.FS) (map[string]Thing, error) {
if !file.IsDir() {
continue
}
thingFiles, err := things.ReadDir(filepath.Join("things", file.Name()))
thingFiles, err := things.ReadDir(path.Join("things", file.Name()))
if err != nil {
return nil, err
}

var thing Thing
for _, f := range thingFiles {
if f.Name() == "index.md" {
data, err := things.ReadFile(filepath.Join("things", file.Name(), "index.md"))
data, err := things.ReadFile(path.Join("things", file.Name(), "index.md"))
if err != nil {
return nil, fmt.Errorf("failed to read index.md for %s: %w", file.Name(), err)
}
Expand All @@ -47,7 +47,7 @@ func ReadThings(things embed.FS) (map[string]Thing, error) {
continue
}

data, err := things.ReadFile(filepath.Join("things", file.Name(), f.Name()))
data, err := things.ReadFile(path.Join("things", file.Name(), f.Name()))
if err != nil {
return nil, fmt.Errorf("failed to read file %s for %s: %w", f.Name(), file.Name(), err)
}
Expand Down
3 changes: 3 additions & 0 deletions things/bee_movie_script/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
name: Bee Movie Script
---
Loading

0 comments on commit 3245539

Please sign in to comment.