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

@@ -37,7 +37,7 @@ namespace NadekoBot.Modules.Utility
public async Task AliasesClear()
{
var count = _service.ClearAliases(ctx.Guild.Id);
await ReplyConfirmLocalizedAsync("aliases_cleared", count).ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.aliases_cleared(count));
}
[NadekoCommand, Aliases]
@@ -57,7 +57,7 @@ namespace NadekoBot.Modules.Utility
if (!_service.AliasMaps.TryGetValue(ctx.Guild.Id, out var maps) ||
!maps.TryRemove(trigger, out _))
{
await ReplyErrorLocalizedAsync("alias_remove_fail", Format.Code(trigger)).ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.alias_remove_fail(Format.Code(trigger))).ConfigureAwait(false);
return;
}
@@ -75,7 +75,7 @@ namespace NadekoBot.Modules.Utility
uow.SaveChanges();
}
await ReplyConfirmLocalizedAsync("alias_removed", Format.Code(trigger)).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.alias_removed(Format.Code(trigger))).ConfigureAwait(false);
return;
}
_service.AliasMaps.AddOrUpdate(ctx.Guild.Id, (_) =>
@@ -113,7 +113,7 @@ namespace NadekoBot.Modules.Utility
return map;
});
await ReplyConfirmLocalizedAsync("alias_added", Format.Code(trigger), Format.Code(mapping)).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.alias_added(Format.Code(trigger), Format.Code(mapping))).ConfigureAwait(false);
}
@@ -129,7 +129,7 @@ namespace NadekoBot.Modules.Utility
if (!_service.AliasMaps.TryGetValue(ctx.Guild.Id, out var maps) || !maps.Any())
{
await ReplyErrorLocalizedAsync("aliases_none").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.aliases_none).ConfigureAwait(false);
return;
}

View File

@@ -162,7 +162,7 @@ namespace NadekoBot.Modules.Utility
if (!success)
{
await ReplyErrorLocalizedAsync("config_edit_fail", Format.Code(prop), Format.Code(value));
await ReplyErrorLocalizedAsync(strs.config_edit_fail(Format.Code(prop), Format.Code(value)));
return;
}

View File

@@ -30,7 +30,7 @@ namespace NadekoBot.Modules.Utility
if (DateTime.UtcNow.Day < 5)
{
await ReplyErrorLocalizedAsync("clpa_too_early").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.clpa_too_early).ConfigureAwait(false);
return;
}

View File

@@ -52,7 +52,7 @@ namespace NadekoBot.Modules.Utility
string.Join("\n", quotes.Select(q => $"`#{q.Id}` {Format.Bold(q.Keyword.SanitizeAllMentions()),-20} by {q.AuthorName.SanitizeAllMentions()}")))
.ConfigureAwait(false);
else
await ReplyErrorLocalizedAsync("quotes_page_none").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.quotes_page_none).ConfigureAwait(false);
}
[NadekoCommand, Aliases]
@@ -96,13 +96,13 @@ namespace NadekoBot.Modules.Utility
using (var uow = _db.GetDbContext())
{
quote = uow.Quotes.GetById(id);
if (quote.GuildId != ctx.Guild.Id)
if (quote?.GuildId != ctx.Guild.Id)
quote = null;
}
if (quote is null)
{
await ReplyErrorLocalizedAsync("quote_no_found_id");
await ReplyErrorLocalizedAsync(strs.quotes_notfound);
return;
}
@@ -198,7 +198,7 @@ namespace NadekoBot.Modules.Utility
});
await uow.SaveChangesAsync();
}
await ReplyConfirmLocalizedAsync("quote_added_new", Format.Code(q.Id.ToString())).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.quote_added_new(Format.Code(q.Id.ToString()))).ConfigureAwait(false);
}
[NadekoCommand, Aliases]
@@ -248,7 +248,7 @@ namespace NadekoBot.Modules.Utility
await uow.SaveChangesAsync();
}
await ReplyConfirmLocalizedAsync("quotes_deleted", Format.Bold(keyword.SanitizeAllMentions())).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.quotes_deleted(Format.Bold(keyword.SanitizeAllMentions()))).ConfigureAwait(false);
}
}
}

View File

