Browse Source

fix command parsing for context command names with space char

pull/2395/head
Cenngo 2 years ago
parent
commit
b5071ab347
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      src/Discord.Net.Interactions/LocalizationManagers/JsonLocalizationManager.cs

+ 3
- 1
src/Discord.Net.Interactions/LocalizationManagers/JsonLocalizationManager.cs View File

@@ -3,6 +3,7 @@ using Newtonsoft.Json.Linq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;


@@ -15,6 +16,7 @@ namespace Discord.Interactions
{ {
private const string NameIdentifier = "name"; private const string NameIdentifier = "name";
private const string DescriptionIdentifier = "description"; private const string DescriptionIdentifier = "description";
private const string SpaceToken = "~";


private readonly string _basePath; private readonly string _basePath;
private readonly string _fileName; private readonly string _fileName;
@@ -58,7 +60,7 @@ namespace Discord.Interactions
using var sr = new StreamReader(file); using var sr = new StreamReader(file);
using var jr = new JsonTextReader(sr); using var jr = new JsonTextReader(sr);
var obj = JObject.Load(jr); var obj = JObject.Load(jr);
var token = string.Join(".", key) + $".{identifier}";
var token = string.Join(".", key.Select(x => $"['{x}']")) + $".{identifier}";
var value = (string)obj.SelectToken(token); var value = (string)obj.SelectToken(token);
if (value is not null) if (value is not null)
result[locale] = value; result[locale] = value;


Loading…
Cancel
Save