Changed (almost) all responses to make them use the new system instead of raw strings

- Fixed many invalid string keys
This commit is contained in:
Kwoth
2021-07-30 22:42:10 +02:00
parent 4484732f5d
commit 919bedeae6
80 changed files with 883 additions and 859 deletions

View File

@@ -26,7 +26,7 @@ namespace NadekoBot.Modules.Searches
if (novelData is null)
{
await ReplyErrorLocalizedAsync("failed_finding_novel").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.failed_finding_novel).ConfigureAwait(false);
return;
}
@@ -39,7 +39,8 @@ namespace NadekoBot.Modules.Searches
.AddField(GetText(strs.authors), string.Join("\n", novelData.Authors), true)
.AddField(GetText(strs.status), novelData.Status, true)
.AddField(GetText(strs.genres), string.Join(" ", novelData.Genres.Any() ? novelData.Genres : new[] { "none" }), true)
.WithFooter(GetText("score" + " " + novelData.Score));
.WithFooter($"{GetText(strs.score)} {novelData.Score}");
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
}
@@ -146,7 +147,7 @@ namespace NadekoBot.Modules.Searches
if (animeData is null)
{
await ReplyErrorLocalizedAsync("failed_finding_anime").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.failed_finding_anime).ConfigureAwait(false);
return;
}
@@ -159,7 +160,7 @@ namespace NadekoBot.Modules.Searches
.AddField(GetText(strs.episodes), animeData.TotalEpisodes.ToString(), true)
.AddField(GetText(strs.status), animeData.AiringStatus.ToString(), true)
.AddField(GetText(strs.genres), string.Join(",\n", animeData.Genres.Any() ? animeData.Genres : new[] { "none" }), true)
.WithFooter(GetText("score" + " " + animeData.AverageScore + " / 100"));
.WithFooter($"{GetText(strs.score)} {animeData.AverageScore} / 100");
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
}
@@ -174,7 +175,7 @@ namespace NadekoBot.Modules.Searches
if (mangaData is null)
{
await ReplyErrorLocalizedAsync("failed_finding_manga").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.failed_finding_manga).ConfigureAwait(false);
return;
}
@@ -187,7 +188,7 @@ namespace NadekoBot.Modules.Searches
.AddField(GetText(strs.chapters), mangaData.TotalChapters.ToString(), true)
.AddField(GetText(strs.status), mangaData.PublishingStatus.ToString(), true)
.AddField(GetText(strs.genres), string.Join(",\n", mangaData.Genres.Any() ? mangaData.Genres : new[] { "none" }), true)
.WithFooter(GetText("score" + " " + mangaData.AverageScore + " / 100"));
.WithFooter($"{GetText(strs.score)} {mangaData.AverageScore} / 100");
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
}

View File

@@ -34,7 +34,7 @@ namespace NadekoBot.Modules.Searches
if (crypto is null)
{
await ReplyErrorLocalizedAsync("crypto_not_found").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.crypto_not_found).ConfigureAwait(false);
return;
}

View File

@@ -41,12 +41,12 @@ namespace NadekoBot.Modules.Searches
success = _service.AddFeed(ctx.Guild.Id, channel.Id, url);
if (success)
{
await ReplyConfirmLocalizedAsync("feed_added").ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.feed_added).ConfigureAwait(false);
return;
}
}
await ReplyErrorLocalizedAsync("feed_not_valid").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.feed_not_valid).ConfigureAwait(false);
}
[NadekoCommand, Aliases]
@@ -56,10 +56,10 @@ namespace NadekoBot.Modules.Searches
{
if (_service.RemoveFeed(ctx.Guild.Id, --index))
{
await ReplyConfirmLocalizedAsync("feed_removed").ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.feed_removed).ConfigureAwait(false);
}
else
await ReplyErrorLocalizedAsync("feed_out_of_range").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.feed_out_of_range).ConfigureAwait(false);
}
[NadekoCommand, Aliases]

View File