@@ -40,7 +40,7 @@ namespace NadekoBot.Modules.Utility
{
if (!_service.TryParseRemindMessage(remindString, out var remindData))
{
await ReplyErrorLocalizedAsync("remind_invalid");
await ReplyErrorLocalizedAsync(strs.remind_invalid);
return;
}
@@ -49,7 +49,7 @@ namespace NadekoBot.Modules.Utility
if (!await RemindInternal(target, meorhere == MeOrHere.Me || ctx.Guild is null, remindData.Time, remindData.What)
.ConfigureAwait(false))
{
await ReplyErrorLocalizedAsync("remind_too_long").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.remind_too_long).ConfigureAwait(false);
}
}
@@ -62,13 +62,13 @@ namespace NadekoBot.Modules.Utility
var perms = ((IGuildUser) ctx.User).GetPermissions(channel);
if (!perms.SendMessages || !perms.ViewChannel)
{
await ReplyErrorLocalizedAsync("cant_read_or_send").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.cant_read_or_send).ConfigureAwait(false);
return;
}
if (!_service.TryParseRemindMessage(remindString, out var remindData))
{
await ReplyErrorLocalizedAsync("remind_invalid");
await ReplyErrorLocalizedAsync(strs.remind_invalid);
return;
}
@@ -76,7 +76,7 @@ namespace NadekoBot.Modules.Utility
if (!await RemindInternal(channel.Id, false, remindData.Time, remindData.What)
.ConfigureAwait(false))
{
await ReplyErrorLocalizedAsync("remind_too_long").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.remind_too_long).ConfigureAwait(false);
}
}
@@ -144,11 +144,11 @@ namespace NadekoBot.Modules.Utility
if (rem is null)
{
await ReplyErrorLocalizedAsync("reminder_not_exist").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.reminder_not_exist).ConfigureAwait(false);
}
else
{
await ReplyErrorLocalizedAsync("reminder_deleted", index + 1).ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.reminder_deleted(index + 1));
}
}

View File

@@ -28,7 +28,7 @@ namespace NadekoBot.Modules.Utility
var success = await _service.TriggerExternal(ctx.Guild.Id, index);
if (!success)
{
await ReplyErrorLocalizedAsync("repeat_invoke_none").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.repeat_invoke_none).ConfigureAwait(false);
}
}
@@ -43,7 +43,7 @@ namespace NadekoBot.Modules.Utility
var removed = await _service.RemoveByIndexAsync(ctx.Guild.Id, index);
if (removed is null)
{
await ReplyErrorLocalizedAsync("repeater_remove_fail").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.repeater_remove_fail).ConfigureAwait(false);
return;
}
@@ -66,17 +66,17 @@ namespace NadekoBot.Modules.Utility
if (result is null)
{
await ReplyErrorLocalizedAsync("index_out_of_range").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.index_out_of_range).ConfigureAwait(false);
return;
}
if (result.Value)
{
await ReplyConfirmLocalizedAsync("repeater_redundant_no", index + 1);
await ReplyErrorLocalizedAsync(strs.repeater_redundant_no(index + 1));
}
else
{
await ReplyConfirmLocalizedAsync("repeater_redundant_yes" ,index + 1);
await ReplyConfirmLocalizedAsync(strs.repeater_redundant_yes(index + 1));
}
}
@@ -139,7 +139,7 @@ namespace NadekoBot.Modules.Utility
if (runner is null)
{
await ReplyErrorLocalizedAsync("repeater_exceed_limit", 5);
await ReplyErrorLocalizedAsync(strs.repeater_exceed_limit(5));
return;
}
@@ -158,7 +158,7 @@ namespace NadekoBot.Modules.Utility
var repeaters = _service.GetRepeaters(ctx.Guild.Id);
if (repeaters.Count == 0)
{
await ReplyConfirmLocalizedAsync("repeaters_none").ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.repeaters_none).ConfigureAwait(false);
return;
}

View File

