mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-13 09:10:14 +00:00
feat(bot): use button for cv2 cards dashboard link
This commit is contained in:
parent
64d05fbb4e
commit
6223f32130
2 changed files with 55 additions and 13 deletions
|
|
@ -21,13 +21,15 @@ public class EmbedService
|
||||||
private readonly IDatabase _db;
|
private readonly IDatabase _db;
|
||||||
private readonly ModelRepository _repo;
|
private readonly ModelRepository _repo;
|
||||||
private readonly DiscordApiClient _rest;
|
private readonly DiscordApiClient _rest;
|
||||||
|
private readonly CoreConfig _coreConfig;
|
||||||
|
|
||||||
public EmbedService(IDatabase db, ModelRepository repo, IDiscordCache cache, DiscordApiClient rest)
|
public EmbedService(IDatabase db, ModelRepository repo, IDiscordCache cache, DiscordApiClient rest, CoreConfig coreConfig)
|
||||||
{
|
{
|
||||||
_db = db;
|
_db = db;
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_cache = cache;
|
_cache = cache;
|
||||||
_rest = rest;
|
_rest = rest;
|
||||||
|
_coreConfig = coreConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<(ulong Id, User? User)[]> GetUsers(IEnumerable<ulong> ids)
|
private Task<(ulong Id, User? User)[]> GetUsers(IEnumerable<ulong> ids)
|
||||||
|
|
@ -141,7 +143,7 @@ public class EmbedService
|
||||||
new MessageComponent()
|
new MessageComponent()
|
||||||
{
|
{
|
||||||
Type = ComponentType.Text,
|
Type = ComponentType.Text,
|
||||||
Content = $"## [{systemName ?? $"`{system.DisplayHid(cctx.Config)}`"}](https://dash.pluralkit.me/profile/s/{system.Hid}){premiumText}",
|
Content = $"## {systemName ?? $"`{system.DisplayHid(cctx.Config)}`"}{premiumText}",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -182,8 +184,21 @@ public class EmbedService
|
||||||
},
|
},
|
||||||
new MessageComponent()
|
new MessageComponent()
|
||||||
{
|
{
|
||||||
Type = ComponentType.Text,
|
Type = ComponentType.Section,
|
||||||
Content = $"-# System ID: `{system.DisplayHid(cctx.Config)}`\n-# Created: {system.Created.FormatZoned(cctx.Zone)}",
|
Components = [
|
||||||
|
new MessageComponent()
|
||||||
|
{
|
||||||
|
Type = ComponentType.Text,
|
||||||
|
Content = $"-# System ID: `{system.DisplayHid(cctx.Config)}`\n-# Created: {system.Created.FormatZoned(cctx.Zone)}",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
Accessory = new MessageComponent()
|
||||||
|
{
|
||||||
|
Type = ComponentType.Button,
|
||||||
|
Style = ButtonStyle.Link,
|
||||||
|
Label = "View on dashboard",
|
||||||
|
Url = $"{_coreConfig.DashboardBaseUrl}/profile/s/{system.Hid}",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -210,7 +225,7 @@ public class EmbedService
|
||||||
.Footer(new Embed.EmbedFooter(
|
.Footer(new Embed.EmbedFooter(
|
||||||
$"System ID: {system.DisplayHid(cctx.Config)} | Created on {system.Created.FormatZoned(cctx.Zone)}"))
|
$"System ID: {system.DisplayHid(cctx.Config)} | Created on {system.Created.FormatZoned(cctx.Zone)}"))
|
||||||
.Color(system.Color?.ToDiscordColor())
|
.Color(system.Color?.ToDiscordColor())
|
||||||
.Url($"https://dash.pluralkit.me/profile/s/{system.Hid}");
|
.Url($"{_coreConfig.DashboardBaseUrl}/profile/s/{system.Hid}");
|
||||||
|
|
||||||
var avatar = system.AvatarFor(ctx);
|
var avatar = system.AvatarFor(ctx);
|
||||||
if (avatar != null)
|
if (avatar != null)
|
||||||
|
|
@ -410,7 +425,7 @@ public class EmbedService
|
||||||
new MessageComponent()
|
new MessageComponent()
|
||||||
{
|
{
|
||||||
Type = ComponentType.Text,
|
Type = ComponentType.Text,
|
||||||
Content = $"## [{name}](https://dash.pluralkit.me/profile/m/{member.Hid}){(systemName != null ? $" ({systemName})" : "")}",
|
Content = $"## {name}{(systemName != null ? $" ({systemName})" : "")}",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -444,8 +459,21 @@ public class EmbedService
|
||||||
},
|
},
|
||||||
new MessageComponent()
|
new MessageComponent()
|
||||||
{
|
{
|
||||||
Type = ComponentType.Text,
|
Type = ComponentType.Section,
|
||||||
Content = $"-# System ID: `{system.DisplayHid(ccfg)}` \u2219 Member ID: `{member.DisplayHid(ccfg)}`{(member.MetadataPrivacy.CanAccess(ctx) ? $"\n-# Created: {member.Created.FormatZoned(zone)}" : "")}",
|
Components = [
|
||||||
|
new MessageComponent()
|
||||||
|
{
|
||||||
|
Type = ComponentType.Text,
|
||||||
|
Content = $"-# System ID: `{system.DisplayHid(ccfg)}` \u2219 Member ID: `{member.DisplayHid(ccfg)}`{(member.MetadataPrivacy.CanAccess(ctx) ? $"\n-# Created: {member.Created.FormatZoned(zone)}" : "")}",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
Accessory = new MessageComponent()
|
||||||
|
{
|
||||||
|
Type = ComponentType.Button,
|
||||||
|
Style = ButtonStyle.Link,
|
||||||
|
Label = "View on dashboard",
|
||||||
|
Url = $"{_coreConfig.DashboardBaseUrl}/profile/m/{member.Hid}",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -474,7 +502,7 @@ public class EmbedService
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
var eb = new EmbedBuilder()
|
var eb = new EmbedBuilder()
|
||||||
.Author(new Embed.EmbedAuthor(name, IconUrl: webhook_avatar.TryGetCleanCdnUrl(), Url: $"https://dash.pluralkit.me/profile/m/{member.Hid}"))
|
.Author(new Embed.EmbedAuthor(name, IconUrl: webhook_avatar.TryGetCleanCdnUrl(), Url: $"{_coreConfig.DashboardBaseUrl}/profile/m/{member.Hid}"))
|
||||||
// .WithColor(member.ColorPrivacy.CanAccess(ctx) ? color : null)
|
// .WithColor(member.ColorPrivacy.CanAccess(ctx) ? color : null)
|
||||||
.Color(member.Color?.ToDiscordColor())
|
.Color(member.Color?.ToDiscordColor())
|
||||||
.Footer(new Embed.EmbedFooter(
|
.Footer(new Embed.EmbedFooter(
|
||||||
|
|
@ -584,7 +612,7 @@ public class EmbedService
|
||||||
new MessageComponent()
|
new MessageComponent()
|
||||||
{
|
{
|
||||||
Type = ComponentType.Text,
|
Type = ComponentType.Text,
|
||||||
Content = $"## [{name}](https://dash.pluralkit.me/profile/g/{target.Hid}){(systemName != null ? $" ({systemName})" : "")}",
|
Content = $"## {name}{(systemName != null ? $" ({systemName})" : "")}",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -618,8 +646,21 @@ public class EmbedService
|
||||||
},
|
},
|
||||||
new MessageComponent()
|
new MessageComponent()
|
||||||
{
|
{
|
||||||
Type = ComponentType.Text,
|
Type = ComponentType.Section,
|
||||||
Content = $"-# System ID: `{system.DisplayHid(ctx.Config)}` \u2219 Group ID: `{target.DisplayHid(ctx.Config)}`{(target.MetadataPrivacy.CanAccess(pctx) ? $"\n-# Created: {target.Created.FormatZoned(ctx.Zone)}" : "")}",
|
Components = [
|
||||||
|
new MessageComponent()
|
||||||
|
{
|
||||||
|
Type = ComponentType.Text,
|
||||||
|
Content = $"-# System ID: `{system.DisplayHid(ctx.Config)}` \u2219 Group ID: `{target.DisplayHid(ctx.Config)}`{(target.MetadataPrivacy.CanAccess(pctx) ? $"\n-# Created: {target.Created.FormatZoned(ctx.Zone)}" : "")}",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
Accessory = new MessageComponent()
|
||||||
|
{
|
||||||
|
Type = ComponentType.Button,
|
||||||
|
Style = ButtonStyle.Link,
|
||||||
|
Label = "View on dashboard",
|
||||||
|
Url = $"{_coreConfig.DashboardBaseUrl}/profile/g/{target.Hid}",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -649,7 +690,7 @@ public class EmbedService
|
||||||
nameField = $"{nameField}";
|
nameField = $"{nameField}";
|
||||||
|
|
||||||
var eb = new EmbedBuilder()
|
var eb = new EmbedBuilder()
|
||||||
.Author(new Embed.EmbedAuthor(nameField, IconUrl: target.IconFor(pctx), Url: $"https://dash.pluralkit.me/profile/g/{target.Hid}"))
|
.Author(new Embed.EmbedAuthor(nameField, IconUrl: target.IconFor(pctx), Url: $"{_coreConfig.DashboardBaseUrl}/profile/g/{target.Hid}"))
|
||||||
.Color(target.Color?.ToDiscordColor());
|
.Color(target.Color?.ToDiscordColor());
|
||||||
|
|
||||||
eb.Footer(new Embed.EmbedFooter($"System ID: {system.DisplayHid(ctx.Config)} | Group ID: {target.DisplayHid(ctx.Config)}{(target.MetadataPrivacy.CanAccess(pctx) ? $" | Created on {target.Created.FormatZoned(ctx.Zone)}" : "")}"));
|
eb.Footer(new Embed.EmbedFooter($"System ID: {system.DisplayHid(ctx.Config)} | Group ID: {target.DisplayHid(ctx.Config)}{(target.MetadataPrivacy.CanAccess(pctx) ? $" | Created on {target.Created.FormatZoned(ctx.Zone)}" : "")}"));
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ public class CoreConfig
|
||||||
public string? SeqLogUrl { get; set; }
|
public string? SeqLogUrl { get; set; }
|
||||||
public string? DispatchProxyUrl { get; set; }
|
public string? DispatchProxyUrl { get; set; }
|
||||||
public string? DispatchProxyToken { get; set; }
|
public string? DispatchProxyToken { get; set; }
|
||||||
|
public string DashboardBaseUrl { get; set; } = "https://dash.pluralkit.local";
|
||||||
|
|
||||||
public LogEventLevel ConsoleLogLevel { get; set; } = LogEventLevel.Debug;
|
public LogEventLevel ConsoleLogLevel { get; set; } = LogEventLevel.Debug;
|
||||||
public LogEventLevel ElasticLogLevel { get; set; } = LogEventLevel.Information;
|
public LogEventLevel ElasticLogLevel { get; set; } = LogEventLevel.Information;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue