| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package cmd |
||
| 2 | |||
| 3 | import ( |
||
| 4 | "github.com/FlameInTheDark/dtbot/bot" |
||
| 5 | ) |
||
| 6 | |||
| 7 | // TwitchCommand manipulates twitch announcer |
||
| 8 | func TwitchCommand(ctx bot.Context) { |
||
| 9 | ctx.MetricsCommand("bot") |
||
| 10 | if ctx.GetRoles().ExistsName("bot.admin") || ctx.IsAdmin() { |
||
| 11 | if len(ctx.Args) == 0 { |
||
| 12 | return |
||
| 13 | } |
||
| 14 | switch ctx.Args[0] { |
||
| 15 | case "add": |
||
| 16 | if len(ctx.Args) > 1 { |
||
| 17 | err := ctx.Twitch.AddStreamer(ctx.Guild.ID, ctx.Message.ChannelID, ctx.Args[1]) |
||
| 18 | if err != nil { |
||
| 19 | ctx.ReplyEmbed("Twitch", ctx.Loc("twitch_add_error")) |
||
| 20 | } else { |
||
| 21 | ctx.ReplyEmbed("Twitch", ctx.Loc("twitch_added")) |
||
| 22 | } |
||
| 23 | } |
||
| 24 | case "remove": |
||
| 25 | if len(ctx.Args) > 1 { |
||
| 26 | err := ctx.Twitch.RemoveStreamer(ctx.Guild.ID, ctx.Args[1]) |
||
| 27 | if err != nil { |
||
| 28 | ctx.ReplyEmbed("Twitch", ctx.Loc("twitch_remove_error")) |
||
| 29 | } else { |
||
| 30 | ctx.ReplyEmbed("Twitch", ctx.Loc("twitch_removed")) |
||
| 31 | } |
||
| 32 | } |
||
| 33 | } |
||
| 34 | } else { |
||
| 35 | ctx.ReplyEmbed("Twitch", ctx.Loc("admin_require")) |
||
| 36 | } |
||
| 37 | } |