@@ -38,7 +38,7 @@ namespace NadekoBot.Modules.Searches
{
if (!_service.WowJokes.Any())
{
await ReplyErrorLocalizedAsync("jokes_not_loaded").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.jokes_not_loaded).ConfigureAwait(false);
return;
}
var joke = _service.WowJokes[new NadekoRandom().Next(0, _service.WowJokes.Count)];
@@ -50,7 +50,7 @@ namespace NadekoBot.Modules.Searches
{
if (!_service.WowJokes.Any())
{
await ReplyErrorLocalizedAsync("magicitems_not_loaded").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.magicitems_not_loaded).ConfigureAwait(false);
return;
}
var item = _service.MagicItems[new NadekoRandom().Next(0, _service.MagicItems.Count)];

View File

@@ -45,7 +45,7 @@ namespace NadekoBot.Modules.Searches
{
if (string.IsNullOrWhiteSpace(_creds.OsuApiKey))
{
await ReplyErrorLocalizedAsync("osu_api_key").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.osu_api_key).ConfigureAwait(false);
return;
}
@@ -57,7 +57,7 @@ namespace NadekoBot.Modules.Searches
if (objs.Count == 0)
{
await ReplyErrorLocalizedAsync("osu_user_not_found").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.osu_user_not_found).ConfigureAwait(false);
return;
}
@@ -79,11 +79,11 @@ namespace NadekoBot.Modules.Searches
}
catch (ArgumentOutOfRangeException)
{
await ReplyErrorLocalizedAsync("osu_user_not_found").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.osu_user_not_found).ConfigureAwait(false);
}
catch (Exception ex)
{
await ReplyErrorLocalizedAsync("osu_failed").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.osu_failed).ConfigureAwait(false);
Log.Warning(ex, "Osu command failed");
}
}
@@ -106,7 +106,7 @@ namespace NadekoBot.Modules.Searches
var statsResponse = JsonConvert.DeserializeObject<GatariUserStatsResponse>(resString);
if (statsResponse.Code != 200 || statsResponse.Stats.Id == 0)
{
await ReplyErrorLocalizedAsync("osu_user_not_found").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.osu_user_not_found).ConfigureAwait(false);
return;
}

View File

@@ -49,7 +49,7 @@ namespace NadekoBot.Modules.Searches
return;
}
}
await ReplyErrorLocalizedAsync("pokemon_none").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.pokemon_none).ConfigureAwait(false);
}
[NadekoCommand, Aliases]
@@ -71,7 +71,7 @@ namespace NadekoBot.Modules.Searches
return;
}
}
await ReplyErrorLocalizedAsync("pokemon_ability_none").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.pokemon_ability_none).ConfigureAwait(false);
}
}
}

View File

