| Conditions | 14 |
| Total Lines | 32 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Complex classes like cmd.HelpCommand often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
| 1 | package cmd |
||
| 8 | func HelpCommand(ctx bot.Context) { |
||
| 9 | ctx.MetricsCommand("help_command") |
||
| 10 | if len(ctx.Args) == 0 { |
||
| 11 | ctx.ReplyEmbed(ctx.Loc("help"), ctx.Loc("help_reply")) |
||
| 12 | return |
||
| 13 | } |
||
| 14 | switch ctx.Args[0] { |
||
| 15 | case "!v": |
||
| 16 | ctx.ReplyEmbed(ctx.Loc("help"), ctx.Loc("help_command_!v")) |
||
| 17 | case "!b": |
||
| 18 | ctx.ReplyEmbed(ctx.Loc("help"), ctx.Loc("help_command_!b")) |
||
| 19 | if (ctx.IsAdmin()) { |
||
| 20 | ctx.ReplyEmbed(ctx.Loc("help"), ctx.Loc("help_command_!b_admin")) |
||
| 21 | } |
||
| 22 | case "!y": |
||
| 23 | ctx.ReplyEmbed(ctx.Loc("help"), ctx.Loc("help_command_!y")) |
||
| 24 | case "!r": |
||
| 25 | ctx.ReplyEmbed(ctx.Loc("help"), ctx.Loc("help_command_!r")) |
||
| 26 | case "!w": |
||
| 27 | ctx.ReplyEmbed(ctx.Loc("help"), ctx.Loc("help_command_!w")) |
||
| 28 | case "!n": |
||
| 29 | ctx.ReplyEmbed(ctx.Loc("help"), ctx.Loc("help_command_!n")) |
||
| 30 | case "!t": |
||
| 31 | ctx.ReplyEmbed(ctx.Loc("help"), ctx.Loc("help_command_!t")) |
||
| 32 | case "!c": |
||
| 33 | ctx.ReplyEmbed(ctx.Loc("help"), ctx.Loc("help_command_!c")) |
||
| 34 | case "!p": |
||
| 35 | ctx.ReplyEmbed(ctx.Loc("help"), ctx.Loc("help_command_!p")) |
||
| 36 | case "!geoip": |
||
| 37 | ctx.ReplyEmbed(ctx.Loc("help"), ctx.Loc("help_command_!geoip")) |
||
| 38 | case "!twitch": |
||
| 39 | ctx.ReplyEmbed(ctx.Loc("help"), ctx.Loc("help_command_!twitch")) |
||
| 40 | } |
||
| 42 |