Update style, add nullable

This commit is contained in:
Noi 2021-11-22 13:32:30 -08:00
parent f8350fed53
commit 488ebfa163

View file

@ -1,18 +1,13 @@
using Discord; using System.Text;
using System;
using System.Collections.Generic;
using System.Text;
namespace BirthdayBot.UserInterface namespace BirthdayBot.UserInterface;
{
internal class CommandDocumentation internal class CommandDocumentation {
{
public string[] Commands { get; } public string[] Commands { get; }
public string Usage { get; } public string Usage { get; }
public string Examples { get; } public string? Examples { get; }
public CommandDocumentation(IEnumerable<string> commands, string usage, string examples) public CommandDocumentation(IEnumerable<string> commands, string usage, string? examples) {
{
var cmds = new List<string>(); var cmds = new List<string>();
foreach (var item in commands) cmds.Add(CommandsCommon.CommandPrefix + item); foreach (var item in commands) cmds.Add(CommandsCommon.CommandPrefix + item);
if (cmds.Count == 0) throw new ArgumentException(null, nameof(commands)); if (cmds.Count == 0) throw new ArgumentException(null, nameof(commands));
@ -24,16 +19,14 @@ namespace BirthdayBot.UserInterface
/// <summary> /// <summary>
/// Returns a string that can be inserted into a help or usage message. /// Returns a string that can be inserted into a help or usage message.
/// </summary> /// </summary>
public string Export() public string Export() {
{
var result = new StringBuilder(); var result = new StringBuilder();
foreach (var item in Commands) result.Append(", `" + item + "`"); foreach (var item in Commands) result.Append(", `" + item + "`");
result.Remove(0, 2); result.Remove(0, 2);
result.Insert(0, '●'); result.Insert(0, '●');
result.AppendLine(); result.AppendLine();
result.Append("» " + Usage); result.Append("» " + Usage);
if (Examples != null) if (Examples != null) {
{
result.AppendLine(); result.AppendLine();
result.Append("» Examples: " + Examples); result.Append("» Examples: " + Examples);
} }
@ -43,10 +36,8 @@ namespace BirthdayBot.UserInterface
/// <summary> /// <summary>
/// Creates an embeddable message containing the command documentation. /// Creates an embeddable message containing the command documentation.
/// </summary> /// </summary>
public Embed UsageEmbed => new EmbedBuilder() public Embed UsageEmbed => new EmbedBuilder() {
{
Author = new EmbedAuthorBuilder() { Name = "Usage" }, Author = new EmbedAuthorBuilder() { Name = "Usage" },
Description = Export() Description = Export()
}.Build(); }.Build();
} }
}