[Activity] Add CDN refresh
This commit is contained in:
@@ -40,7 +40,7 @@ public class ActivityFormatter
|
|||||||
|
|
||||||
public static string GetActivityBanner(ActivityName activityName)
|
public static string GetActivityBanner(ActivityName activityName)
|
||||||
{
|
{
|
||||||
return $"https://sage.cdn.ilysix.fr/assets/Cocotte/banner/{GetActivityCode(activityName)}.webp";
|
return CdnUtils.GetAsset($"banner/{GetActivityCode(activityName)}.webp");
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmbedBuilder ActivityEmbed(Activity activity, IReadOnlyCollection<ActivityPlayer> players)
|
public EmbedBuilder ActivityEmbed(Activity activity, IReadOnlyCollection<ActivityPlayer> players)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Cocotte.Modules.Activities.Models;
|
using Cocotte.Modules.Activities.Models;
|
||||||
|
using Cocotte.Utils;
|
||||||
|
|
||||||
namespace Cocotte.Modules.Activities;
|
namespace Cocotte.Modules.Activities;
|
||||||
|
|
||||||
@@ -24,7 +25,6 @@ public class InterstellarFormatter
|
|||||||
|
|
||||||
public string GetColorIcon(InterstellarColor color)
|
public string GetColorIcon(InterstellarColor color)
|
||||||
{
|
{
|
||||||
return
|
return CdnUtils.GetAsset($"icons/tof/gate/gate_{color.ToString().ToLowerInvariant()}.webp");
|
||||||
$"https://sage.cdn.ilysix.fr/assets/Cocotte/icons/tof/gate/gate_{color.ToString().ToLowerInvariant()}.webp";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
19
Cocotte/Utils/CdnUtils.cs
Normal file
19
Cocotte/Utils/CdnUtils.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
namespace Cocotte.Utils;
|
||||||
|
|
||||||
|
public class CdnUtils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Use this to force discord media cache to fetch new content from CDN
|
||||||
|
/// </summary>
|
||||||
|
private const string QuerySuffix = $"?q={RandomSuffix}";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Needs to be updated each time a media is updated on the CDN
|
||||||
|
/// </summary>
|
||||||
|
private const string RandomSuffix = "a57z45a";
|
||||||
|
|
||||||
|
public static string GetAsset(string assetName)
|
||||||
|
{
|
||||||
|
return $"https://sage.cdn.ilysix.fr/assets/Cocotte/{assetName}{QuerySuffix}";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ public static class EmbedUtils
|
|||||||
.WithColor(Colors.ErrorColor)
|
.WithColor(Colors.ErrorColor)
|
||||||
.WithAuthor(a => a
|
.WithAuthor(a => a
|
||||||
.WithName(title)
|
.WithName(title)
|
||||||
.WithIconUrl("https://sage.cdn.ilysix.fr/assets/Cocotte/icons/error.webp")
|
.WithIconUrl(CdnUtils.GetAsset("icons/error.webp"))
|
||||||
)
|
)
|
||||||
.WithDescription(message);
|
.WithDescription(message);
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ public static class EmbedUtils
|
|||||||
.WithColor(Colors.InfoColor)
|
.WithColor(Colors.InfoColor)
|
||||||
.WithAuthor(a => a
|
.WithAuthor(a => a
|
||||||
.WithName(title)
|
.WithName(title)
|
||||||
.WithIconUrl("https://sage.cdn.ilysix.fr/assets/Cocotte/icons/info.webp")
|
.WithIconUrl(CdnUtils.GetAsset("icons/info.webp"))
|
||||||
)
|
)
|
||||||
.WithDescription(message);
|
.WithDescription(message);
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ public static class EmbedUtils
|
|||||||
.WithColor(Colors.SuccessColor)
|
.WithColor(Colors.SuccessColor)
|
||||||
.WithAuthor(a => a
|
.WithAuthor(a => a
|
||||||
.WithName(title)
|
.WithName(title)
|
||||||
.WithIconUrl("https://sage.cdn.ilysix.fr/assets/Cocotte/icons/success.webp")
|
.WithIconUrl(CdnUtils.GetAsset("icons/success.webp"))
|
||||||
)
|
)
|
||||||
.WithDescription(message);
|
.WithDescription(message);
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ public static class EmbedUtils
|
|||||||
.WithColor(Colors.WarningColor)
|
.WithColor(Colors.WarningColor)
|
||||||
.WithAuthor(a => a
|
.WithAuthor(a => a
|
||||||
.WithName(title)
|
.WithName(title)
|
||||||
.WithIconUrl("https://sage.cdn.ilysix.fr/assets/Cocotte/icons/warning.webp")
|
.WithIconUrl(CdnUtils.GetAsset("icons/warning.webp"))
|
||||||
)
|
)
|
||||||
.WithDescription(message);
|
.WithDescription(message);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user