-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathDevOnly.cs
69 lines (64 loc) · 2.76 KB
/
DevOnly.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Text;
using System.Threading.Tasks;
using CompatBot.Utils;
using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
namespace CompatBot.Commands;
internal sealed class DevOnly : BaseCommandModuleCustom
{
[Command("whitespacetest"), Aliases("wst", "wstest")]
[Description("Testing discord embeds breakage for whitespaces")]
public async Task WhitespaceTest(CommandContext ctx)
{
var checkMark = "[\u00a0]";
const int width = 20;
var result = new StringBuilder($"` 1. Dots:{checkMark.PadLeft(width, '.')}`").AppendLine()
.AppendLine($"` 2. None:{checkMark,width}`");
var ln = 3;
foreach (var c in StringUtils.SpaceCharacters)
result.AppendLine($"`{ln++,2}. {(int)c:x4}:{checkMark,width}`");
#pragma warning disable 8321
static void addRandomStuff(DiscordEmbedBuilder emb)
{
emb.AddField("Random section", """
😾 lasjdf wqoieyr osdf `Vreoh Sdab` wohe `270`
🤔 salfhiosfhsero hskfh shufwei oufhwehw e wkihrwe h
ℹ️ sakfjas f hs `ASfhewighehw safds` asfw
🔮 ¯\\\_(ツ)\_/¯
""", false);
}
#pragma warning restore 8321
var embed = new DiscordEmbedBuilder()
.WithTitle("Whitespace embed test")
.WithDescription("In a perfect world all these lines would look the same, with perfectly formed columns");
var lines = result.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
var embedList = lines.BreakInEmbeds(embed, lines.Length / 2 + lines.Length % 2, "Normal");
foreach (var _ in embedList)
{
//drain the enumerable
}
embed.AddField("-", "-", false);
lines = result.ToString().Replace(' ', StringUtils.Nbsp).Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
embedList = lines.BreakInEmbeds(embed, lines.Length / 2 + lines.Length % 2, "Non-breakable spaces");
foreach (var _ in embedList)
{
//drain the enumerable
}
await ctx.Channel.SendMessageAsync(embed: embed).ConfigureAwait(false);
}
[Command("buttons")]
[Description("Buttons test")]
public async Task Buttons(CommandContext ctx)
{
var builder = new DiscordMessageBuilder()
.WithContent("Regular button vs emoji button")
.AddComponents(
new DiscordButtonComponent(ButtonStyle.Primary, "pt", "✅ Regular"),
new DiscordButtonComponent(ButtonStyle.Primary, "pe", "Emoji", emoji: new(DiscordEmoji.FromUnicode("✅")))
);
await ctx.RespondAsync(builder).ConfigureAwait(false);
}
}