diff --git a/locale/Messages.resx b/locale/Messages.resx index 218c414..b881996 100644 --- a/locale/Messages.resx +++ b/locale/Messages.resx @@ -594,4 +594,64 @@ Reminder edited + + It is certain + + + It is decidedly so + + + Without a doubt + + + Yes — definitely + + + You may rely on it + + + As I see it, yes + + + Most likely + + + Outlook good + + + Signs point to yes + + + Yes + + + Reply hazy, try again + + + Ask again later + + + Better not tell you now + + + Cannot predict now + + + Concentrate and ask again + + + Don’t count on it + + + My reply is no + + + My sources say no + + + Outlook not so good + + + Very doubtful + diff --git a/locale/Messages.ru.resx b/locale/Messages.ru.resx index 3eb53f1..cb318cd 100644 --- a/locale/Messages.ru.resx +++ b/locale/Messages.ru.resx @@ -594,4 +594,64 @@ Напоминание отредактировано + + Бесспорно + + + Предрешено + + + Никаких сомнений + + + Определённо да + + + Можешь быть уверен в этом + + + Мне кажется — «да» + + + Вероятнее всего + + + Хорошие перспективы + + + Знаки говорят — «да» + + + Да + + + Пока не ясно, попробуй снова + + + Спроси позже + + + Лучше не рассказывать + + + Сейчас нельзя предсказать + + + Сконцентрируйся и спроси снова + + + Даже не думай + + + Мой ответ — «нет» + + + По моим данным — «нет» + + + Перспективы не очень хорошие + + + Весьма сомнительно + diff --git a/locale/Messages.tt-ru.resx b/locale/Messages.tt-ru.resx index f5d789b..f0b80a7 100644 --- a/locale/Messages.tt-ru.resx +++ b/locale/Messages.tt-ru.resx @@ -594,4 +594,64 @@ напоминалка подправлена + + абсолютли + + + заявлено + + + ваще не сомневайся + + + 100% да + + + будь в этом уверен + + + я считаю что да + + + ну вполне вероятно + + + ну выглядит нормально + + + мне сказали ок + + + мгм + + + ну-ка попробуй снова + + + давай позже + + + щас пока не скажу + + + я не могу сейчас предсказать + + + ну сконцентрируйся и давай еще раз + + + даже не думай + + + мое завление это нет + + + я тут посчитал, короче нет + + + выглядит такое себе + + + чот сомневаюсь + diff --git a/src/Commands/ToolsCommandGroup.cs b/src/Commands/ToolsCommandGroup.cs index fb87117..3c16232 100644 --- a/src/Commands/ToolsCommandGroup.cs +++ b/src/Commands/ToolsCommandGroup.cs @@ -21,7 +21,7 @@ using Remora.Results; namespace Octobot.Commands; /// -/// Handles tool commands: /userinfo, /guildinfo, /random, /timestamp. +/// Handles tool commands: /userinfo, /guildinfo, /random, /timestamp, /8ball. /// [UsedImplicitly] public class ToolsCommandGroup : CommandGroup @@ -496,4 +496,65 @@ public class ToolsCommandGroup : CommandGroup return _feedback.SendContextualEmbedResultAsync(embed, ct: ct); } + + /// + /// A slash command that shows a random answer from the Magic 8-Ball. + /// + /// Unused input. + /// + /// The 8-Ball answers were taken from Wikipedia. + /// + /// + /// A feedback sending result which may or may not have succeeded. + /// + [Command("8ball")] + [DiscordDefaultDMPermission(false)] + [Description("Ask the Magic 8-Ball a question")] + [UsedImplicitly] + public async Task ExecuteEightBallAsync( + // let the user think he's actually asking the ball a question + string question) + { + if (!_context.TryGetContextIDs(out var guildId, out _, out _)) + { + return new ArgumentInvalidError(nameof(_context), "Unable to retrieve necessary IDs from command context"); + } + + var botResult = await _userApi.GetCurrentUserAsync(CancellationToken); + if (!botResult.IsDefined(out var bot)) + { + return Result.FromError(botResult); + } + + var data = await _guildData.GetData(guildId, CancellationToken); + Messages.Culture = GuildSettings.Language.Get(data.Settings); + + return await AnswerEightBallAsync(bot, CancellationToken); + } + + private static readonly string[] AnswerTypes = + [ + "Positive", "Questionable", "Neutral", "Negative" + ]; + + private Task AnswerEightBallAsync(IUser bot, CancellationToken ct) + { + var typeNumber = Random.Shared.Next(0, 4); + var embedColor = typeNumber switch + { + 0 => ColorsList.Blue, + 1 => ColorsList.Green, + 2 => ColorsList.Yellow, + 3 => ColorsList.Red, + _ => throw new ArgumentOutOfRangeException(null, nameof(typeNumber)) + }; + + var answer = $"EightBall{AnswerTypes[typeNumber]}{Random.Shared.Next(1, 6)}".Localized(); + + var embed = new EmbedBuilder().WithSmallTitle(answer, bot) + .WithColour(embedColor) + .Build(); + + return _feedback.SendContextualEmbedResultAsync(embed, ct: ct); + } } diff --git a/src/Messages.Designer.cs b/src/Messages.Designer.cs index a0c915a..9597bcd 100644 --- a/src/Messages.Designer.cs +++ b/src/Messages.Designer.cs @@ -1058,5 +1058,125 @@ namespace Octobot { return ResourceManager.GetString("ReminderEdited", resourceCulture); } } + + internal static string EightBallPositive1 { + get { + return ResourceManager.GetString("EightBallPositive1", resourceCulture); + } + } + + internal static string EightBallPositive2 { + get { + return ResourceManager.GetString("EightBallPositive2", resourceCulture); + } + } + + internal static string EightBallPositive3 { + get { + return ResourceManager.GetString("EightBallPositive3", resourceCulture); + } + } + + internal static string EightBallPositive4 { + get { + return ResourceManager.GetString("EightBallPositive4", resourceCulture); + } + } + + internal static string EightBallPositive5 { + get { + return ResourceManager.GetString("EightBallPositive5", resourceCulture); + } + } + + internal static string EightBallQuestionable1 { + get { + return ResourceManager.GetString("EightBallQuestionable1", resourceCulture); + } + } + + internal static string EightBallQuestionable2 { + get { + return ResourceManager.GetString("EightBallQuestionable2", resourceCulture); + } + } + + internal static string EightBallQuestionable3 { + get { + return ResourceManager.GetString("EightBallQuestionable3", resourceCulture); + } + } + + internal static string EightBallQuestionable4 { + get { + return ResourceManager.GetString("EightBallQuestionable4", resourceCulture); + } + } + + internal static string EightBallQuestionable5 { + get { + return ResourceManager.GetString("EightBallQuestionable5", resourceCulture); + } + } + + internal static string EightBallNeutral1 { + get { + return ResourceManager.GetString("EightBallNeutral1", resourceCulture); + } + } + + internal static string EightBallNeutral2 { + get { + return ResourceManager.GetString("EightBallNeutral2", resourceCulture); + } + } + + internal static string EightBallNeutral3 { + get { + return ResourceManager.GetString("EightBallNeutral3", resourceCulture); + } + } + + internal static string EightBallNeutral4 { + get { + return ResourceManager.GetString("EightBallNeutral4", resourceCulture); + } + } + + internal static string EightBallNeutral5 { + get { + return ResourceManager.GetString("EightBallNeutral5", resourceCulture); + } + } + + internal static string EightBallNegative1 { + get { + return ResourceManager.GetString("EightBallNegative1", resourceCulture); + } + } + + internal static string EightBallNegative2 { + get { + return ResourceManager.GetString("EightBallNegative2", resourceCulture); + } + } + + internal static string EightBallNegative3 { + get { + return ResourceManager.GetString("EightBallNegative3", resourceCulture); + } + } + + internal static string EightBallNegative4 { + get { + return ResourceManager.GetString("EightBallNegative4", resourceCulture); + } + } + + internal static string EightBallNegative5 { + get { + return ResourceManager.GetString("EightBallNegative5", resourceCulture); + } + } } }