|
|
|
@ -89,27 +89,17 @@ internal class ExportContext
|
|
|
|
|
|
|
|
|
|
public Role? TryGetRole(Snowflake id) => _roles.GetValueOrDefault(id);
|
|
|
|
|
|
|
|
|
|
public Color? TryGetUserColor(Snowflake id)
|
|
|
|
|
{
|
|
|
|
|
var memberRoles = GetUserRoles(id);
|
|
|
|
|
|
|
|
|
|
return memberRoles?
|
|
|
|
|
.Where(r => r.Color is not null)
|
|
|
|
|
.Select(r => r.Color)
|
|
|
|
|
.FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IReadOnlyList<Role> GetUserRoles(Snowflake id)
|
|
|
|
|
{
|
|
|
|
|
var member = TryGetMember(id);
|
|
|
|
|
|
|
|
|
|
return member?
|
|
|
|
|
public IReadOnlyList<Role> GetUserRoles(Snowflake id) => TryGetMember(id)?
|
|
|
|
|
.RoleIds
|
|
|
|
|
.Select(TryGetRole)
|
|
|
|
|
.WhereNotNull()
|
|
|
|
|
.OrderByDescending(r => r.Position)
|
|
|
|
|
.ToArray() ?? Array.Empty<Role>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Color? TryGetUserColor(Snowflake id) => GetUserRoles(id)
|
|
|
|
|
.Where(r => r.Color is not null)
|
|
|
|
|
.Select(r => r.Color)
|
|
|
|
|
.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
public async ValueTask<string> ResolveAssetUrlAsync(string url, CancellationToken cancellationToken = default)
|
|
|
|
|
{
|
|
|
|
@ -122,7 +112,7 @@ internal class ExportContext
|
|
|
|
|
var relativeFilePath = Path.GetRelativePath(Request.OutputDirPath, filePath);
|
|
|
|
|
|
|
|
|
|
// Prefer relative paths so that the output files can be copied around without breaking references.
|
|
|
|
|
// If the assets path is outside of the export directory, use an absolute path instead.
|
|
|
|
|
// If the asset directory is outside of the export directory, use an absolute path instead.
|
|
|
|
|
var optimalFilePath =
|
|
|
|
|
relativeFilePath.StartsWith(".." + Path.DirectorySeparatorChar, StringComparison.Ordinal) ||
|
|
|
|
|
relativeFilePath.StartsWith(".." + Path.AltDirectorySeparatorChar, StringComparison.Ordinal)
|
|
|
|
|