mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Part2 of the response system rework
This commit is contained in:
@@ -20,11 +20,11 @@ public partial class Searches
|
||||
//
|
||||
// if (novelData is null)
|
||||
// {
|
||||
// await ReplyErrorLocalizedAsync(strs.failed_finding_novel);
|
||||
// await Response().Error(strs.failed_finding_novel).SendAsync();
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// var embed = _eb.Create()
|
||||
// var embed = new EmbedBuilder()
|
||||
// .WithOkColor()
|
||||
// .WithDescription(novelData.Description.Replace("<br>", Environment.NewLine, StringComparison.InvariantCulture))
|
||||
// .WithTitle(novelData.Title)
|
||||
@@ -35,7 +35,7 @@ public partial class Searches
|
||||
// .AddField(GetText(strs.genres), string.Join(" ", novelData.Genres.Any() ? novelData.Genres : new[] { "none" }), true)
|
||||
// .WithFooter($"{GetText(strs.score)} {novelData.Score}");
|
||||
//
|
||||
// await EmbedAsync(embed);
|
||||
// await Response().Embed(embed).SendAsync();
|
||||
// }
|
||||
|
||||
[Cmd]
|
||||
@@ -86,7 +86,7 @@ public partial class Searches
|
||||
.Select(x => x.TextContent.Split(':').Select(y => y.Trim()).ToArray())
|
||||
.ToArray();
|
||||
|
||||
var embed = _eb.Create()
|
||||
var embed = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText(strs.mal_profile(name)))
|
||||
.AddField("💚 " + GetText(strs.watching), stats[0], true)
|
||||
@@ -110,7 +110,7 @@ public partial class Searches
|
||||
.WithUrl(fullQueryLink)
|
||||
.WithImageUrl(imageUrl);
|
||||
|
||||
await EmbedAsync(embed);
|
||||
await Response().Embed(embed).SendAsync();
|
||||
}
|
||||
|
||||
private static string MalInfoToEmoji(string info)
|
||||
@@ -147,11 +147,11 @@ public partial class Searches
|
||||
|
||||
if (animeData is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.failed_finding_anime);
|
||||
await Response().Error(strs.failed_finding_anime).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
var embed = _eb.Create()
|
||||
var embed = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithDescription(animeData.Synopsis.Replace("<br>",
|
||||
Environment.NewLine,
|
||||
@@ -165,7 +165,7 @@ public partial class Searches
|
||||
string.Join(",\n", animeData.Genres.Any() ? animeData.Genres : new[] { "none" }),
|
||||
true)
|
||||
.WithFooter($"{GetText(strs.score)} {animeData.AverageScore} / 100");
|
||||
await EmbedAsync(embed);
|
||||
await Response().Embed(embed).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -179,11 +179,11 @@ public partial class Searches
|
||||
|
||||
if (mangaData is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.failed_finding_manga);
|
||||
await Response().Error(strs.failed_finding_manga).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
var embed = _eb.Create()
|
||||
var embed = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithDescription(mangaData.Synopsis.Replace("<br>",
|
||||
Environment.NewLine,
|
||||
@@ -198,7 +198,7 @@ public partial class Searches
|
||||
true)
|
||||
.WithFooter($"{GetText(strs.score)} {mangaData.AverageScore} / 100");
|
||||
|
||||
await EmbedAsync(embed);
|
||||
await Response().Embed(embed).SendAsync();
|
||||
}
|
||||
}
|
||||
}
|
@@ -30,12 +30,12 @@ public partial class Searches
|
||||
|
||||
if (symbols.Count == 0)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.not_found);
|
||||
await Response().Error(strs.not_found).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
var symbol = symbols.First();
|
||||
var promptEmbed = _eb.Create()
|
||||
var promptEmbed = new EmbedBuilder()
|
||||
.WithDescription(symbol.Description)
|
||||
.WithTitle(GetText(strs.did_you_mean(symbol.Symbol)));
|
||||
|
||||
@@ -47,7 +47,7 @@ public partial class Searches
|
||||
|
||||
if (stock is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.not_found);
|
||||
await Response().Error(strs.not_found).SendAsync();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public partial class Searches
|
||||
|
||||
var price = stock.Price.ToString("C2", localCulture);
|
||||
|
||||
var eb = _eb.Create()
|
||||
var eb = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithAuthor(stock.Symbol)
|
||||
.WithUrl($"https://www.tradingview.com/chart/?symbol={stock.Symbol}")
|
||||
@@ -92,7 +92,7 @@ public partial class Searches
|
||||
// .AddField("Change 200d", $"{sign200}{change200}", true)
|
||||
.WithFooter(stock.Exchange);
|
||||
|
||||
var message = await EmbedAsync(eb);
|
||||
var message = await Response().Embed(eb).SendAsync();
|
||||
await using var imageData = await stockImageTask;
|
||||
if (imageData is null)
|
||||
return;
|
||||
@@ -127,7 +127,7 @@ public partial class Searches
|
||||
|
||||
if (nearest is not null)
|
||||
{
|
||||
var embed = _eb.Create()
|
||||
var embed = new EmbedBuilder()
|
||||
.WithTitle(GetText(strs.crypto_not_found))
|
||||
.WithDescription(
|
||||
GetText(strs.did_you_mean(Format.Bold($"{nearest.Name} ({nearest.Symbol})"))));
|
||||
@@ -138,7 +138,7 @@ public partial class Searches
|
||||
|
||||
if (crypto is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.crypto_not_found);
|
||||
await Response().Error(strs.crypto_not_found).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public partial class Searches
|
||||
await using var sparkline = await _service.GetSparklineAsync(crypto.Id, usd.PercentChange7d >= 0);
|
||||
var fileName = $"{crypto.Slug}_7d.png";
|
||||
|
||||
var toSend = _eb.Create()
|
||||
var toSend = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithAuthor($"#{crypto.CmcRank}")
|
||||
.WithTitle($"{crypto.Name} ({crypto.Symbol})")
|
||||
|
@@ -28,7 +28,7 @@ public partial class Searches
|
||||
{
|
||||
var m = _ytChannelRegex.Match(url);
|
||||
if (!m.Success)
|
||||
return ReplyErrorLocalizedAsync(strs.invalid_input);
|
||||
return Response().Error(strs.invalid_input).SendAsync();
|
||||
|
||||
if (!((IGuildUser)ctx.User).GetPermissions(channel).MentionEveryone)
|
||||
message = message?.SanitizeAllMentions();
|
||||
@@ -55,7 +55,7 @@ public partial class Searches
|
||||
if (!Uri.TryCreate(url, UriKind.Absolute, out var uri)
|
||||
|| (uri.Scheme != Uri.UriSchemeHttp && uri.Scheme != Uri.UriSchemeHttps))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.feed_invalid_url);
|
||||
await Response().Error(strs.feed_invalid_url).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public partial class Searches
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Information(ex, "Unable to get feeds from that url");
|
||||
await ReplyErrorLocalizedAsync(strs.feed_cant_parse);
|
||||
await Response().Error(strs.feed_cant_parse).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -80,19 +80,19 @@ public partial class Searches
|
||||
var result = _service.AddFeed(ctx.Guild.Id, channel.Id, url, message);
|
||||
if (result == FeedAddResult.Success)
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.feed_added);
|
||||
await Response().Confirm(strs.feed_added).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
if (result == FeedAddResult.Duplicate)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.feed_duplicate);
|
||||
await Response().Error(strs.feed_duplicate).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
if (result == FeedAddResult.LimitReached)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.feed_limit_reached);
|
||||
await Response().Error(strs.feed_limit_reached).SendAsync();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -103,9 +103,9 @@ public partial class Searches
|
||||
public async Task FeedRemove(int index)
|
||||
{
|
||||
if (_service.RemoveFeed(ctx.Guild.Id, --index))
|
||||
await ReplyConfirmLocalizedAsync(strs.feed_removed);
|
||||
await Response().Confirm(strs.feed_removed).SendAsync();
|
||||
else
|
||||
await ReplyErrorLocalizedAsync(strs.feed_out_of_range);
|
||||
await Response().Error(strs.feed_out_of_range).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -117,14 +117,14 @@ public partial class Searches
|
||||
|
||||
if (!feeds.Any())
|
||||
{
|
||||
await EmbedAsync(_eb.Create().WithOkColor().WithDescription(GetText(strs.feed_no_feed)));
|
||||
await Response().Embed(new EmbedBuilder().WithOkColor().WithDescription(GetText(strs.feed_no_feed))).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
await ctx.SendPaginatedConfirmAsync(0,
|
||||
cur =>
|
||||
{
|
||||
var embed = _eb.Create().WithOkColor();
|
||||
var embed = new EmbedBuilder().WithOkColor();
|
||||
var i = 0;
|
||||
var fs = string.Join("\n",
|
||||
feeds.Skip(cur * 10).Take(10).Select(x => $"`{(cur * 10) + ++i}.` <#{x.ChannelId}> {x.Url}"));
|
||||
|
@@ -115,7 +115,7 @@ public class FeedsService : INService
|
||||
if (itemUpdateDate <= lastFeedUpdate)
|
||||
continue;
|
||||
|
||||
var embed = _eb.Create().WithFooter(rssUrl);
|
||||
var embed = new EmbedBuilder().WithFooter(rssUrl);
|
||||
|
||||
_lastPosts[kvp.Key] = itemUpdateDate;
|
||||
|
||||
|
@@ -10,30 +10,30 @@ public partial class Searches
|
||||
{
|
||||
[Cmd]
|
||||
public async Task Yomama()
|
||||
=> await SendConfirmAsync(await _service.GetYomamaJoke());
|
||||
=> await Response().Confirm(await _service.GetYomamaJoke()).SendAsync();
|
||||
|
||||
[Cmd]
|
||||
public async Task Randjoke()
|
||||
{
|
||||
var (setup, punchline) = await _service.GetRandomJoke();
|
||||
await SendConfirmAsync(setup, punchline);
|
||||
await Response().Confirm(setup, punchline).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
public async Task ChuckNorris()
|
||||
=> await SendConfirmAsync(await _service.GetChuckNorrisJoke());
|
||||
=> await Response().Confirm(await _service.GetChuckNorrisJoke()).SendAsync();
|
||||
|
||||
[Cmd]
|
||||
public async Task WowJoke()
|
||||
{
|
||||
if (!_service.WowJokes.Any())
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.jokes_not_loaded);
|
||||
await Response().Error(strs.jokes_not_loaded).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
var joke = _service.WowJokes[new NadekoRandom().Next(0, _service.WowJokes.Count)];
|
||||
await SendConfirmAsync(joke.Question, joke.Answer);
|
||||
await Response().Confirm(joke.Question, joke.Answer).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -41,13 +41,13 @@ public partial class Searches
|
||||
{
|
||||
if (!_service.MagicItems.Any())
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.magicitems_not_loaded);
|
||||
await Response().Error(strs.magicitems_not_loaded).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
var item = _service.MagicItems[new NadekoRandom().Next(0, _service.MagicItems.Count)];
|
||||
|
||||
await SendConfirmAsync("✨" + item.Name, item.Description);
|
||||
await Response().Confirm("✨" + item.Name, item.Description).SendAsync();
|
||||
}
|
||||
}
|
||||
}
|
@@ -46,7 +46,7 @@ public partial class Searches
|
||||
var templates = string.Empty;
|
||||
foreach (var template in data.Skip(curPage * 15).Take(15))
|
||||
templates += $"**{template.Name}:**\n key: `{template.Id}`\n";
|
||||
var embed = _eb.Create().WithOkColor().WithDescription(templates);
|
||||
var embed = new EmbedBuilder().WithOkColor().WithDescription(templates);
|
||||
|
||||
return embed;
|
||||
},
|
||||
|
@@ -31,7 +31,7 @@ public partial class Searches
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_creds.OsuApiKey))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.osu_api_key);
|
||||
await Response().Error(strs.osu_api_key).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,14 +42,14 @@ public partial class Searches
|
||||
|
||||
if (objs.Count == 0)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.osu_user_not_found);
|
||||
await Response().Error(strs.osu_user_not_found).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
var obj = objs[0];
|
||||
var userId = obj.UserId;
|
||||
|
||||
await EmbedAsync(_eb.Create()
|
||||
await Response().Embed(new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle($"osu! {smode} profile for {user}")
|
||||
.WithThumbnailUrl($"https://a.ppy.sh/{userId}")
|
||||
@@ -61,15 +61,15 @@ public partial class Searches
|
||||
.AddField("Total PP", Math.Round(obj.PpRaw, 2), true)
|
||||
.AddField("Accuracy", Math.Round(obj.Accuracy, 2) + "%", true)
|
||||
.AddField("Playcount", obj.Playcount, true)
|
||||
.AddField("Level", Math.Round(obj.Level), true));
|
||||
.AddField("Level", Math.Round(obj.Level), true)).SendAsync();
|
||||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.osu_user_not_found);
|
||||
await Response().Error(strs.osu_user_not_found).SendAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.osu_failed);
|
||||
await Response().Error(strs.osu_failed).SendAsync();
|
||||
Log.Warning(ex, "Osu command failed");
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public partial class Searches
|
||||
var statsResponse = JsonConvert.DeserializeObject<GatariUserStatsResponse>(resString);
|
||||
if (statsResponse.Code != 200 || statsResponse.Stats.Id == 0)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.osu_user_not_found);
|
||||
await Response().Error(strs.osu_user_not_found).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public partial class Searches
|
||||
var userData = JsonConvert.DeserializeObject<GatariUserResponse>(usrResString).Users[0];
|
||||
var userStats = statsResponse.Stats;
|
||||
|
||||
var embed = _eb.Create()
|
||||
var embed = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle($"osu!Gatari {modeStr} profile for {user}")
|
||||
.WithThumbnailUrl($"https://a.gatari.pw/{userStats.Id}")
|
||||
@@ -109,7 +109,7 @@ public partial class Searches
|
||||
.AddField("Playcount", userStats.Playcount, true)
|
||||
.AddField("Level", userStats.Level, true);
|
||||
|
||||
await EmbedAsync(embed);
|
||||
await Response().Embed(embed).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -117,13 +117,13 @@ public partial class Searches
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_creds.OsuApiKey))
|
||||
{
|
||||
await SendErrorAsync("An osu! API key is required.");
|
||||
await Response().Error("An osu! API key is required.").SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(user))
|
||||
{
|
||||
await SendErrorAsync("Please provide a username.");
|
||||
await Response().Error("Please provide a username.").SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -166,13 +166,13 @@ public partial class Searches
|
||||
return (title, desc);
|
||||
});
|
||||
|
||||
var eb = _eb.Create().WithOkColor().WithTitle($"Top 5 plays for {user}");
|
||||
var eb = new EmbedBuilder().WithOkColor().WithTitle($"Top 5 plays for {user}");
|
||||
|
||||
var mapData = await mapTasks.WhenAll();
|
||||
foreach (var (title, desc) in mapData.Where(x => x != default))
|
||||
eb.AddField(title, desc);
|
||||
|
||||
await EmbedAsync(eb);
|
||||
await Response().Embed(eb).SendAsync();
|
||||
}
|
||||
|
||||
//https://osu.ppy.sh/wiki/Accuracy
|
||||
|
@@ -121,7 +121,7 @@ public partial class Searches
|
||||
|
||||
if (string.IsNullOrWhiteSpace(usr))
|
||||
{
|
||||
await SendErrorAsync("Please provide an account name.");
|
||||
await Response().Error("Please provide an account name.").SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -135,9 +135,9 @@ public partial class Searches
|
||||
}
|
||||
catch
|
||||
{
|
||||
var embed = _eb.Create().WithDescription(GetText(strs.account_not_found)).WithErrorColor();
|
||||
var embed = new EmbedBuilder().WithDescription(GetText(strs.account_not_found)).WithErrorColor();
|
||||
|
||||
await EmbedAsync(embed);
|
||||
await Response().Embed(embed).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public partial class Searches
|
||||
await ctx.SendPaginatedConfirmAsync(page,
|
||||
curPage =>
|
||||
{
|
||||
var embed = _eb.Create()
|
||||
var embed = new EmbedBuilder()
|
||||
.WithAuthor($"Characters on {usr}'s account",
|
||||
"https://web.poecdn.com/image/favicon/ogimage.png",
|
||||
$"{PROFILE_URL}{usr}")
|
||||
@@ -190,13 +190,13 @@ public partial class Searches
|
||||
}
|
||||
catch
|
||||
{
|
||||
var eembed = _eb.Create().WithDescription(GetText(strs.leagues_not_found)).WithErrorColor();
|
||||
var eembed = new EmbedBuilder().WithDescription(GetText(strs.leagues_not_found)).WithErrorColor();
|
||||
|
||||
await EmbedAsync(eembed);
|
||||
await Response().Embed(eembed).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
var embed = _eb.Create()
|
||||
var embed = new EmbedBuilder()
|
||||
.WithAuthor("Path of Exile Leagues",
|
||||
"https://web.poecdn.com/image/favicon/ogimage.png",
|
||||
"https://www.pathofexile.com")
|
||||
@@ -215,7 +215,7 @@ public partial class Searches
|
||||
|
||||
embed.WithDescription(sb.ToString());
|
||||
|
||||
await EmbedAsync(embed);
|
||||
await Response().Embed(embed).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -226,13 +226,13 @@ public partial class Searches
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(leagueName))
|
||||
{
|
||||
await SendErrorAsync("Please provide league name.");
|
||||
await Response().Error("Please provide league name.").SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(currencyName))
|
||||
{
|
||||
await SendErrorAsync("Please provide currency name.");
|
||||
await Response().Error("Please provide currency name.").SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ public partial class Searches
|
||||
CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
var embed = _eb.Create()
|
||||
var embed = new EmbedBuilder()
|
||||
.WithAuthor($"{leagueName} Currency Exchange",
|
||||
"https://web.poecdn.com/image/favicon/ogimage.png",
|
||||
"http://poe.ninja")
|
||||
@@ -281,13 +281,13 @@ public partial class Searches
|
||||
.AddField($"{cleanConvert} Equivalent", chaosEquivalent / conversionEquivalent, true)
|
||||
.WithOkColor();
|
||||
|
||||
await EmbedAsync(embed);
|
||||
await Response().Embed(embed).SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
var embed = _eb.Create().WithDescription(GetText(strs.ninja_not_found)).WithErrorColor();
|
||||
var embed = new EmbedBuilder().WithDescription(GetText(strs.ninja_not_found)).WithErrorColor();
|
||||
|
||||
await EmbedAsync(embed);
|
||||
await Response().Embed(embed).SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,7 @@ public partial class Searches
|
||||
if (kvp.Key.ToUpperInvariant() == pokemon.ToUpperInvariant())
|
||||
{
|
||||
var p = kvp.Value;
|
||||
await EmbedAsync(_eb.Create()
|
||||
await Response().Embed(new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle(kvp.Key.ToTitleCase())
|
||||
.WithDescription(p.BaseStats.ToString())
|
||||
@@ -37,12 +37,12 @@ public partial class Searches
|
||||
true)
|
||||
.AddField(GetText(strs.abilities),
|
||||
string.Join("\n", p.Abilities.Select(a => a.Value)),
|
||||
true));
|
||||
true)).SendAsync();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await ReplyErrorLocalizedAsync(strs.pokemon_none);
|
||||
await Response().Error(strs.pokemon_none).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -55,7 +55,7 @@ public partial class Searches
|
||||
{
|
||||
if (kvp.Key.ToUpperInvariant() == ability)
|
||||
{
|
||||
await EmbedAsync(_eb.Create()
|
||||
await Response().Embed(new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle(kvp.Value.Name)
|
||||
.WithDescription(string.IsNullOrWhiteSpace(kvp.Value.Desc)
|
||||
@@ -63,12 +63,12 @@ public partial class Searches
|
||||
: kvp.Value.Desc)
|
||||
.AddField(GetText(strs.rating),
|
||||
kvp.Value.Rating.ToString(Culture),
|
||||
true));
|
||||
true)).SendAsync();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await ReplyErrorLocalizedAsync(strs.pokemon_ability_none);
|
||||
await Response().Error(strs.pokemon_ability_none).SendAsync();
|
||||
}
|
||||
}
|
||||
}
|
@@ -24,7 +24,7 @@ public partial class Searches
|
||||
|
||||
if (string.IsNullOrWhiteSpace(query))
|
||||
{
|
||||
await ErrorLocalizedAsync(strs.specify_search_params);
|
||||
await Response().Error(strs.specify_search_params).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public partial class Searches
|
||||
|
||||
if (data is null or { Entries: null or { Count: 0 } })
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.no_results);
|
||||
await Response().Error(strs.no_results).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public partial class Searches
|
||||
|
||||
descStr = descStr.TrimTo(4096);
|
||||
|
||||
var embed = _eb.Create()
|
||||
var embed = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithAuthor(ctx.User)
|
||||
.WithTitle(query.TrimTo(64)!)
|
||||
@@ -68,7 +68,7 @@ public partial class Searches
|
||||
GetText(strs.results_in(data.Info.TotalResults, data.Info.SearchTime)),
|
||||
"https://i.imgur.com/G46fm8J.png");
|
||||
|
||||
await EmbedAsync(embed);
|
||||
await Response().Embed(embed).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -78,7 +78,7 @@ public partial class Searches
|
||||
|
||||
if (string.IsNullOrWhiteSpace(query))
|
||||
{
|
||||
await ErrorLocalizedAsync(strs.specify_search_params);
|
||||
await Response().Error(strs.specify_search_params).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -89,16 +89,16 @@ public partial class Searches
|
||||
|
||||
if (data is null or { Entries: null or { Count: 0 } })
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.no_search_results);
|
||||
await Response().Error(strs.no_search_results).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
var embeds = new List<IEmbedBuilder>(4);
|
||||
var embeds = new List<EmbedBuilder>(4);
|
||||
|
||||
|
||||
IEmbedBuilder CreateEmbed(IImageSearchResultEntry entry)
|
||||
EmbedBuilder CreateEmbed(IImageSearchResultEntry entry)
|
||||
{
|
||||
return _eb.Create(ctx)
|
||||
return new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithAuthor(ctx.User)
|
||||
.WithTitle(query)
|
||||
@@ -121,7 +121,7 @@ public partial class Searches
|
||||
embeds.Add(CreateEmbed(entry));
|
||||
}
|
||||
|
||||
await EmbedAsync(null, embeds: embeds);
|
||||
await Response().Embeds(embeds).SendAsync();
|
||||
}
|
||||
|
||||
private TypedKey<string> GetYtCacheKey(string query)
|
||||
@@ -150,7 +150,7 @@ public partial class Searches
|
||||
|
||||
if (string.IsNullOrWhiteSpace(query))
|
||||
{
|
||||
await ErrorLocalizedAsync(strs.specify_search_params);
|
||||
await Response().Error(strs.specify_search_params).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public partial class Searches
|
||||
?? await _searchFactory.GetYoutubeSearchService().SearchAsync(query);
|
||||
if (maybeResult is not {} result || result is {Url: null})
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.no_results);
|
||||
await Response().Error(strs.no_results).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ public partial class Searches
|
||||
// var data = await _service.DuckDuckGoSearchAsync(query);
|
||||
// if (data is null)
|
||||
// {
|
||||
// await ReplyErrorLocalizedAsync(strs.no_results);
|
||||
// await Response().Error(strs.no_results).SendAsync();
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
@@ -190,13 +190,13 @@ public partial class Searches
|
||||
//
|
||||
// var descStr = string.Join("\n\n", desc);
|
||||
//
|
||||
// var embed = _eb.Create()
|
||||
// var embed = new EmbedBuilder()
|
||||
// .WithAuthor(ctx.User.ToString(),
|
||||
// "https://upload.wikimedia.org/wikipedia/en/9/90/The_DuckDuckGo_Duck.png")
|
||||
// .WithDescription($"{GetText(strs.search_for)} **{query}**\n\n" + descStr)
|
||||
// .WithOkColor();
|
||||
//
|
||||
// await EmbedAsync(embed);
|
||||
// await Response().Embed(embed).SendAsync();
|
||||
// }
|
||||
}
|
||||
}
|
@@ -54,7 +54,7 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
if (!await ValidateQuery(query))
|
||||
return;
|
||||
|
||||
var embed = _eb.Create();
|
||||
var embed = new EmbedBuilder();
|
||||
var data = await _service.GetWeatherDataAsync(query);
|
||||
|
||||
if (data is null)
|
||||
@@ -93,7 +93,7 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
$"https://openweathermap.org/img/w/{data.Weather[0].Icon}.png");
|
||||
}
|
||||
|
||||
await EmbedAsync(embed);
|
||||
await Response().Embed(embed).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -124,22 +124,22 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
break;
|
||||
}
|
||||
|
||||
await ReplyErrorLocalizedAsync(errorKey);
|
||||
await Response().Error(errorKey).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(data.TimeZoneName))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.timezone_db_api_key);
|
||||
await Response().Error(strs.timezone_db_api_key).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
var eb = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText(strs.time_new))
|
||||
.WithDescription(Format.Code(data.Time.ToString(Culture)))
|
||||
.AddField(GetText(strs.location), string.Join('\n', data.Address.Split(", ")), true)
|
||||
.AddField(GetText(strs.timezone), data.TimeZoneName, true);
|
||||
var eb = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText(strs.time_new))
|
||||
.WithDescription(Format.Code(data.Time.ToString(Culture)))
|
||||
.AddField(GetText(strs.location), string.Join('\n', data.Address.Split(", ")), true)
|
||||
.AddField(GetText(strs.timezone), data.TimeZoneName, true);
|
||||
|
||||
await ctx.Channel.SendMessageAsync(embed: eb.Build());
|
||||
}
|
||||
@@ -155,19 +155,21 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
var movie = await _service.GetMovieDataAsync(query);
|
||||
if (movie is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.imdb_fail);
|
||||
await Response().Error(strs.imdb_fail).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
await EmbedAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(movie.Title)
|
||||
.WithUrl($"https://www.imdb.com/title/{movie.ImdbId}/")
|
||||
.WithDescription(movie.Plot.TrimTo(1000))
|
||||
.AddField("Rating", movie.ImdbRating, true)
|
||||
.AddField("Genre", movie.Genre, true)
|
||||
.AddField("Year", movie.Year, true)
|
||||
.WithImageUrl(movie.Poster));
|
||||
await Response()
|
||||
.Embed(new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle(movie.Title)
|
||||
.WithUrl($"https://www.imdb.com/title/{movie.ImdbId}/")
|
||||
.WithDescription(movie.Plot.TrimTo(1000))
|
||||
.AddField("Rating", movie.ImdbRating, true)
|
||||
.AddField("Genre", movie.Genre, true)
|
||||
.AddField("Year", movie.Year, true)
|
||||
.WithImageUrl(movie.Poster))
|
||||
.SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -189,7 +191,7 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
private Task InternalRandomImage(SearchesService.ImageTag tag)
|
||||
{
|
||||
var url = _service.GetRandomImageUrl(tag);
|
||||
return EmbedAsync(_eb.Create().WithOkColor().WithImageUrl(url));
|
||||
return Response().Embed(new EmbedBuilder().WithOkColor().WithImageUrl(url)).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -199,7 +201,7 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
return;
|
||||
|
||||
var shortenedUrl = await _google.ShortenUrl($"https://letmegooglethat.com/?q={Uri.EscapeDataString(ffs)}");
|
||||
await SendConfirmAsync($"<{shortenedUrl}>");
|
||||
await Response().Confirm($"<{shortenedUrl}>").SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -239,10 +241,12 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
}
|
||||
}
|
||||
|
||||
await EmbedAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
.AddField(GetText(strs.original_url), $"<{query}>")
|
||||
.AddField(GetText(strs.short_url), $"<{shortLink}>"));
|
||||
await Response()
|
||||
.Embed(new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.AddField(GetText(strs.original_url), $"<{query}>")
|
||||
.AddField(GetText(strs.short_url), $"<{shortLink}>"))
|
||||
.SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -256,20 +260,20 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
|
||||
if (card is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.card_not_found);
|
||||
await Response().Error(strs.card_not_found).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(card.Name)
|
||||
.WithDescription(card.Description)
|
||||
.WithImageUrl(card.ImageUrl)
|
||||
.AddField(GetText(strs.store_url), card.StoreUrl, true)
|
||||
.AddField(GetText(strs.cost), card.ManaCost, true)
|
||||
.AddField(GetText(strs.types), card.Types, true);
|
||||
var embed = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle(card.Name)
|
||||
.WithDescription(card.Description)
|
||||
.WithImageUrl(card.ImageUrl)
|
||||
.AddField(GetText(strs.store_url), card.StoreUrl, true)
|
||||
.AddField(GetText(strs.cost), card.ManaCost, true)
|
||||
.AddField(GetText(strs.types), card.Types, true);
|
||||
|
||||
await EmbedAsync(embed);
|
||||
await Response().Embed(embed).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -280,7 +284,7 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
|
||||
if (string.IsNullOrWhiteSpace(_creds.RapidApiKey))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.mashape_api_missing);
|
||||
await Response().Error(strs.mashape_api_missing).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -289,16 +293,16 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
|
||||
if (card is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.card_not_found);
|
||||
await Response().Error(strs.card_not_found).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
var embed = _eb.Create().WithOkColor().WithImageUrl(card.Img);
|
||||
var embed = new EmbedBuilder().WithOkColor().WithImageUrl(card.Img);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(card.Flavor))
|
||||
embed.WithDescription(card.Flavor);
|
||||
|
||||
await EmbedAsync(embed);
|
||||
await Response().Embed(embed).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -321,11 +325,11 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
p =>
|
||||
{
|
||||
var item = items[p];
|
||||
return _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithUrl(item.Permalink)
|
||||
.WithTitle(item.Word)
|
||||
.WithDescription(item.Definition);
|
||||
return new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithUrl(item.Permalink)
|
||||
.WithTitle(item.Word)
|
||||
.WithDescription(item.Definition);
|
||||
},
|
||||
items.Length,
|
||||
1);
|
||||
@@ -337,7 +341,7 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
}
|
||||
}
|
||||
|
||||
await ReplyErrorLocalizedAsync(strs.ud_error);
|
||||
await Response().Error(strs.ud_error).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -361,28 +365,28 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
var data = JsonConvert.DeserializeObject<DefineModel>(res);
|
||||
|
||||
var datas = data.Results
|
||||
.Where(x => x.Senses is not null
|
||||
&& x.Senses.Count > 0
|
||||
&& x.Senses[0].Definition is not null)
|
||||
.Select(x => (Sense: x.Senses[0], x.PartOfSpeech))
|
||||
.ToList();
|
||||
.Where(x => x.Senses is not null
|
||||
&& x.Senses.Count > 0
|
||||
&& x.Senses[0].Definition is not null)
|
||||
.Select(x => (Sense: x.Senses[0], x.PartOfSpeech))
|
||||
.ToList();
|
||||
|
||||
if (!datas.Any())
|
||||
{
|
||||
Log.Warning("Definition not found: {Word}", word);
|
||||
await ReplyErrorLocalizedAsync(strs.define_unknown);
|
||||
await Response().Error(strs.define_unknown).SendAsync();
|
||||
}
|
||||
|
||||
|
||||
var col = datas.Select(x => (
|
||||
Definition: x.Sense.Definition is string
|
||||
? x.Sense.Definition.ToString()
|
||||
: ((JArray)JToken.Parse(x.Sense.Definition.ToString())).First.ToString(),
|
||||
Example: x.Sense.Examples is null || x.Sense.Examples.Count == 0
|
||||
? string.Empty
|
||||
: x.Sense.Examples[0].Text, Word: word,
|
||||
WordType: string.IsNullOrWhiteSpace(x.PartOfSpeech) ? "-" : x.PartOfSpeech))
|
||||
.ToList();
|
||||
Definition: x.Sense.Definition is string
|
||||
? x.Sense.Definition.ToString()
|
||||
: ((JArray)JToken.Parse(x.Sense.Definition.ToString())).First.ToString(),
|
||||
Example: x.Sense.Examples is null || x.Sense.Examples.Count == 0
|
||||
? string.Empty
|
||||
: x.Sense.Examples[0].Text, Word: word,
|
||||
WordType: string.IsNullOrWhiteSpace(x.PartOfSpeech) ? "-" : x.PartOfSpeech))
|
||||
.ToList();
|
||||
|
||||
Log.Information("Sending {Count} definition for: {Word}", col.Count, word);
|
||||
|
||||
@@ -390,12 +394,12 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
page =>
|
||||
{
|
||||
var model = col.Skip(page).First();
|
||||
var embed = _eb.Create()
|
||||
.WithDescription(ctx.User.Mention)
|
||||
.AddField(GetText(strs.word), model.Word, true)
|
||||
.AddField(GetText(strs._class), model.WordType, true)
|
||||
.AddField(GetText(strs.definition), model.Definition)
|
||||
.WithOkColor();
|
||||
var embed = new EmbedBuilder()
|
||||
.WithDescription(ctx.User.Mention)
|
||||
.AddField(GetText(strs.word), model.Word, true)
|
||||
.AddField(GetText(strs._class), model.WordType, true)
|
||||
.AddField(GetText(strs.definition), model.Definition)
|
||||
.WithOkColor();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(model.Example))
|
||||
embed.AddField(GetText(strs.example), model.Example);
|
||||
@@ -418,7 +422,7 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
var response = await http.GetStringAsync("https://catfact.ninja/fact");
|
||||
|
||||
var fact = JObject.Parse(response)["fact"].ToString();
|
||||
await SendConfirmAsync("🐈" + GetText(strs.catfact), fact);
|
||||
await Response().Confirm("🐈" + GetText(strs.catfact), fact).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -435,7 +439,7 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
+ Uri.EscapeDataString(query));
|
||||
var data = JsonConvert.DeserializeObject<WikipediaApiModel>(result);
|
||||
if (data.Query.Pages[0].Missing || string.IsNullOrWhiteSpace(data.Query.Pages[0].FullUrl))
|
||||
await ReplyErrorLocalizedAsync(strs.wiki_page_not_found);
|
||||
await Response().Error(strs.wiki_page_not_found).SendAsync();
|
||||
else
|
||||
await ctx.Channel.SendMessageAsync(data.Query.Pages[0].FullUrl);
|
||||
}
|
||||
@@ -468,13 +472,14 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
|
||||
var avatarUrl = usr.RealAvatarUrl(2048);
|
||||
|
||||
await EmbedAsync(
|
||||
_eb.Create()
|
||||
.WithOkColor()
|
||||
.AddField("Username", usr.ToString())
|
||||
.AddField("Avatar Url", avatarUrl)
|
||||
.WithThumbnailUrl(avatarUrl.ToString()),
|
||||
ctx.User.Mention);
|
||||
await Response()
|
||||
.Embed(
|
||||
new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.AddField("Username", usr.ToString())
|
||||
.AddField("Avatar Url", avatarUrl)
|
||||
.WithThumbnailUrl(avatarUrl.ToString()))
|
||||
.SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -482,7 +487,7 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(target) || string.IsNullOrWhiteSpace(query))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.wikia_input_error);
|
||||
await Response().Error(strs.wikia_input_error).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -502,7 +507,7 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
|
||||
if (string.IsNullOrWhiteSpace(title))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.wikia_error);
|
||||
await Response().Error(strs.wikia_error).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -513,7 +518,7 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
}
|
||||
catch
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.wikia_error);
|
||||
await Response().Error(strs.wikia_error).SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -532,14 +537,16 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
}
|
||||
|
||||
if (obj.Error is not null || obj.Verses is null || obj.Verses.Length == 0)
|
||||
await SendErrorAsync(obj.Error ?? "No verse found.");
|
||||
await Response().Error(obj.Error ?? "No verse found.").SendAsync();
|
||||
else
|
||||
{
|
||||
var v = obj.Verses[0];
|
||||
await EmbedAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle($"{v.BookName} {v.Chapter}:{v.Verse}")
|
||||
.WithDescription(v.Text));
|
||||
await Response()
|
||||
.Embed(new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle($"{v.BookName} {v.Chapter}:{v.Verse}")
|
||||
.WithDescription(v.Text))
|
||||
.SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,11 +561,11 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
var appId = await _service.GetSteamAppIdByName(query);
|
||||
if (appId == -1)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.not_found);
|
||||
await Response().Error(strs.not_found).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
//var embed = _eb.Create()
|
||||
//var embed = new EmbedBuilder()
|
||||
// .WithOkColor()
|
||||
// .WithDescription(gameData.ShortDescription)
|
||||
// .WithTitle(gameData.Name)
|
||||
@@ -576,12 +583,13 @@ public partial class Searches : NadekoModule<SearchesService>
|
||||
if (!string.IsNullOrWhiteSpace(query))
|
||||
return true;
|
||||
|
||||
await ErrorLocalizedAsync(strs.specify_search_params);
|
||||
await Response().Error(strs.specify_search_params).SendAsync();
|
||||
return false;
|
||||
}
|
||||
|
||||
public class ShortenData
|
||||
{
|
||||
[JsonProperty("result_url")] public string ResultUrl { get; set; }
|
||||
[JsonProperty("result_url")]
|
||||
public string ResultUrl { get; set; }
|
||||
}
|
||||
}
|
@@ -24,12 +24,15 @@ public partial class Searches
|
||||
var data = await _service.FollowStream(ctx.Guild.Id, ctx.Channel.Id, link);
|
||||
if (data is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.stream_not_added);
|
||||
await Response().Error(strs.stream_not_added).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
var embed = _service.GetEmbed(ctx.Guild.Id, data);
|
||||
await EmbedAsync(embed, GetText(strs.stream_tracked));
|
||||
await Response()
|
||||
.Embed(embed)
|
||||
.Text(strs.stream_tracked)
|
||||
.SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -44,11 +47,11 @@ public partial class Searches
|
||||
var fs = await _service.UnfollowStreamAsync(ctx.Guild.Id, index);
|
||||
if (fs is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.stream_no);
|
||||
await Response().Error(strs.stream_no).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.stream_removed(Format.Bold(fs.Username), fs.Type));
|
||||
await Response().Confirm(strs.stream_removed(Format.Bold(fs.Username), fs.Type)).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -57,7 +60,7 @@ public partial class Searches
|
||||
public async Task StreamsClear()
|
||||
{
|
||||
await _service.ClearAllStreams(ctx.Guild.Id);
|
||||
await ReplyConfirmLocalizedAsync(strs.streams_cleared);
|
||||
await Response().Confirm(strs.streams_cleared).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -93,9 +96,9 @@ public partial class Searches
|
||||
.ToList();
|
||||
|
||||
if (elements.Count == 0)
|
||||
return _eb.Create().WithDescription(GetText(strs.streams_none)).WithErrorColor();
|
||||
return new EmbedBuilder().WithDescription(GetText(strs.streams_none)).WithErrorColor();
|
||||
|
||||
var eb = _eb.Create().WithTitle(GetText(strs.streams_follow_title)).WithOkColor();
|
||||
var eb = new EmbedBuilder().WithTitle(GetText(strs.streams_follow_title)).WithOkColor();
|
||||
for (var index = 0; index < elements.Count; index++)
|
||||
{
|
||||
var elem = elements[index];
|
||||
@@ -117,11 +120,11 @@ public partial class Searches
|
||||
{
|
||||
var newValue = _service.ToggleStreamOffline(ctx.Guild.Id);
|
||||
if (newValue)
|
||||
await ReplyConfirmLocalizedAsync(strs.stream_off_enabled);
|
||||
await Response().Confirm(strs.stream_off_enabled).SendAsync();
|
||||
else
|
||||
await ReplyConfirmLocalizedAsync(strs.stream_off_disabled);
|
||||
await Response().Confirm(strs.stream_off_disabled).SendAsync();
|
||||
}
|
||||
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[UserPerm(GuildPerm.ManageMessages)]
|
||||
@@ -129,9 +132,9 @@ public partial class Searches
|
||||
{
|
||||
var newValue = _service.ToggleStreamOnlineDelete(ctx.Guild.Id);
|
||||
if (newValue)
|
||||
await ReplyConfirmLocalizedAsync(strs.stream_online_delete_enabled);
|
||||
await Response().Confirm(strs.stream_online_delete_enabled).SendAsync();
|
||||
else
|
||||
await ReplyConfirmLocalizedAsync(strs.stream_online_delete_disabled);
|
||||
await Response().Confirm(strs.stream_online_delete_disabled).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -144,14 +147,14 @@ public partial class Searches
|
||||
|
||||
if (!_service.SetStreamMessage(ctx.Guild.Id, index, message, out var fs))
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.stream_not_following);
|
||||
await Response().Confirm(strs.stream_not_following).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(message))
|
||||
await ReplyConfirmLocalizedAsync(strs.stream_message_reset(Format.Bold(fs.Username)));
|
||||
await Response().Confirm(strs.stream_message_reset(Format.Bold(fs.Username))).SendAsync();
|
||||
else
|
||||
await ReplyConfirmLocalizedAsync(strs.stream_message_set(Format.Bold(fs.Username)));
|
||||
await Response().Confirm(strs.stream_message_set(Format.Bold(fs.Username))).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -163,11 +166,11 @@ public partial class Searches
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.stream_not_following_any);
|
||||
await Response().Confirm(strs.stream_not_following_any).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.stream_message_set_all(count));
|
||||
await Response().Confirm(strs.stream_message_set_all(count)).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -179,21 +182,23 @@ public partial class Searches
|
||||
var data = await _service.GetStreamDataAsync(url);
|
||||
if (data is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.no_channel_found);
|
||||
await Response().Error(strs.no_channel_found).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.IsLive)
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.streamer_online(Format.Bold(data.Name),
|
||||
Format.Bold(data.Viewers.ToString())));
|
||||
await Response()
|
||||
.Confirm(strs.streamer_online(Format.Bold(data.Name),
|
||||
Format.Bold(data.Viewers.ToString())))
|
||||
.SendAsync();
|
||||
}
|
||||
else
|
||||
await ReplyConfirmLocalizedAsync(strs.streamer_offline(data.Name));
|
||||
await Response().Confirm(strs.streamer_offline(data.Name)).SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.no_channel_found);
|
||||
await Response().Error(strs.no_channel_found).SendAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -479,9 +479,9 @@ public sealed class StreamNotificationService : INService, IReadyExecutor
|
||||
return data;
|
||||
}
|
||||
|
||||
public IEmbedBuilder GetEmbed(ulong guildId, StreamData status, bool showViewers = true)
|
||||
public EmbedBuilder GetEmbed(ulong guildId, StreamData status, bool showViewers = true)
|
||||
{
|
||||
var embed = _eb.Create()
|
||||
var embed = new EmbedBuilder()
|
||||
.WithTitle(status.Name)
|
||||
.WithUrl(status.StreamUrl)
|
||||
.WithDescription(status.StreamUrl)
|
||||
|
@@ -69,7 +69,7 @@ public sealed class TranslateService : ITranslateService, IExecNoCommand, IReady
|
||||
|| msg.Content.Equals(output, StringComparison.InvariantCultureIgnoreCase))
|
||||
return;
|
||||
|
||||
var embed = _eb.Create().WithOkColor();
|
||||
var embed = new EmbedBuilder().WithOkColor();
|
||||
|
||||
if (autoDelete)
|
||||
{
|
||||
|
@@ -20,13 +20,13 @@ public partial class Searches
|
||||
await ctx.Channel.TriggerTypingAsync();
|
||||
var translation = await _service.Translate(from, to, text);
|
||||
|
||||
var embed = _eb.Create(ctx).WithOkColor().AddField(from, text).AddField(to, translation);
|
||||
var embed = new EmbedBuilder().WithOkColor().AddField(from, text).AddField(to, translation);
|
||||
|
||||
await EmbedAsync(embed);
|
||||
await Response().Embed(embed).SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.bad_input_format);
|
||||
await Response().Error(strs.bad_input_format).SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ public partial class Searches
|
||||
var toggle =
|
||||
await _service.ToggleAtl(ctx.Guild.Id, ctx.Channel.Id, autoDelete == AutoDeleteAutoTranslate.Del);
|
||||
if (toggle)
|
||||
await ReplyConfirmLocalizedAsync(strs.atl_started);
|
||||
await Response().Confirm(strs.atl_started).SendAsync();
|
||||
else
|
||||
await ReplyConfirmLocalizedAsync(strs.atl_stopped);
|
||||
await Response().Confirm(strs.atl_stopped).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -50,7 +50,7 @@ public partial class Searches
|
||||
public async Task AutoTransLang()
|
||||
{
|
||||
if (await _service.UnregisterUser(ctx.Channel.Id, ctx.User.Id))
|
||||
await ReplyConfirmLocalizedAsync(strs.atl_removed);
|
||||
await Response().Confirm(strs.atl_removed).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -61,17 +61,17 @@ public partial class Searches
|
||||
|
||||
if (succ is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.atl_not_enabled);
|
||||
await Response().Error(strs.atl_not_enabled).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
if (succ is false)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.invalid_lang);
|
||||
await Response().Error(strs.invalid_lang).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.atl_set(from, to));
|
||||
await Response().Confirm(strs.atl_set(from, to)).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -80,16 +80,16 @@ public partial class Searches
|
||||
{
|
||||
var langs = _service.GetLanguages().ToList();
|
||||
|
||||
var eb = _eb.Create()
|
||||
var eb = new EmbedBuilder()
|
||||
.WithTitle(GetText(strs.supported_languages))
|
||||
.WithOkColor();
|
||||
|
||||
foreach (var chunk in langs.Chunk(15))
|
||||
{
|
||||
eb.AddField("", chunk.Join("\n"), isInline: true);
|
||||
eb.AddField("", chunk.Join("\n"), inline: true);
|
||||
}
|
||||
|
||||
await EmbedAsync(eb);
|
||||
await Response().Embed(eb).SendAsync();
|
||||
}
|
||||
}
|
||||
}
|
@@ -25,13 +25,13 @@ public partial class Searches
|
||||
using var http = _httpFactory.CreateClient();
|
||||
var res = await http.GetStringAsync($"{XKCD_URL}/info.0.json");
|
||||
var comic = JsonConvert.DeserializeObject<XkcdComic>(res);
|
||||
var embed = _eb.Create()
|
||||
var embed = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithImageUrl(comic.ImageLink)
|
||||
.WithAuthor(comic.Title, "https://xkcd.com/s/919f27.ico", $"{XKCD_URL}/{comic.Num}")
|
||||
.AddField(GetText(strs.comic_number), comic.Num.ToString(), true)
|
||||
.AddField(GetText(strs.date), $"{comic.Month}/{comic.Year}", true);
|
||||
var sent = await EmbedAsync(embed);
|
||||
var sent = await Response().Embed(embed).SendAsync();
|
||||
|
||||
await Task.Delay(10000);
|
||||
|
||||
@@ -39,7 +39,7 @@ public partial class Searches
|
||||
}
|
||||
catch (HttpRequestException)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.comic_not_found);
|
||||
await Response().Error(strs.comic_not_found).SendAsync();
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -60,14 +60,14 @@ public partial class Searches
|
||||
var res = await http.GetStringAsync($"{XKCD_URL}/{num}/info.0.json");
|
||||
|
||||
var comic = JsonConvert.DeserializeObject<XkcdComic>(res);
|
||||
var embed = _eb.Create()
|
||||
var embed = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithImageUrl(comic.ImageLink)
|
||||
.WithAuthor(comic.Title, "https://xkcd.com/s/919f27.ico", $"{XKCD_URL}/{num}")
|
||||
.AddField(GetText(strs.comic_number), comic.Num.ToString(), true)
|
||||
.AddField(GetText(strs.date), $"{comic.Month}/{comic.Year}", true);
|
||||
|
||||
var sent = await EmbedAsync(embed);
|
||||
var sent = await Response().Embed(embed).SendAsync();
|
||||
|
||||
await Task.Delay(10000);
|
||||
|
||||
@@ -75,7 +75,7 @@ public partial class Searches
|
||||
}
|
||||
catch (HttpRequestException)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.comic_not_found);
|
||||
await Response().Error(strs.comic_not_found).SendAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13,11 +13,11 @@ public partial class Searches
|
||||
// var succ = await _service.ToggleChannelFollowAsync(ctx.Guild.Id, ctx.Channel.Id, ytChannelId, uploadMessage);
|
||||
// if(succ)
|
||||
// {
|
||||
// await ReplyConfirmLocalizedAsync(strs.yt_follow_added);
|
||||
// await Response().Confirm(strs.yt_follow_added).SendAsync();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// await ReplyConfirmLocalizedAsync(strs.yt_follow_fail);
|
||||
// await Response().Confirm(strs.yt_follow_fail).SendAsync();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
@@ -28,11 +28,11 @@ public partial class Searches
|
||||
// //var succ = await _service.ToggleChannelTrackingAsync(ctx.Guild.Id, ctx.Channel.Id, ytChannelId, uploadMessage);
|
||||
// //if (succ)
|
||||
// //{
|
||||
// // await ReplyConfirmLocalizedAsync(strs.yt_track_added);
|
||||
// // await Response().Confirm(strs.yt_track_added).SendAsync();
|
||||
// //}
|
||||
// //else
|
||||
// //{
|
||||
// // await ReplyConfirmLocalizedAsync(strs.yt_track_fail);
|
||||
// // await Response().Confirm(strs.yt_track_fail).SendAsync();
|
||||
// //}
|
||||
// }
|
||||
//
|
||||
@@ -43,11 +43,11 @@ public partial class Searches
|
||||
// //var succ = await _service.ToggleChannelTrackingAsync(ctx.Guild.Id, ctx.Channel.Id, ytChannelId, uploadMessage);
|
||||
// //if (succ)
|
||||
// //{
|
||||
// // await ReplyConfirmLocalizedAsync(strs.yt_track_added);
|
||||
// // await Response().Confirm(strs.yt_track_added).SendAsync();
|
||||
// //}
|
||||
// //else
|
||||
// //{
|
||||
// // await ReplyConfirmLocalizedAsync(strs.yt_track_fail);
|
||||
// // await Response().Confirm(strs.yt_track_fail).SendAsync();
|
||||
// //}
|
||||
// }
|
||||
// }
|
||||
|
Reference in New Issue
Block a user