Skip to content

Commit 7289969

Browse files
committed
#336: Settings Command List
Account for the fact that cached values is a dictionary of strings and JsonElements, 1.1.0 of Configuration should address this issue and it will be removed in a future release
1 parent 79ea416 commit 7289969

File tree

1 file changed

+11
-1
lines changed
  • services/grid-bot/lib/commands/PrivateModules/Commands

1 file changed

+11
-1
lines changed

services/grid-bot/lib/commands/PrivateModules/Commands/Settings.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ namespace Grid.Bot.Commands.Private;
1919

2020
using Utility;
2121
using Extensions;
22+
using System.Text.Json;
23+
2224

2325
/// <summary>
2426
/// Represents the interaction for settings.
@@ -137,7 +139,15 @@ public async Task GetAllAsync(string provider, bool refresh = true)
137139

138140
if (refresh) instance.Refresh();
139141

140-
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(instance.GetRawValues(), Formatting.Indented)));
142+
/* FIXME: This is stupid, update 1.1.0 on Configuration should convert these on each refresh instead of placing a JE dict in cache. */
143+
144+
var values = new Dictionary<string, string>();
145+
146+
foreach (var kvp in instance.GetRawValues())
147+
if (kvp.Value is JsonElement element)
148+
values.Add(kvp.Key, element.GetString());
149+
150+
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(values, Formatting.Indented)));
141151

142152
await this.ReplyWithFileAsync(stream, $"{provider}.json", "Here are the settings for the specified provider.");
143153
}

0 commit comments

Comments
 (0)