Skip to content

Commit

Permalink
fix: really fix translation export
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Jan 16, 2024
1 parent 0d4d471 commit 59ad839
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions DisCatSharp.ApplicationCommands/ApplicationCommandsExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ private async Task RegisterCommands(List<ApplicationCommandsModuleConfiguration>
{
updateList = updateList.DistinctBy(x => x.Name).ToList();
if (Configuration.GenerateTranslationFilesOnly)
await this.CheckRegistrationStartup(translation, groupTranslation);
await this.CheckRegistrationStartup(translation, groupTranslation, guildId);
else
try
{
Expand Down Expand Up @@ -964,15 +964,16 @@ private async Task RegisterCommands(List<ApplicationCommandsModuleConfiguration>
/// </summary>
/// <param name="translation">The optional translations.</param>
/// <param name="groupTranslation">The optional group translations.</param>
private async Task CheckRegistrationStartup(List<CommandTranslator>? translation = null, List<GroupTranslator>? groupTranslation = null)
/// <param name="guildId">The optional guild id.</param>
private async Task CheckRegistrationStartup(List<CommandTranslator>? translation = null, List<GroupTranslator>? groupTranslation = null, ulong? guildId = null)
{
if (Configuration.GenerateTranslationFilesOnly)
{
try
{
if (translation is not null && translation.Count is not 0)
{
var fileName = $"translation_generator_export-shard{this.Client.ShardId}-SINGLE.json";
var fileName = $"translation_generator_export-shard{this.Client.ShardId}-SINGLE-{(guildId.HasValue ? guildId.Value : "global")}.json";
var fs = File.Create(fileName);
var ms = new MemoryStream();
var writer = new StreamWriter(ms);
Expand All @@ -990,7 +991,7 @@ private async Task CheckRegistrationStartup(List<CommandTranslator>? translation

if (groupTranslation is not null && groupTranslation.Count is not 0)
{
var fileName = $"translation_generator_export-shard{this.Client.ShardId}-GROUP.json";
var fileName = $"translation_generator_export-shard{this.Client.ShardId}-GROUP-{(guildId.HasValue ? guildId.Value : "global")}.json";
var fs = File.Create(fileName);
var ms = new MemoryStream();
var writer = new StreamWriter(ms);
Expand Down Expand Up @@ -1029,6 +1030,8 @@ private async Task CheckStartupFinishAsync(ApplicationCommandsExtension sender,
GuildsWithoutScope = s_missingScopeGuildIdsGlobal
}).ConfigureAwait(false);
FinishFired = true;
if (Configuration.GenerateTranslationFilesOnly)
Environment.Exit(0);
}

args.Handled = false;
Expand Down

0 comments on commit 59ad839

Please sign in to comment.