mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-19 16:33:36 +03:00
Add repository link button
This commit is contained in:
parent
b284ac28d5
commit
a67ba46f7f
2 changed files with 19 additions and 5 deletions
|
@ -8,9 +8,11 @@ using Remora.Commands.Attributes;
|
||||||
using Remora.Commands.Groups;
|
using Remora.Commands.Groups;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
using Remora.Discord.API.Abstractions.Rest;
|
using Remora.Discord.API.Abstractions.Rest;
|
||||||
|
using Remora.Discord.API.Objects;
|
||||||
using Remora.Discord.Commands.Attributes;
|
using Remora.Discord.Commands.Attributes;
|
||||||
using Remora.Discord.Commands.Conditions;
|
using Remora.Discord.Commands.Conditions;
|
||||||
using Remora.Discord.Commands.Contexts;
|
using Remora.Discord.Commands.Contexts;
|
||||||
|
using Remora.Discord.Commands.Feedback.Messages;
|
||||||
using Remora.Discord.Commands.Feedback.Services;
|
using Remora.Discord.Commands.Feedback.Services;
|
||||||
using Remora.Discord.Extensions.Embeds;
|
using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
|
@ -31,6 +33,8 @@ public class AboutCommandGroup : CommandGroup
|
||||||
("neroduckale", new Snowflake(474943797063843851))
|
("neroduckale", new Snowflake(474943797063843851))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private const string RepositoryUrl = "https://github.com/LabsDevelopment/Octobot";
|
||||||
|
|
||||||
private readonly ICommandContext _context;
|
private readonly ICommandContext _context;
|
||||||
private readonly IFeedbackService _feedback;
|
private readonly IFeedbackService _feedback;
|
||||||
private readonly GuildDataService _guildData;
|
private readonly GuildDataService _guildData;
|
||||||
|
@ -91,14 +95,22 @@ public class AboutCommandGroup : CommandGroup
|
||||||
builder.AppendBulletPointLine($"{tag} — {$"AboutDeveloper@{dev.Username}".Localized()}");
|
builder.AppendBulletPointLine($"{tag} — {$"AboutDeveloper@{dev.Username}".Localized()}");
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.Append($"### [{Messages.AboutTitleRepository}](https://github.com/LabsDevelopment/Octobot)");
|
|
||||||
|
|
||||||
var embed = new EmbedBuilder().WithSmallTitle(Messages.AboutBot, bot)
|
var embed = new EmbedBuilder().WithSmallTitle(Messages.AboutBot, bot)
|
||||||
.WithDescription(builder.ToString())
|
.WithDescription(builder.ToString())
|
||||||
.WithColour(ColorsList.Cyan)
|
.WithColour(ColorsList.Cyan)
|
||||||
.WithImageUrl("https://cdn.mctaylors.ru/octobot-banner.png")
|
.WithImageUrl("https://cdn.mctaylors.ru/octobot-banner.png")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
return await _feedback.SendContextualEmbedResultAsync(embed, ct);
|
var button = new ButtonComponent(
|
||||||
|
ButtonComponentStyle.Link,
|
||||||
|
Messages.AboutTitleRepository,
|
||||||
|
URL: RepositoryUrl
|
||||||
|
);
|
||||||
|
|
||||||
|
return await _feedback.SendContextualEmbedResultAsync(embed, ct,
|
||||||
|
new FeedbackMessageOptions(MessageComponents: new[]
|
||||||
|
{
|
||||||
|
new ActionRowComponent(new[] { button })
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using Remora.Discord.API.Objects;
|
using Remora.Discord.API.Objects;
|
||||||
|
using Remora.Discord.Commands.Feedback.Messages;
|
||||||
using Remora.Discord.Commands.Feedback.Services;
|
using Remora.Discord.Commands.Feedback.Services;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
|
|
||||||
|
@ -7,13 +8,14 @@ namespace Octobot.Extensions;
|
||||||
public static class FeedbackServiceExtensions
|
public static class FeedbackServiceExtensions
|
||||||
{
|
{
|
||||||
public static async Task<Result> SendContextualEmbedResultAsync(
|
public static async Task<Result> SendContextualEmbedResultAsync(
|
||||||
this IFeedbackService feedback, Result<Embed> embedResult, CancellationToken ct = default)
|
this IFeedbackService feedback, Result<Embed> embedResult, CancellationToken ct = default,
|
||||||
|
FeedbackMessageOptions? options = null)
|
||||||
{
|
{
|
||||||
if (!embedResult.IsDefined(out var embed))
|
if (!embedResult.IsDefined(out var embed))
|
||||||
{
|
{
|
||||||
return Result.FromError(embedResult);
|
return Result.FromError(embedResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (Result)await feedback.SendContextualEmbedAsync(embed, ct: ct);
|
return (Result)await feedback.SendContextualEmbedAsync(embed, options, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue