upgrade d#+

This commit is contained in:
13xforever
2025-05-17 22:06:54 +05:00
parent fd6a9b1057
commit e4ed125693
7 changed files with 39 additions and 50 deletions

View File

@@ -51,7 +51,7 @@ internal sealed class DevOnly
{
var builder = new DiscordMessageBuilder()
.WithContent("Regular button vs emoji button")
.AddComponents(
.AddActionRowComponent(
new DiscordButtonComponent(DiscordButtonStyle.Primary, "pt", "✅ Regular"),
new DiscordButtonComponent(DiscordButtonStyle.Primary, "pe", "Emoji", emoji: new(DiscordEmoji.FromUnicode("✅")))
);

View File

@@ -116,13 +116,11 @@ internal static class Explain
.AsEphemeral()
.WithCustomId($"modal:warn:{Guid.NewGuid():n}")
.WithTitle("New explanation")
.AddComponents(
new DiscordTextInputComponent(
label,
"explanation",
style: DiscordTextInputStyle.Paragraph
)
);
.AddTextInputComponent(new(
label,
"explanation",
style: DiscordTextInputStyle.Paragraph
));
await ctx.RespondWithModalAsync(modal).ConfigureAwait(false);
InteractivityResult<ModalSubmittedEventArgs> modalResult;
@@ -251,14 +249,12 @@ internal static class Explain
.AsEphemeral()
.WithCustomId($"modal:warn:{Guid.NewGuid():n}")
.WithTitle("Updated explanation")
.AddComponents(
new DiscordTextInputComponent(
label,
"explanation",
value: item.Text,
style: DiscordTextInputStyle.Paragraph
)
);
.AddTextInputComponent(new(
label,
"explanation",
value: item.Text,
style: DiscordTextInputStyle.Paragraph
));
await ctx.RespondWithModalAsync(modal).ConfigureAwait(false);
InteractivityResult<ModalSubmittedEventArgs> modalResult;

View File

@@ -30,16 +30,14 @@ internal static class ForcedNicknames
.AsEphemeral()
.WithCustomId($"modal:nickname:{Guid.NewGuid():n}")
.WithTitle("Enforcing Rule 7")
.AddComponents(
new DiscordTextInputComponent(
"New nickname",
"nickname",
suggestedName,
suggestedName,
min_length: 2,
max_length: 32
)
);
.AddTextInputComponent(new(
"New nickname",
"nickname",
suggestedName,
suggestedName,
min_length: 2,
max_length: 32
));
await ctx.RespondWithModalAsync(modal).ConfigureAwait(false);
string resultMsg;

View File

@@ -32,9 +32,8 @@ internal static class MessageMenuCommands
var placeholder = StatsStorage.GetExplainStats().FirstOrDefault().name ?? "rule 1";
var modal = new DiscordInteractionResponseBuilder()
.WithTitle("Explain Prompt")
.AddComponents(new DiscordTextInputComponent("Term to explain", "term", placeholder, min_length: 1))
.AddTextInputComponent(new("Term to explain", "term", placeholder, min_length: 1))
.WithCustomId($"modal:explain:{Guid.NewGuid():n}");
await ctx.RespondWithModalAsync(modal).ConfigureAwait(false);
InteractivityResult<ModalSubmittedEventArgs> modalResult;
@@ -80,16 +79,14 @@ internal static class MessageMenuCommands
.AsEphemeral()
.WithCustomId($"modal:report:{Guid.NewGuid():n}")
.WithTitle("Message Report")
.AddComponents(
new DiscordTextInputComponent(
"Comment",
"comment",
"Describe why you report this message",
required: false,
style: DiscordTextInputStyle.Paragraph,
max_length: EmbedPager.MaxFieldLength
)
);
.AddTextInputComponent(new(
"Comment",
"comment",
"Describe why you report this message",
required: false,
style: DiscordTextInputStyle.Paragraph,
max_length: EmbedPager.MaxFieldLength
));
await ctx.RespondWithModalAsync(modal).ConfigureAwait(false);
var modalResult = await interactivity.WaitForModalAsync(modal.CustomId, ctx.User).ConfigureAwait(false);
if (modalResult.TimedOut)

View File

@@ -34,14 +34,12 @@ internal static class WarningsContextMenus
.AsEphemeral()
.WithCustomId($"modal:warn:{Guid.NewGuid():n}")
.WithTitle("Issue new warning")
.AddComponents(
new DiscordTextInputComponent(
"Warning reason",
"warning",
"Rule #2",
min_length: 2
)
);
.AddTextInputComponent(new(
"Warning reason",
"warning",
"Rule #2",
min_length: 2
));
await ctx.RespondWithModalAsync(modal).ConfigureAwait(false);
try

View File

@@ -42,9 +42,9 @@
<ItemGroup>
<PackageReference Include="Blurhash.ImageSharp" Version="4.0.0" />
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.4.0" />
<PackageReference Include="DSharpPlus" Version="5.0.0-nightly-02478" />
<PackageReference Include="DSharpPlus.Commands" Version="5.0.0-nightly-02478" />
<PackageReference Include="DSharpPlus.Interactivity" Version="5.0.0-nightly-02478" />
<PackageReference Include="DSharpPlus" Version="5.0.0-nightly-02506" />
<PackageReference Include="DSharpPlus.Commands" Version="5.0.0-nightly-02506" />
<PackageReference Include="DSharpPlus.Interactivity" Version="5.0.0-nightly-02506" />
<PackageReference Include="DSharpPlus.Natives.Zstd" Version="1.5.7.21" />
<PackageReference Include="Google.Apis.Drive.v3" Version="1.69.0.3778" />
<PackageReference Include="MathParser.org-mXparser" Version="6.1.0" />

View File

@@ -58,7 +58,7 @@ internal static partial class ProductCodeLookup
var messageBuilder = new DiscordMessageBuilder().AddEmbed(result.builder);
//todo: pass author from context and update OnCheckUpdatesButtonClick in psn check updates
if (message is {Author: not null} && channel.IsSpamChannel())
messageBuilder.AddComponents(
messageBuilder.AddActionRowComponent(
new DiscordButtonComponent(
DiscordButtonStyle.Secondary,
$"{GlobalButtonHandler.ReplaceWithUpdatesPrefix}{result.code}",