@@ -115,20 +115,20 @@ namespace NadekoBot.Modules.Searches
var (data, err) = await _service.GetTimeDataAsync(query).ConfigureAwait(false);
if (err is not null)
{
string errorKey;
LocStr errorKey;
switch (err)
{
case TimeErrors.ApiKeyMissing:
errorKey = "api_key_missing";
errorKey = strs.api_key_missing;
break;
case TimeErrors.InvalidInput:
errorKey = "invalid_input";
errorKey = strs.invalid_input;
break;
case TimeErrors.NotFound:
errorKey = "not_found";
errorKey = strs.not_found;
break;
default:
errorKey = "error_occured";
errorKey = strs.error_occured;
break;
}
await ReplyErrorLocalizedAsync(errorKey).ConfigureAwait(false);
@@ -136,7 +136,7 @@ namespace NadekoBot.Modules.Searches
}
else if (string.IsNullOrWhiteSpace(data.TimeZoneName))
{
await ReplyErrorLocalizedAsync("timezone_db_api_key").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.timezone_db_api_key).ConfigureAwait(false);
return;
}
@@ -159,7 +159,7 @@ namespace NadekoBot.Modules.Searches
var result = (await _google.GetVideoLinksByKeywordAsync(query, 1).ConfigureAwait(false)).FirstOrDefault();
if (string.IsNullOrWhiteSpace(result))
{
await ReplyErrorLocalizedAsync("no_results").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.no_results).ConfigureAwait(false);
return;
}
@@ -177,7 +177,7 @@ namespace NadekoBot.Modules.Searches
var movie = await _service.GetMovieDataAsync(query).ConfigureAwait(false);
if (movie is null)
{
await ReplyErrorLocalizedAsync("imdb_fail").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.imdb_fail).ConfigureAwait(false);
return;
}
await ctx.Channel.EmbedAsync(_eb.Create().WithOkColor()
@@ -340,7 +340,7 @@ namespace NadekoBot.Modules.Searches
var data = await _service.GoogleSearchAsync(query);
if (data is null)
{
await ReplyErrorLocalizedAsync("no_results");
await ReplyErrorLocalizedAsync(strs.no_results);
return;
}
@@ -373,7 +373,7 @@ namespace NadekoBot.Modules.Searches
var data = await _service.DuckDuckGoSearchAsync(query);
if (data is null)
{
await ReplyErrorLocalizedAsync("no_results");
await ReplyErrorLocalizedAsync(strs.no_results);
return;
}
@@ -403,7 +403,7 @@ namespace NadekoBot.Modules.Searches
if (card is null)
{
await ReplyErrorLocalizedAsync("card_not_found").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.card_not_found).ConfigureAwait(false);
return;
}
@@ -427,7 +427,7 @@ namespace NadekoBot.Modules.Searches
if (string.IsNullOrWhiteSpace(_creds.RapidApiKey))
{
await ReplyErrorLocalizedAsync("mashape_api_missing").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.mashape_api_missing).ConfigureAwait(false);
return;
}
@@ -436,7 +436,7 @@ namespace NadekoBot.Modules.Searches
if (card is null)
{
await ReplyErrorLocalizedAsync("card_not_found").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.card_not_found).ConfigureAwait(false);
return;
}
var embed = _eb.Create().WithOkColor()
@@ -479,7 +479,7 @@ namespace NadekoBot.Modules.Searches
{
}
}
await ReplyErrorLocalizedAsync("ud_error").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.ud_error).ConfigureAwait(false);
}
@@ -509,7 +509,7 @@ namespace NadekoBot.Modules.Searches
if (!datas.Any())
{
Log.Warning("Definition not found: {Word}", word);
await ReplyErrorLocalizedAsync("define_unknown").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.define_unknown).ConfigureAwait(false);
}
@@ -606,7 +606,7 @@ namespace NadekoBot.Modules.Searches
var result = await http.GetStringAsync("https://en.wikipedia.org//w/api.php?action=query&format=json&prop=info&redirects=1&formatversion=2&inprop=url&titles=" + Uri.EscapeDataString(query)).ConfigureAwait(false);
var data = JsonConvert.DeserializeObject<WikipediaApiModel>(result);
if (data.Query.Pages[0].Missing || string.IsNullOrWhiteSpace(data.Query.Pages[0].FullUrl))
await ReplyErrorLocalizedAsync("wiki_page_not_found").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.wiki_page_not_found).ConfigureAwait(false);
else
await ctx.Channel.SendMessageAsync(data.Query.Pages[0].FullUrl).ConfigureAwait(false);
}
@@ -651,7 +651,7 @@ namespace NadekoBot.Modules.Searches
if (avatarUrl is null)
{
await ReplyErrorLocalizedAsync("avatar_none", usr.ToString()).ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.avatar_none(usr.ToString())).ConfigureAwait(false);
return;
}
@@ -666,7 +666,7 @@ namespace NadekoBot.Modules.Searches
{
if (string.IsNullOrWhiteSpace(target) || string.IsNullOrWhiteSpace(query))
{
await ReplyErrorLocalizedAsync("wikia_input_error").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.wikia_input_error).ConfigureAwait(false);
return;
}
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
@@ -686,7 +686,7 @@ namespace NadekoBot.Modules.Searches
if (string.IsNullOrWhiteSpace(title))
{
await ReplyErrorLocalizedAsync("wikia_error").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.wikia_error).ConfigureAwait(false);
return;
}
@@ -697,7 +697,7 @@ namespace NadekoBot.Modules.Searches
}
catch
{
await ReplyErrorLocalizedAsync("wikia_error").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.wikia_error).ConfigureAwait(false);
}
}
}
@@ -743,7 +743,7 @@ namespace NadekoBot.Modules.Searches
var appId = await _service.GetSteamAppIdByName(query).ConfigureAwait(false);
if (appId == -1)
{
await ReplyErrorLocalizedAsync("not_found").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.not_found).ConfigureAwait(false);
return;
}
@@ -782,7 +782,7 @@ namespace NadekoBot.Modules.Searches
return true;
}
await ErrorLocalizedAsync("specify_search_params").ConfigureAwait(false);
await ErrorLocalizedAsync(strs.specify_search_params).ConfigureAwait(false);
return false;
}
}