@@ -20,7 +20,7 @@ namespace NadekoBot.Modules.Utility
{
await this._service.SetStreamRole(fromRole, addRole).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync("stream_role_enabled", Format.Bold(fromRole.ToString()), Format.Bold(addRole.ToString())).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.stream_role_enabled(Format.Bold(fromRole.ToString()), Format.Bold(addRole.ToString()))).ConfigureAwait(false);
}
[NadekoCommand, Aliases]
@@ -30,7 +30,7 @@ namespace NadekoBot.Modules.Utility
public async Task StreamRole()
{
await this._service.StopStreamRole(ctx.Guild).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync("stream_role_disabled").ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.stream_role_disabled).ConfigureAwait(false);
}
[NadekoCommand, Aliases]
@@ -42,9 +42,9 @@ namespace NadekoBot.Modules.Utility
string kw = await this._service.SetKeyword(ctx.Guild, keyword).ConfigureAwait(false);
if(string.IsNullOrWhiteSpace(keyword))
await ReplyConfirmLocalizedAsync("stream_role_kw_reset").ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.stream_role_kw_reset).ConfigureAwait(false);
else
await ReplyConfirmLocalizedAsync("stream_role_kw_set", Format.Bold(kw)).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.stream_role_kw_set(Format.Bold(kw))).ConfigureAwait(false);
}
[NadekoCommand, Aliases]
@@ -58,14 +58,14 @@ namespace NadekoBot.Modules.Utility
if(action == AddRemove.Add)
if(success)
await ReplyConfirmLocalizedAsync("stream_role_bl_add", Format.Bold(user.ToString())).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.stream_role_bl_add(Format.Bold(user.ToString()))).ConfigureAwait(false);
else
await ReplyConfirmLocalizedAsync("stream_role_bl_add_fail", Format.Bold(user.ToString())).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.stream_role_bl_add_fail(Format.Bold(user.ToString()))).ConfigureAwait(false);
else
if (success)
await ReplyConfirmLocalizedAsync("stream_role_bl_rem", Format.Bold(user.ToString())).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.stream_role_bl_rem(Format.Bold(user.ToString()))).ConfigureAwait(false);
else
await ReplyErrorLocalizedAsync("stream_role_bl_rem_fail", Format.Bold(user.ToString())).ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.stream_role_bl_rem_fail(Format.Bold(user.ToString()))).ConfigureAwait(false);
}
[NadekoCommand, Aliases]
@@ -79,14 +79,14 @@ namespace NadekoBot.Modules.Utility
if (action == AddRemove.Add)
if(success)
await ReplyConfirmLocalizedAsync("stream_role_wl_add", Format.Bold(user.ToString())).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.stream_role_wl_add(Format.Bold(user.ToString()))).ConfigureAwait(false);
else
await ReplyConfirmLocalizedAsync("stream_role_wl_add_fail", Format.Bold(user.ToString())).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.stream_role_wl_add_fail(Format.Bold(user.ToString()))).ConfigureAwait(false);
else
if (success)
await ReplyConfirmLocalizedAsync("stream_role_wl_rem", Format.Bold(user.ToString())).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.stream_role_wl_rem(Format.Bold(user.ToString()))).ConfigureAwait(false);
else
await ReplyErrorLocalizedAsync("stream_role_wl_rem_fail", Format.Bold(user.ToString())).ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.stream_role_wl_rem_fail(Format.Bold(user.ToString()))).ConfigureAwait(false);
}
}
}

View File

@@ -42,12 +42,12 @@ namespace NadekoBot.Modules.Utility
var targetUnit = _service.Units.FirstOrDefault(x => x.Triggers.Select(y => y.ToUpperInvariant()).Contains(target.ToUpperInvariant()));
if (originUnit is null || targetUnit is null)
{
await ReplyErrorLocalizedAsync("convert_not_found", Format.Bold(origin), Format.Bold(target)).ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.convert_not_found(Format.Bold(origin), Format.Bold(target))).ConfigureAwait(false);
return;
}
if (originUnit.UnitType != targetUnit.UnitType)
{
await ReplyErrorLocalizedAsync("convert_type_error", Format.Bold(originUnit.Triggers.First()), Format.Bold(targetUnit.Triggers.First())).ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.convert_type_error(Format.Bold(originUnit.Triggers.First()), Format.Bold(targetUnit.Triggers.First()))).ConfigureAwait(false);
return;
}
decimal res;

View File

