Skip to content

Commit

Permalink
Merge pull request #34 from Azuki-bar/feat/help-cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Azuki-bar authored Mar 13, 2022
2 parents 71668f3 + 89c3cde commit fed9cbd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions doc/cmd.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

またね!

## help

このページへのリンクをテキストチャンネルに投稿します。

## dict

読み方を登録する単語辞書を操作します。
Expand Down
5 changes: 2 additions & 3 deletions pkg/ceviord/handleMsg.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,11 @@ func parseUserCmd(msg string) (userMainCmd, error) {
mainCmd = new(dict)
case "change":
mainCmd = new(change)
case "help", "man":
mainCmd = new(help)
default:
return nil, fmt.Errorf("unknown user cmd `%s` \n", rawCmd[0])
}
if len(rawCmd) < 2 {
return mainCmd, nil
}
if err := mainCmd.parse(rawCmd); err != nil {
return nil, err
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/ceviord/userCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,18 @@ func (d *dictList) getOptStr() string {
}
}

type help struct{}

func (*help) handle(sess *discordgo.Session, _ *discordgo.MessageCreate) error {
return SendEmbedMsg(&discordgo.MessageEmbed{
Title: "コマンドリファレンス",
Description: "コマンドは以下のページを参考に入力してください。",
URL: "https://github.com/Azuki-bar/ceviord/blob/main/doc/cmd.md",
}, sess)
}

func (*help) parse(_ []string) error { return nil }

func stringMax(msg string, max int) string {
lenMsg := len([]rune(msg))
if lenMsg > max {
Expand Down

0 comments on commit fed9cbd

Please sign in to comment.