View File

@@ -39,7 +39,7 @@ namespace NadekoBot.Modules.Searches
var data = await _service.FollowStream(ctx.Guild.Id, ctx.Channel.Id, link);
if (data is null)
{
await ReplyErrorLocalizedAsync("stream_not_added").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.stream_not_added).ConfigureAwait(false);
return;
}
@@ -59,14 +59,14 @@ namespace NadekoBot.Modules.Searches
var fs = await _service.UnfollowStreamAsync(ctx.Guild.Id, index);
if (fs is null)
{
await ReplyErrorLocalizedAsync("stream_no").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.stream_no).ConfigureAwait(false);
return;
}
await ReplyConfirmLocalizedAsync(
"stream_removed",
Format.Bold(fs.Username),
fs.Type).ConfigureAwait(false);
strs.stream_removed(
Format.Bold(fs.Username),
fs.Type));
}
// [NadekoCommand, Usage, Description, Aliases]
@@ -75,7 +75,7 @@ namespace NadekoBot.Modules.Searches
// public async Task StreamsClear()
// {
// var count = _service.ClearAllStreams(ctx.Guild.Id);
// await ReplyConfirmLocalizedAsync("streams_cleared", count).ConfigureAwait(false);
// await ReplyErrorLocalizedAsync(strs.streams_cleared(count)));
// }
[NadekoCommand, Aliases]
@@ -146,11 +146,11 @@ namespace NadekoBot.Modules.Searches
var newValue = _service.ToggleStreamOffline(ctx.Guild.Id);
if (newValue)
{
await ReplyConfirmLocalizedAsync("stream_off_enabled").ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.stream_off_enabled).ConfigureAwait(false);
}
else
{
await ReplyConfirmLocalizedAsync("stream_off_disabled").ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.stream_off_disabled).ConfigureAwait(false);
}
}
@@ -164,19 +164,17 @@ namespace NadekoBot.Modules.Searches
if (!_service.SetStreamMessage(ctx.Guild.Id, index, message, out var fs))
{
await ReplyConfirmLocalizedAsync("stream_not_following").ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.stream_not_following).ConfigureAwait(false);
return;
}
if (string.IsNullOrWhiteSpace(message))
{
await ReplyConfirmLocalizedAsync("stream_message_reset", Format.Bold(fs.Username))
.ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.stream_message_reset(Format.Bold(fs.Username)));
}
else
{
await ReplyConfirmLocalizedAsync("stream_message_set", Format.Bold(fs.Username))
.ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.stream_message_set(Format.Bold(fs.Username)));
}
}
@@ -189,11 +187,11 @@ namespace NadekoBot.Modules.Searches
if (count == 0)
{
await ReplyConfirmLocalizedAsync("stream_not_following_any");
await ReplyConfirmLocalizedAsync(strs.stream_not_following_any);
return;
}
await ReplyConfirmLocalizedAsync("stream_message_set_all", count);
await ReplyErrorLocalizedAsync(strs.stream_message_set_all(count));
}
[NadekoCommand, Aliases]
@@ -205,26 +203,24 @@ namespace NadekoBot.Modules.Searches
var data = await _service.GetStreamDataAsync(url).ConfigureAwait(false);
if (data is null)
{
await ReplyErrorLocalizedAsync("no_channel_found").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.no_channel_found).ConfigureAwait(false);
return;
}
if (data.IsLive)
{
await ReplyConfirmLocalizedAsync("streamer_online",
Format.Bold(data.Name),
Format.Bold(data.Viewers.ToString()))
.ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.streamer_online(
Format.Bold(data.Name),
Format.Bold(data.Viewers.ToString())));
}
else
{
await ReplyConfirmLocalizedAsync("streamer_offline", data.Name)
.ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.streamer_offline(data.Name));
}
}
catch
{
await ReplyErrorLocalizedAsync("no_channel_found").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.no_channel_found).ConfigureAwait(false);
}
}
}

View File

