- Reworked embed builder

- Use IEmbedBuilderService to create embed builders
- Wrapped embed builder and using IEmbedBuilder
This commit is contained in:
Kwoth
2021-07-09 22:23:19 +02:00
parent 5b4daa9dd3
commit 5e4754fa40
103 changed files with 730 additions and 540 deletions

View File

@@ -80,7 +80,7 @@ namespace NadekoBot.Modules.Games
private Task Game_OnStarted(AcrophobiaGame game)
{
var embed = new EmbedBuilder().WithOkColor()
var embed = _eb.Create().WithOkColor()
.WithTitle(GetText("acrophobia"))
.WithDescription(GetText("acro_started", Format.Bold(string.Join(".", game.StartingLetters))))
.WithFooter(GetText("acro_started_footer", game.Opts.SubmissionTime));
@@ -90,7 +90,7 @@ namespace NadekoBot.Modules.Games
private Task Game_OnUserVoted(string user)
{
return ctx.Channel.SendConfirmAsync(
return SendConfirmAsync(
GetText("acrophobia"),
GetText("acro_vote_cast", Format.Bold(user)));
}
@@ -99,12 +99,12 @@ namespace NadekoBot.Modules.Games
{
if (submissions.Length == 0)
{
await ctx.Channel.SendErrorAsync(GetText("acrophobia"), GetText("acro_ended_no_sub")).ConfigureAwait(false);
await SendErrorAsync(GetText("acrophobia"), GetText("acro_ended_no_sub")).ConfigureAwait(false);
return;
}
if (submissions.Length == 1)
{
await ctx.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
await ctx.Channel.EmbedAsync(_eb.Create().WithOkColor()
.WithDescription(
GetText("acro_winner_only",
Format.Bold(submissions.First().Key.UserName)))
@@ -115,7 +115,7 @@ namespace NadekoBot.Modules.Games
var i = 0;
var embed = new EmbedBuilder()
var embed = _eb.Create()
.WithOkColor()
.WithTitle(GetText("acrophobia") + " - " + GetText("submissions_closed"))
.WithDescription(GetText("acro_nym_was", Format.Bold(string.Join(".", game.StartingLetters)) + "\n" +
@@ -131,12 +131,12 @@ $@"--
{
if (!votes.Any() || votes.All(x => x.Value == 0))
{
await ctx.Channel.SendErrorAsync(GetText("acrophobia"), GetText("acro_no_votes_cast")).ConfigureAwait(false);
await SendErrorAsync(GetText("acrophobia"), GetText("acro_no_votes_cast")).ConfigureAwait(false);
return;
}
var table = votes.OrderByDescending(v => v.Value);
var winner = table.First();
var embed = new EmbedBuilder().WithOkColor()
var embed = _eb.Create().WithOkColor()
.WithTitle(GetText("acrophobia"))
.WithDescription(GetText("acro_winner", Format.Bold(winner.Key.UserName),
Format.Bold(winner.Value.ToString())))

View File

@@ -50,14 +50,16 @@ namespace NadekoBot.Modules.Games.Common
private readonly IBotStrings _strings;
private readonly DiscordSocketClient _client;
private readonly Options _options;
private readonly IEmbedBuilderService _eb;
public TicTacToe(IBotStrings strings, DiscordSocketClient client, ITextChannel channel,
IGuildUser firstUser, Options options)
IGuildUser firstUser, Options options, IEmbedBuilderService eb)
{
_channel = channel;
_strings = strings;
_client = client;
_options = options;
_eb = eb;
_users = new[] { firstUser, null };
_state = new int?[,] {
@@ -91,9 +93,9 @@ namespace NadekoBot.Modules.Games.Common
return sb.ToString();
}
public EmbedBuilder GetEmbed(string title = null)
public IEmbedBuilder GetEmbed(string title = null)
{
var embed = new EmbedBuilder()
var embed = _eb.Create()
.WithOkColor()
.WithDescription(Environment.NewLine + GetState())
.WithAuthor(GetText("vs", _users[0], _users[1]));
@@ -135,12 +137,12 @@ namespace NadekoBot.Modules.Games.Common
{
if (_phase == Phase.Started || _phase == Phase.Ended)
{
await _channel.SendErrorAsync(user.Mention + GetText("ttt_already_running")).ConfigureAwait(false);
await _channel.SendErrorAsync(_eb, user.Mention + GetText("ttt_already_running")).ConfigureAwait(false);
return;
}
else if (_users[0] == user)
{
await _channel.SendErrorAsync(user.Mention + GetText("ttt_against_yourself")).ConfigureAwait(false);
await _channel.SendErrorAsync(_eb, user.Mention + GetText("ttt_against_yourself")).ConfigureAwait(false);
return;
}

View File

@@ -42,10 +42,11 @@ namespace NadekoBot.Modules.Games.Common.Trivia
private readonly TriviaQuestionPool _questionPool;
private int _timeoutCount = 0;
private readonly string _quitCommand;
private readonly IEmbedBuilderService _eb;
public TriviaGame(IBotStrings strings, DiscordSocketClient client, GamesConfig config,
IDataCache cache, ICurrencyService cs, IGuild guild, ITextChannel channel,
TriviaOptions options, string quitCommand)
TriviaOptions options, string quitCommand, IEmbedBuilderService eb)
{
_cache = cache;
_questionPool = new TriviaQuestionPool(_cache);
@@ -55,6 +56,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
_cs = cs;
_options = options;
_quitCommand = quitCommand;
_eb = eb;
Guild = guild;
Channel = channel;
@@ -76,16 +78,16 @@ namespace NadekoBot.Modules.Games.Common.Trivia
CurrentQuestion = _questionPool.GetRandomQuestion(OldQuestions, _options.IsPokemon);
if (string.IsNullOrWhiteSpace(CurrentQuestion?.Answer) || string.IsNullOrWhiteSpace(CurrentQuestion.Question))
{
await Channel.SendErrorAsync(GetText("trivia_game"), GetText("failed_loading_question")).ConfigureAwait(false);
await Channel.SendErrorAsync(_eb, GetText("trivia_game"), GetText("failed_loading_question")).ConfigureAwait(false);
return;
}
OldQuestions.Add(CurrentQuestion); //add it to exclusion list so it doesn't show up again
EmbedBuilder questionEmbed;
IEmbedBuilder questionEmbed;
IUserMessage questionMessage;
try
{
questionEmbed = new EmbedBuilder().WithOkColor()
questionEmbed = _eb.Create().WithOkColor()
.WithTitle(GetText("trivia_game"))
.AddField(GetText("category"), CurrentQuestion.Category)
.AddField(GetText("question"), CurrentQuestion.Question);
@@ -149,7 +151,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
{
try
{
var embed = new EmbedBuilder().WithErrorColor()
var embed = _eb.Create().WithErrorColor()
.WithTitle(GetText("trivia_game"))
.WithDescription(GetText("trivia_times_up", Format.Bold(CurrentQuestion.Answer)));
if (Uri.IsWellFormedUriString(CurrentQuestion.AnswerImageUrl, UriKind.Absolute))
@@ -173,7 +175,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
{
ShouldStopGame = true;
await Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
await Channel.EmbedAsync(_eb.Create().WithOkColor()
.WithAuthor("Trivia Game Ended")
.WithTitle("Final Results")
.WithDescription(GetLeaderboard())).ConfigureAwait(false);
@@ -187,8 +189,9 @@ namespace NadekoBot.Modules.Games.Common.Trivia
{
try
{
await Channel.SendConfirmAsync(GetText("trivia_game"), GetText("trivia_stopping"))
.ConfigureAwait(false);
await Channel.SendConfirmAsync(_eb,
GetText("trivia_game"),
GetText("trivia_stopping"));
}
catch (Exception ex)
@@ -235,7 +238,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
ShouldStopGame = true;
try
{
var embedS = new EmbedBuilder().WithOkColor()
var embedS = _eb.Create().WithOkColor()
.WithTitle(GetText("trivia_game"))
.WithDescription(GetText("trivia_win",
guildUser.Mention,
@@ -253,7 +256,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
await _cs.AddAsync(guildUser, "Won trivia", reward, true).ConfigureAwait(false);
return;
}
var embed = new EmbedBuilder().WithOkColor()
var embed = _eb.Create().WithOkColor()
.WithTitle(GetText("trivia_game"))
.WithDescription(GetText("trivia_guess", guildUser.Mention, Format.Bold(CurrentQuestion.Answer)));
if (Uri.IsWellFormedUriString(CurrentQuestion.AnswerImageUrl, UriKind.Absolute))

View File

@@ -9,6 +9,7 @@ using NadekoBot.Common;
using NadekoBot.Extensions;
using NadekoBot.Modules.Games.Services;
using CommandLine;
using NadekoBot.Services;
using Serilog;
namespace NadekoBot.Modules.Games.Common
@@ -37,15 +38,17 @@ namespace NadekoBot.Modules.Games.Common
private readonly GamesService _games;
private readonly string _prefix;
private readonly Options _options;
private readonly IEmbedBuilderService _eb;
public TypingGame(GamesService games, DiscordSocketClient client, ITextChannel channel,
string prefix, Options options)
string prefix, Options options, IEmbedBuilderService eb)
{
_games = games;
_client = client;
_prefix = prefix;
_options = options;
_eb = eb;
this.Channel = channel;
IsActive = false;
sw = new Stopwatch();
@@ -62,7 +65,7 @@ namespace NadekoBot.Modules.Games.Common
sw.Reset();
try
{
await Channel.SendConfirmAsync("Typing contest stopped.").ConfigureAwait(false);
await Channel.SendConfirmAsync(_eb, "Typing contest stopped.");
}
catch (Exception ex)
{
@@ -80,7 +83,8 @@ namespace NadekoBot.Modules.Games.Common
var i = (int)(CurrentSentence.Length / WORD_VALUE * 1.7f);
try
{
await Channel.SendConfirmAsync($@":clock2: Next contest will last for {i} seconds. Type the bolded text as fast as you can.").ConfigureAwait(false);
await Channel.SendConfirmAsync(_eb,
$@":clock2: Next contest will last for {i} seconds. Type the bolded text as fast as you can.");
var time = _options.StartTime;
@@ -156,7 +160,7 @@ namespace NadekoBot.Modules.Games.Common
var elapsed = sw.Elapsed;
var wpm = CurrentSentence.Length / WORD_VALUE / elapsed.TotalSeconds * 60;
finishedUserIds.Add(msg.Author.Id);
await this.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
await this.Channel.EmbedAsync(_eb.Create().WithOkColor()
.WithTitle($"{msg.Author} finished the race!")
.AddField("Place", $"#{finishedUserIds.Count}", true)
.AddField("WPM", $"{wpm:F1} *[{elapsed.TotalSeconds:F2}sec]*", true)
@@ -164,7 +168,7 @@ namespace NadekoBot.Modules.Games.Common
if (finishedUserIds.Count % 4 == 0)
{
await this.Channel.SendConfirmAsync(
await this.Channel.SendConfirmAsync(_eb,
$":exclamation: A lot of people finished, here is the text for those still typing:" +
$"\n\n**{Format.Sanitize(CurrentSentence.Replace(" ", " \x200B", StringComparison.InvariantCulture)).SanitizeMentions(true)}**")
.ConfigureAwait(false);

View File

@@ -38,7 +38,7 @@ namespace NadekoBot.Modules.Games
if (listArr.Length < 2)
return;
var rng = new NadekoRandom();
await ctx.Channel.SendConfirmAsync("🤔", listArr[rng.Next(0, listArr.Length)]).ConfigureAwait(false);
await SendConfirmAsync("🤔", listArr[rng.Next(0, listArr.Length)]).ConfigureAwait(false);
}
[NadekoCommand, Aliases]
@@ -48,7 +48,7 @@ namespace NadekoBot.Modules.Games
return;
var res = _service.GetEightballResponse(ctx.User.Id, question);
await ctx.Channel.EmbedAsync(new EmbedBuilder().WithColor(Bot.OkColor)
await ctx.Channel.EmbedAsync(_eb.Create().WithOkColor()
.WithDescription(ctx.User.ToString())
.AddField("❓ " + GetText("question"), question, false)
.AddField("🎱 " + GetText("8ball"), res, false));
@@ -78,7 +78,7 @@ namespace NadekoBot.Modules.Games
await ctx.Channel.SendFileAsync(stream: imgStream,
filename: $"girl_{usr}.png",
text: Format.Bold($"{ctx.User.Mention} Girl Rating For {usr}"),
embed: new EmbedBuilder()
embed: _eb.Create()
.WithOkColor()
.AddField("Hot", gr.Hot.ToString("F2"), true)
.AddField("Crazy", gr.Crazy.ToString("F2"), true)
@@ -152,7 +152,7 @@ namespace NadekoBot.Modules.Games
[NadekoCommand, Aliases]
public async Task Linux(string guhnoo, string loonix)
{
await ctx.Channel.SendConfirmAsync(
await SendConfirmAsync(
$@"I'd just like to interject for moment. What you're refering to as {loonix}, is in fact, {guhnoo}/{loonix}, or as I've recently taken to calling it, {guhnoo} plus {loonix}. {loonix} is not an operating system unto itself, but rather another free component of a fully functioning {guhnoo} system made useful by the {guhnoo} corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX.
Many computer users run a modified version of the {guhnoo} system every day, without realizing it. Through a peculiar turn of events, the version of {guhnoo} which is widely used today is often called {loonix}, and many of its users are not aware that it is basically the {guhnoo} system, developed by the {guhnoo} Project.

View File

@@ -27,7 +27,7 @@ namespace NadekoBot.Modules.Games
[RequireContext(ContextType.Guild)]
public async Task Hangmanlist()
{
await ctx.Channel.SendConfirmAsync(Format.Code(GetText("hangman_types", Prefix)) + "\n" + string.Join("\n", _service.TermPool.Data.Keys)).ConfigureAwait(false);
await SendConfirmAsync(Format.Code(GetText("hangman_types", Prefix)) + "\n" + string.Join("\n", _service.TermPool.Data.Keys)).ConfigureAwait(false);
}
[NadekoCommand, Aliases]
@@ -58,7 +58,7 @@ namespace NadekoBot.Modules.Games
try
{
await ctx.Channel.SendConfirmAsync(GetText("hangman_game_started") + $" ({hm.TermType})",
await SendConfirmAsync(GetText("hangman_game_started") + $" ({hm.TermType})",
hm.ScrambledWord + "\n" + hm.GetHangman())
.ConfigureAwait(false);
}
@@ -87,7 +87,7 @@ namespace NadekoBot.Modules.Games
{
if (winner is null)
{
var loseEmbed = new EmbedBuilder().WithTitle($"Hangman Game ({game.TermType}) - Ended")
var loseEmbed = _eb.Create().WithTitle($"Hangman Game ({game.TermType}) - Ended")
.WithDescription(Format.Bold("You lose."))
.AddField("It was", game.Term.GetWord())
.WithFooter(string.Join(" ", game.PreviousGuesses))
@@ -99,7 +99,7 @@ namespace NadekoBot.Modules.Games
return ctx.Channel.EmbedAsync(loseEmbed);
}
var winEmbed = new EmbedBuilder().WithTitle($"Hangman Game ({game.TermType}) - Ended")
var winEmbed = _eb.Create().WithTitle($"Hangman Game ({game.TermType}) - Ended")
.WithDescription(Format.Bold($"{winner} Won."))
.AddField("It was", game.Term.GetWord())
.WithFooter(string.Join(" ", game.PreviousGuesses))
@@ -113,19 +113,19 @@ namespace NadekoBot.Modules.Games
private Task Hm_OnLetterAlreadyUsed(Hangman game, string user, char guess)
{
return ctx.Channel.SendErrorAsync($"Hangman Game ({game.TermType})", $"{user} Letter `{guess}` has already been used. You can guess again in 3 seconds.\n" + game.ScrambledWord + "\n" + game.GetHangman(),
return SendErrorAsync($"Hangman Game ({game.TermType})", $"{user} Letter `{guess}` has already been used. You can guess again in 3 seconds.\n" + game.ScrambledWord + "\n" + game.GetHangman(),
footer: string.Join(" ", game.PreviousGuesses));
}
private Task Hm_OnGuessSucceeded(Hangman game, string user, char guess)
{
return ctx.Channel.SendConfirmAsync($"Hangman Game ({game.TermType})", $"{user} guessed a letter `{guess}`!\n" + game.ScrambledWord + "\n" + game.GetHangman(),
return SendConfirmAsync($"Hangman Game ({game.TermType})", $"{user} guessed a letter `{guess}`!\n" + game.ScrambledWord + "\n" + game.GetHangman(),
footer: string.Join(" ", game.PreviousGuesses));
}
private Task Hm_OnGuessFailed(Hangman game, string user, char guess)
{
return ctx.Channel.SendErrorAsync($"Hangman Game ({game.TermType})", $"{user} Letter `{guess}` does not exist. You can guess again in 3 seconds.\n" + game.ScrambledWord + "\n" + game.GetHangman(),
return SendErrorAsync($"Hangman Game ({game.TermType})", $"{user} Letter `{guess}` does not exist. You can guess again in 3 seconds.\n" + game.ScrambledWord + "\n" + game.GetHangman(),
footer: string.Join(" ", game.PreviousGuesses));
}

View File

@@ -113,11 +113,11 @@ namespace NadekoBot.Modules.Games
if (!items.Any())
{
return new EmbedBuilder().WithErrorColor()
return _eb.Create().WithErrorColor()
.WithDescription("-");
}
return items.Aggregate(new EmbedBuilder().WithOkColor(),
return items.Aggregate(_eb.Create().WithOkColor(),
(eb, i) => eb.AddField(i.GuildId.ToString(), i.ChannelId));
}, enabledIn.Count(), 9);
}

View File

@@ -41,7 +41,7 @@ namespace NadekoBot.Modules.Games
if (_service.StartPoll(poll))
{
await ctx.Channel
.EmbedAsync(new EmbedBuilder()
.EmbedAsync(_eb.Create()
.WithOkColor()
.WithTitle(GetText("poll_created", ctx.User.ToString()))
.WithDescription(
@@ -83,14 +83,14 @@ namespace NadekoBot.Modules.Games
.ConfigureAwait(false);
}
public EmbedBuilder GetStats(Poll poll, string title)
public IEmbedBuilder GetStats(Poll poll, string title)
{
var results = poll.Votes.GroupBy(kvp => kvp.VoteIndex)
.ToDictionary(x => x.Key, x => x.Sum(kvp => 1));
var totalVotesCast = results.Sum(x => x.Value);
var eb = new EmbedBuilder().WithTitle(title);
var eb = _eb.Create().WithTitle(title);
var sb = new StringBuilder()
.AppendLine(Format.Bold(poll.Question))

View File

@@ -22,6 +22,7 @@ namespace NadekoBot.Modules.Games.Services
private readonly CommandHandler _cmd;
private readonly IBotStrings _strings;
private readonly IBotCredentials _creds;
private readonly IEmbedBuilderService _eb;
private readonly IHttpClientFactory _httpFactory;
public ConcurrentDictionary<ulong, Lazy<IChatterBotSession>> ChatterBotGuilds { get; }
@@ -30,13 +31,14 @@ namespace NadekoBot.Modules.Games.Services
public ChatterBotService(DiscordSocketClient client, PermissionService perms,
Bot bot, CommandHandler cmd, IBotStrings strings, IHttpClientFactory factory,
IBotCredentials creds)
IBotCredentials creds, IEmbedBuilderService eb)
{
_client = client;
_perms = perms;
_cmd = cmd;
_strings = strings;
_creds = creds;
_eb = eb;
_httpFactory = factory;
ChatterBotGuilds = new ConcurrentDictionary<ulong, Lazy<IChatterBotSession>>(
@@ -86,18 +88,18 @@ namespace NadekoBot.Modules.Games.Services
return message;
}
public static async Task<bool> TryAsk(IChatterBotSession cleverbot, ITextChannel channel, string message)
public async Task<bool> TryAsk(IChatterBotSession cleverbot, ITextChannel channel, string message)
{
await channel.TriggerTypingAsync().ConfigureAwait(false);
var response = await cleverbot.Think(message).ConfigureAwait(false);
try
{
await channel.SendConfirmAsync(response.SanitizeMentions(true)).ConfigureAwait(false);
await channel.SendConfirmAsync(_eb, response.SanitizeMentions(true)).ConfigureAwait(false);
}
catch
{
await channel.SendConfirmAsync(response.SanitizeMentions(true)).ConfigureAwait(false); // try twice :\
await channel.SendConfirmAsync(_eb, response.SanitizeMentions(true)).ConfigureAwait(false); // try twice :\
}
return true;
}
@@ -121,7 +123,7 @@ namespace NadekoBot.Modules.Games.Services
if (pc.Verbose)
{
var returnMsg = _strings.GetText("trigger", guild.Id, index + 1, Format.Bold(pc.Permissions[index].GetCommand(_cmd.GetPrefix(guild), (SocketGuild)guild)));
try { await usrMsg.Channel.SendErrorAsync(returnMsg).ConfigureAwait(false); } catch { }
try { await usrMsg.Channel.SendErrorAsync(_eb, returnMsg).ConfigureAwait(false); } catch { }
Log.Information(returnMsg);
}
return true;

View File

@@ -23,11 +23,13 @@ namespace NadekoBot.Modules.Games.Services
private readonly DbService _db;
private readonly IBotStrings _strs;
private readonly IEmbedBuilderService _eb;
public PollService(DbService db, IBotStrings strs)
public PollService(DbService db, IBotStrings strs, IEmbedBuilderService eb)
{
_db = db;
_strs = strs;
_eb = eb;
using (var uow = db.GetDbContext())
{
@@ -97,7 +99,7 @@ namespace NadekoBot.Modules.Games.Services
private async Task Pr_OnVoted(IUserMessage msg, IGuildUser usr)
{
var toDelete = await msg.Channel.SendConfirmAsync(_strs.GetText("poll_voted",
var toDelete = await msg.Channel.SendConfirmAsync(_eb, _strs.GetText("poll_voted",
usr.Guild.Id, Format.Bold(usr.ToString())))
.ConfigureAwait(false);
toDelete.DeleteAfter(5);

View File

@@ -35,14 +35,11 @@ namespace NadekoBot.Modules.Games
var (options, _) = OptionsParser.ParseFrom(new TypingGame.Options(), args);
var channel = (ITextChannel)ctx.Channel;
var game = _service.RunningContests.GetOrAdd(channel.Guild.Id, id => new TypingGame(_games, _client, channel, Prefix, options));
var game = _service.RunningContests.GetOrAdd(ctx.Guild.Id, id => new TypingGame(_games, _client, channel, Prefix, options, _eb));
if (game.IsActive)
{
await channel.SendErrorAsync(
$"Contest already running in " +
$"{game.Channel.Mention} channel.")
.ConfigureAwait(false);
await SendErrorAsync($"Contest already running in {game.Channel.Mention} channel.");
}
else
{
@@ -54,13 +51,13 @@ namespace NadekoBot.Modules.Games
[RequireContext(ContextType.Guild)]
public async Task TypeStop()
{
var channel = (ITextChannel)ctx.Channel;
if (_service.RunningContests.TryRemove(channel.Guild.Id, out TypingGame game))
if (_service.RunningContests.TryRemove(ctx.Guild.Id, out TypingGame game))
{
await game.Stop().ConfigureAwait(false);
return;
}
await channel.SendErrorAsync("No contest to stop on this channel.").ConfigureAwait(false);
await SendErrorAsync("No contest to stop on this channel.").ConfigureAwait(false);
}
@@ -69,21 +66,18 @@ namespace NadekoBot.Modules.Games
[OwnerOnly]
public async Task Typeadd([Leftover] string text)
{
var channel = (ITextChannel)ctx.Channel;
if (string.IsNullOrWhiteSpace(text))
return;
_games.AddTypingArticle(ctx.User, text);
await channel.SendConfirmAsync("Added new article for typing game.").ConfigureAwait(false);
await SendConfirmAsync("Added new article for typing game.").ConfigureAwait(false);
}
[NadekoCommand, Aliases]
[RequireContext(ContextType.Guild)]
public async Task Typelist(int page = 1)
{
var channel = (ITextChannel)ctx.Channel;
if (page < 1)
return;
@@ -91,11 +85,11 @@ namespace NadekoBot.Modules.Games
if (!articles.Any())
{
await channel.SendErrorAsync($"{ctx.User.Mention} `No articles found on that page.`").ConfigureAwait(false);
await SendErrorAsync($"{ctx.User.Mention} `No articles found on that page.`").ConfigureAwait(false);
return;
}
var i = (page - 1) * 15;
await channel.SendConfirmAsync("List of articles for Type Race", string.Join("\n", articles.Select(a => $"`#{++i}` - {a.Text.TrimTo(50)}")))
await SendConfirmAsync("List of articles for Type Race", string.Join("\n", articles.Select(a => $"`#{++i}` - {a.Text.TrimTo(50)}")))
.ConfigureAwait(false);
}
@@ -111,7 +105,7 @@ namespace NadekoBot.Modules.Games
return;
}
var embed = new EmbedBuilder()
var embed = _eb.Create()
.WithTitle($"Removed typing article #{index + 1}")
.WithDescription(removed.Text.TrimTo(50))
.WithOkColor();

View File

@@ -42,7 +42,7 @@ namespace NadekoBot.Modules.Games
});
return;
}
game = new TicTacToe(base.Strings, this._client, channel, (IGuildUser)ctx.User, options);
game = new TicTacToe(base.Strings, this._client, channel, (IGuildUser)ctx.User, options, _eb);
_service.TicTacToeGames.Add(channel.Id, game);
await ReplyConfirmLocalizedAsync("ttt_created").ConfigureAwait(false);

View File

@@ -48,7 +48,9 @@ namespace NadekoBot.Modules.Games
{
return;
}
var trivia = new TriviaGame(Strings, _client, config, _cache, _cs, channel.Guild, channel, opts, Prefix + "tq");
var trivia = new TriviaGame(Strings, _client, config, _cache, _cs, channel.Guild, channel, opts,
Prefix + "tq", _eb);
if (_service.RunningTrivias.TryAdd(channel.Guild.Id, trivia))
{
try
@@ -63,7 +65,7 @@ namespace NadekoBot.Modules.Games
return;
}
await ctx.Channel.SendErrorAsync(GetText("trivia_already_running") + "\n" + trivia.CurrentQuestion)
await SendErrorAsync(GetText("trivia_already_running") + "\n" + trivia.CurrentQuestion)
.ConfigureAwait(false);
}
@@ -71,11 +73,9 @@ namespace NadekoBot.Modules.Games
[RequireContext(ContextType.Guild)]
public async Task Tl()
{
var channel = (ITextChannel)ctx.Channel;
if (_service.RunningTrivias.TryGetValue(channel.Guild.Id, out TriviaGame trivia))
if (_service.RunningTrivias.TryGetValue(ctx.Guild.Id, out TriviaGame trivia))
{
await channel.SendConfirmAsync(GetText("leaderboard"), trivia.GetLeaderboard()).ConfigureAwait(false);
await SendConfirmAsync(GetText("leaderboard"), trivia.GetLeaderboard()).ConfigureAwait(false);
return;
}