@@ -81,7 +81,7 @@ namespace NadekoBot.Modules.Utility
int i = 0;
if (arr.Length == 0)
await ReplyErrorLocalizedAsync("nobody_playing_game").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.nobody_playing_game).ConfigureAwait(false);
else
{
await SendConfirmAsync("```css\n" + string.Join("\n", arr.GroupBy(item => (i++) / 2)
@@ -117,7 +117,7 @@ namespace NadekoBot.Modules.Utility
return _eb.Create().WithOkColor().WithDescription(GetText(strs.no_user_on_this_page));
return _eb.Create().WithOkColor()
.WithTitle(GetText(strs.inrole_list(Format.Bold(role?.Name ?? "No Role")) + $" - {roleUsers.Length}"))
.WithTitle(GetText(strs.inrole_list(Format.Bold(role?.Name ?? "No Role") + $" - {roleUsers.Length}")))
.WithDescription(string.Join("\n", pageUsers));
}, roleUsers.Length, 20).ConfigureAwait(false);
}
@@ -151,31 +151,29 @@ namespace NadekoBot.Modules.Utility
public async Task UserId([Leftover] IGuildUser target = null)
{
var usr = target ?? ctx.User;
await ReplyConfirmLocalizedAsync("userid", "🆔", Format.Bold(usr.ToString()),
Format.Code(usr.Id.ToString())).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.userid("🆔", Format.Bold(usr.ToString()),
Format.Code(usr.Id.ToString())));
}
[NadekoCommand, Aliases]
[RequireContext(ContextType.Guild)]
public async Task RoleId([Leftover] IRole role)
{
await ReplyConfirmLocalizedAsync("roleid", "🆔", Format.Bold(role.ToString()),
Format.Code(role.Id.ToString())).ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.roleid("🆔", Format.Bold(role.ToString()),
Format.Code(role.Id.ToString())));
}
[NadekoCommand, Aliases]
public async Task ChannelId()
{
await ReplyConfirmLocalizedAsync("channelid", "🆔", Format.Code(ctx.Channel.Id.ToString()))
.ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.channelid("🆔", Format.Code(ctx.Channel.Id.ToString())));
}
[NadekoCommand, Aliases]
[RequireContext(ContextType.Guild)]
public async Task ServerId()
{
await ReplyConfirmLocalizedAsync("serverid", "🆔", Format.Code(ctx.Guild.Id.ToString()))
.ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.serverid("🆔", Format.Code(ctx.Guild.Id.ToString())));
}
[NadekoCommand, Aliases]
@@ -194,7 +192,7 @@ namespace NadekoBot.Modules.Utility
var roles = target.GetRoles().Except(new[] { guild.EveryoneRole }).OrderBy(r => -r.Position).Skip((page - 1) * rolesPerPage).Take(rolesPerPage).ToArray();
if (!roles.Any())
{
await ReplyErrorLocalizedAsync("no_roles_on_page").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.no_roles_on_page).ConfigureAwait(false);
}
else
{
@@ -208,7 +206,7 @@ namespace NadekoBot.Modules.Utility
var roles = guild.Roles.Except(new[] { guild.EveryoneRole }).OrderBy(r => -r.Position).Skip((page - 1) * rolesPerPage).Take(rolesPerPage).ToArray();
if (!roles.Any())
{
await ReplyErrorLocalizedAsync("no_roles_on_page").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.no_roles_on_page).ConfigureAwait(false);
}
else
{
@@ -232,7 +230,7 @@ namespace NadekoBot.Modules.Utility
var topic = channel.Topic;
if (string.IsNullOrWhiteSpace(topic))
await ReplyErrorLocalizedAsync("no_topic_set").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.no_topic_set).ConfigureAwait(false);
else
await SendConfirmAsync(GetText(strs.channel_topic), topic).ConfigureAwait(false);
}
@@ -272,7 +270,7 @@ namespace NadekoBot.Modules.Utility
var result = string.Join("\n", tags.Select(m => GetText(strs.showemojis(m, m.Url))));
if (string.IsNullOrWhiteSpace(result))
await ReplyErrorLocalizedAsync("showemojis_none").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.showemojis_none).ConfigureAwait(false);
else
await ctx.Channel.SendMessageAsync(result.TrimTo(2000)).ConfigureAwait(false);
}
@@ -290,7 +288,7 @@ namespace NadekoBot.Modules.Utility
if (!guilds.Any())
{
await ReplyErrorLocalizedAsync("listservers_none").ConfigureAwait(false);
await ReplyErrorLocalizedAsync(strs.listservers_none).ConfigureAwait(false);
return;
}
@@ -382,7 +380,7 @@ namespace NadekoBot.Modules.Utility
// {
// if (_inviteService.TryGetInvite(type, out var code))
// {
// await ReplyConfirmLocalizedAsync("your_invite", $"https://discord.gg/{code}");
// await ReplyErrorLocalizedAsync(strs.your_invite($"https://discord.gg/{code}"));
// return;
// }
// }

View File

@@ -19,9 +19,9 @@ namespace NadekoBot.Modules.Utility
var state = _service.ToggleVerboseErrors(ctx.Guild.Id, newstate);
if (state)
await ReplyConfirmLocalizedAsync("verbose_errors_enabled").ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.verbose_errors_enabled).ConfigureAwait(false);
else
await ReplyConfirmLocalizedAsync("verbose_errors_disabled").ConfigureAwait(false);
await ReplyConfirmLocalizedAsync(strs.verbose_errors_disabled).ConfigureAwait(false);
}
}
}