@@ -34,7 +34,7 @@ namespace NadekoBot.Modules.Searches
}
catch
{
await ReplyErrorLocalizedAsync("bad_input_format").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.bad_input_format).ConfigureAwait(false);
}
}
@@ -76,18 +76,18 @@ namespace NadekoBot.Modules.Searches
if (autoDelete == AutoDeleteAutoTranslate.Del)
{
_searches.TranslatedChannels.AddOrUpdate(channel.Id, true, (key, val) => true);
await ReplyConfirmLocalizedAsync("atl_ad_started").ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.atl_ad_started).ConfigureAwait(false);
return;
}
if (_searches.TranslatedChannels.TryRemove(channel.Id, out _))
{
await ReplyConfirmLocalizedAsync("atl_stopped").ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.atl_stopped).ConfigureAwait(false);
return;
}
if (_searches.TranslatedChannels.TryAdd(channel.Id, autoDelete == AutoDeleteAutoTranslate.Del))
{
await ReplyConfirmLocalizedAsync("atl_started").ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.atl_started).ConfigureAwait(false);
}
}
@@ -100,7 +100,7 @@ namespace NadekoBot.Modules.Searches
if (string.IsNullOrWhiteSpace(langs))
{
if (_searches.UserLanguages.TryRemove(ucp, out langs))
await ReplyConfirmLocalizedAsync("atl_removed").ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.atl_removed).ConfigureAwait(false);
return;
}
@@ -112,13 +112,13 @@ namespace NadekoBot.Modules.Searches
if (!_google.Languages.Contains(from) || !_google.Languages.Contains(to))
{
await ReplyErrorLocalizedAsync("invalid_lang").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.invalid_lang).ConfigureAwait(false);
return;
}
_searches.UserLanguages.AddOrUpdate(ucp, langs, (key, val) => langs);
await ReplyConfirmLocalizedAsync("atl_set", from, to).ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.atl_set(from, to));
}
[NadekoCommand, Aliases]

View File

@@ -49,7 +49,7 @@ namespace NadekoBot.Modules.Searches
}
catch (HttpRequestException)
{
await ReplyErrorLocalizedAsync("comic_not_found").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.comic_not_found).ConfigureAwait(false);
}
return;
}
@@ -86,7 +86,7 @@ namespace NadekoBot.Modules.Searches
}
catch (HttpRequestException)
{
await ReplyErrorLocalizedAsync("comic_not_found").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.comic_not_found).ConfigureAwait(false);
}
}
}

View File

@@ -16,11 +16,11 @@ namespace NadekoBot.Modules.Searches
// var succ = await _service.ToggleChannelFollowAsync(ctx.Guild.Id, ctx.Channel.Id, ytChannelId, uploadMessage);
// if(succ)
// {
// await ReplyConfirmLocalizedAsync("yt_follow_added").ConfigureAwait(false);
// await ReplyConfirmLocalizedAsync(strs.yt_follow_added).ConfigureAwait(false);
// }
// else
// {
// await ReplyConfirmLocalizedAsync("yt_follow_fail").ConfigureAwait(false);
// await ReplyConfirmLocalizedAsync(strs.yt_follow_fail).ConfigureAwait(false);
// }
// }
//
@@ -31,11 +31,11 @@ namespace NadekoBot.Modules.Searches
// //var succ = await _service.ToggleChannelTrackingAsync(ctx.Guild.Id, ctx.Channel.Id, ytChannelId, uploadMessage);
// //if (succ)
// //{
// // await ReplyConfirmLocalizedAsync("yt_track_added").ConfigureAwait(false);
// // await ReplyConfirmLocalizedAsync(strs.yt_track_added).ConfigureAwait(false);
// //}
// //else
// //{
// // await ReplyConfirmLocalizedAsync("yt_track_fail").ConfigureAwait(false);
// // await ReplyConfirmLocalizedAsync(strs.yt_track_fail).ConfigureAwait(false);
// //}
// }
//
@@ -46,11 +46,11 @@ namespace NadekoBot.Modules.Searches
// //var succ = await _service.ToggleChannelTrackingAsync(ctx.Guild.Id, ctx.Channel.Id, ytChannelId, uploadMessage);
// //if (succ)
// //{
// // await ReplyConfirmLocalizedAsync("yt_track_added").ConfigureAwait(false);
// // await ReplyConfirmLocalizedAsync(strs.yt_track_added).ConfigureAwait(false);
// //}
// //else
// //{
// // await ReplyConfirmLocalizedAsync("yt_track_fail").ConfigureAwait(false);
// // await ReplyConfirmLocalizedAsync(strs.yt_track_fail).ConfigureAwait(false);
// //}
// }
// }