mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-19 16:33:36 +03:00
Mixed changes
- Add MarkdownExtensions.cs - Remove AddBulletPoint from StringExtensions.cs - Add xmldocs to StringBuilderExtensions.cs
This commit is contained in:
parent
76d1089c38
commit
c80daa40ed
5 changed files with 64 additions and 16 deletions
|
@ -13,6 +13,7 @@ using Remora.Discord.Commands.Conditions;
|
||||||
using Remora.Discord.Commands.Contexts;
|
using Remora.Discord.Commands.Contexts;
|
||||||
using Remora.Discord.Commands.Feedback.Services;
|
using Remora.Discord.Commands.Feedback.Services;
|
||||||
using Remora.Discord.Extensions.Embeds;
|
using Remora.Discord.Extensions.Embeds;
|
||||||
|
using Remora.Discord.Extensions.Formatting;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
|
|
||||||
|
@ -134,7 +135,7 @@ public class KickCommandGroup : CommandGroup
|
||||||
{
|
{
|
||||||
var dmEmbed = new EmbedBuilder().WithGuildTitle(guild)
|
var dmEmbed = new EmbedBuilder().WithGuildTitle(guild)
|
||||||
.WithTitle(Messages.YouWereKicked)
|
.WithTitle(Messages.YouWereKicked)
|
||||||
.WithDescription(string.Format(Messages.DescriptionActionReason, reason).AddBulletPoint())
|
.WithDescription(MarkdownExtensions.BulletPoint(string.Format(Messages.DescriptionActionReason, reason)))
|
||||||
.WithActionFooter(executor)
|
.WithActionFooter(executor)
|
||||||
.WithCurrentTimestamp()
|
.WithCurrentTimestamp()
|
||||||
.WithColour(ColorsList.Red)
|
.WithColour(ColorsList.Red)
|
||||||
|
@ -159,7 +160,7 @@ public class KickCommandGroup : CommandGroup
|
||||||
data.GetOrCreateMemberData(target.ID).Roles.Clear();
|
data.GetOrCreateMemberData(target.ID).Roles.Clear();
|
||||||
|
|
||||||
var title = string.Format(Messages.UserKicked, target.GetTag());
|
var title = string.Format(Messages.UserKicked, target.GetTag());
|
||||||
var description = string.Format(Messages.DescriptionActionReason, reason).AddBulletPoint();
|
var description = MarkdownExtensions.BulletPoint(string.Format(Messages.DescriptionActionReason, reason));
|
||||||
var logResult = _utility.LogActionAsync(
|
var logResult = _utility.LogActionAsync(
|
||||||
data.Settings, channelId, executor, title, description, target, ColorsList.Red, ct: ct);
|
data.Settings, channelId, executor, title, description, target, ColorsList.Red, ct: ct);
|
||||||
if (!logResult.IsSuccess)
|
if (!logResult.IsSuccess)
|
||||||
|
|
|
@ -325,7 +325,7 @@ public class MuteCommandGroup : CommandGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
var title = string.Format(Messages.UserUnmuted, target.GetTag());
|
var title = string.Format(Messages.UserUnmuted, target.GetTag());
|
||||||
var description = string.Format(Messages.DescriptionActionReason, reason).AddBulletPoint();
|
var description = MarkdownExtensions.BulletPoint(string.Format(Messages.DescriptionActionReason, reason));
|
||||||
var logResult = _utility.LogActionAsync(
|
var logResult = _utility.LogActionAsync(
|
||||||
data.Settings, channelId, executor, title, description, target, ColorsList.Green, ct: ct);
|
data.Settings, channelId, executor, title, description, target, ColorsList.Green, ct: ct);
|
||||||
if (!logResult.IsSuccess)
|
if (!logResult.IsSuccess)
|
||||||
|
|
16
src/Extensions/MarkdownExtensions.cs
Normal file
16
src/Extensions/MarkdownExtensions.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
namespace Octobot.Extensions;
|
||||||
|
|
||||||
|
public static class MarkdownExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Formats a string to use Markdown Bullet formatting.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">The input text to format.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// A markdown-formatted bullet string.
|
||||||
|
/// </returns>
|
||||||
|
public static string BulletPoint(string text)
|
||||||
|
{
|
||||||
|
return $"- {text}";
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,23 +4,59 @@ namespace Octobot.Extensions;
|
||||||
|
|
||||||
public static class StringBuilderExtensions
|
public static class StringBuilderExtensions
|
||||||
{
|
{
|
||||||
public static StringBuilder AppendBulletPoint(this StringBuilder builder, string? text)
|
/// <summary>
|
||||||
|
/// Appends the input string with Markdown Bullet formatting to the specified <see cref="StringBuilder" /> object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="builder">The <see cref="StringBuilder" /> object.</param>
|
||||||
|
/// <param name="value">The string to append with bullet point.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The builder with the appended string with Markdown Bullet formatting.
|
||||||
|
/// </returns>
|
||||||
|
public static StringBuilder AppendBulletPoint(this StringBuilder builder, string? value)
|
||||||
{
|
{
|
||||||
return builder.Append("- ").Append(text);
|
return builder.Append("- ").Append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StringBuilder AppendSubBulletPoint(this StringBuilder builder, string? text)
|
/// <summary>
|
||||||
|
/// Appends the input string with Markdown Sub-Bullet formatting to the specified <see cref="StringBuilder" /> object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="builder">The <see cref="StringBuilder" /> object.</param>
|
||||||
|
/// <param name="value">The string to append with sub-bullet point.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The builder with the appended string with Markdown Sub-Bullet formatting.
|
||||||
|
/// </returns>
|
||||||
|
public static StringBuilder AppendSubBulletPoint(this StringBuilder builder, string? value)
|
||||||
{
|
{
|
||||||
return builder.Append(" - ").Append(text);
|
return builder.Append(" - ").Append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StringBuilder AppendBulletPointLine(this StringBuilder builder, string? text)
|
/// <summary>
|
||||||
|
/// Appends the input string with Markdown Bullet formatting followed by
|
||||||
|
/// the default line terminator to the end of specified <see cref="StringBuilder" /> object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="builder">The <see cref="StringBuilder" /> object.</param>
|
||||||
|
/// <param name="value">The string to append with bullet point.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The builder with the appended string with Markdown Bullet formatting
|
||||||
|
/// and default line terminator at the end.
|
||||||
|
/// </returns>
|
||||||
|
public static StringBuilder AppendBulletPointLine(this StringBuilder builder, string? value)
|
||||||
{
|
{
|
||||||
return builder.Append("- ").AppendLine(text);
|
return builder.Append("- ").AppendLine(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StringBuilder AppendSubBulletPointLine(this StringBuilder builder, string? text)
|
/// <summary>
|
||||||
|
/// Appends the input string with Markdown Sub-Bullet formatting followed by
|
||||||
|
/// the default line terminator to the end of specified <see cref="StringBuilder" /> object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="builder">The <see cref="StringBuilder" /> object.</param>
|
||||||
|
/// <param name="value">The string to append with sub-bullet point.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The builder with the appended string with Markdown Sub-Bullet formatting
|
||||||
|
/// and default line terminator at the end.
|
||||||
|
/// </returns>
|
||||||
|
public static StringBuilder AppendSubBulletPointLine(this StringBuilder builder, string? value)
|
||||||
{
|
{
|
||||||
return builder.Append(" - ").AppendLine(text);
|
return builder.Append(" - ").AppendLine(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,9 +63,4 @@ public static class StringExtensions
|
||||||
{
|
{
|
||||||
return WebUtility.UrlEncode(s).Replace('+', ' ');
|
return WebUtility.UrlEncode(s).Replace('+', ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string AddBulletPoint(this string s)
|
|
||||||
{
|
|
||||||
return $"- {s}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue