| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package cmd |
||
| 2 | |||
| 3 | import ( |
||
| 4 | "github.com/FlameInTheDark/dtbot/bot" |
||
| 5 | "strings" |
||
| 6 | ) |
||
| 7 | |||
| 8 | func GreetingsCommand(ctx bot.Context) { |
||
|
|
|||
| 9 | if ctx.GetRoles().ExistsName("bot.admin") || ctx.IsAdmin() { |
||
| 10 | if len(ctx.Args) > 0 { |
||
| 11 | switch ctx.Args[0] { |
||
| 12 | case "add": |
||
| 13 | if len(ctx.Args) > 1 { |
||
| 14 | ctx.MetricsCommand("greetings", "add") |
||
| 15 | ctx.AddGreetings(strings.Join(ctx.Args[1:], " ")) |
||
| 16 | ctx.ReplyEmbed(ctx.Loc("greetings"), ctx.Loc("greetings_add")) |
||
| 17 | } else { |
||
| 18 | ctx.MetricsCommand("greetings", "add_no_text") |
||
| 19 | ctx.ReplyEmbed(ctx.Loc("greetings"), ctx.Loc("greetings_no_text")) |
||
| 20 | } |
||
| 21 | case "remove": |
||
| 22 | ctx.MetricsCommand("greetings", "remove") |
||
| 23 | ctx.RemoveGreetings() |
||
| 24 | case "test": |
||
| 25 | ctx.ReplyEmbed(ctx.Loc("greetings"), ctx.Loc("greetings_removed")) |
||
| 26 | } |
||
| 27 | } |
||
| 28 | } else { |
||
| 29 | ctx.ReplyEmbed("Greetings", ctx.Loc("admin_require")) |
||
| 30 | ctx.MetricsCommand("greetings", "error") |
||
| 31 | } |
||
| 33 |