mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-01-31 09:09:00 +03:00
Add /8ball command (#264)
@neroduckale was bored so I made this feature. --------- Signed-off-by: mctaylors <cantsendmails@mctaylors.ru> Signed-off-by: Macintxsh <95250141+mctaylors@users.noreply.github.com> Co-authored-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
bf8a89c4e9
commit
8eed295fcd
5 changed files with 362 additions and 1 deletions
|
@ -594,4 +594,64 @@
|
|||
<data name="ReminderEdited" xml:space="preserve">
|
||||
<value>Reminder edited</value>
|
||||
</data>
|
||||
<data name="EightBallPositive1" xml:space="preserve">
|
||||
<value>It is certain</value>
|
||||
</data>
|
||||
<data name="EightBallPositive2" xml:space="preserve">
|
||||
<value>It is decidedly so</value>
|
||||
</data>
|
||||
<data name="EightBallPositive3" xml:space="preserve">
|
||||
<value>Without a doubt</value>
|
||||
</data>
|
||||
<data name="EightBallPositive4" xml:space="preserve">
|
||||
<value>Yes — definitely</value>
|
||||
</data>
|
||||
<data name="EightBallPositive5" xml:space="preserve">
|
||||
<value>You may rely on it</value>
|
||||
</data>
|
||||
<data name="EightBallQuestionable1" xml:space="preserve">
|
||||
<value>As I see it, yes</value>
|
||||
</data>
|
||||
<data name="EightBallQuestionable2" xml:space="preserve">
|
||||
<value>Most likely</value>
|
||||
</data>
|
||||
<data name="EightBallQuestionable3" xml:space="preserve">
|
||||
<value>Outlook good</value>
|
||||
</data>
|
||||
<data name="EightBallQuestionable4" xml:space="preserve">
|
||||
<value>Signs point to yes</value>
|
||||
</data>
|
||||
<data name="EightBallQuestionable5" xml:space="preserve">
|
||||
<value>Yes</value>
|
||||
</data>
|
||||
<data name="EightBallNeutral1" xml:space="preserve">
|
||||
<value>Reply hazy, try again</value>
|
||||
</data>
|
||||
<data name="EightBallNeutral2" xml:space="preserve">
|
||||
<value>Ask again later</value>
|
||||
</data>
|
||||
<data name="EightBallNeutral3" xml:space="preserve">
|
||||
<value>Better not tell you now</value>
|
||||
</data>
|
||||
<data name="EightBallNeutral4" xml:space="preserve">
|
||||
<value>Cannot predict now</value>
|
||||
</data>
|
||||
<data name="EightBallNeutral5" xml:space="preserve">
|
||||
<value>Concentrate and ask again</value>
|
||||
</data>
|
||||
<data name="EightBallNegative1" xml:space="preserve">
|
||||
<value>Don’t count on it</value>
|
||||
</data>
|
||||
<data name="EightBallNegative2" xml:space="preserve">
|
||||
<value>My reply is no</value>
|
||||
</data>
|
||||
<data name="EightBallNegative3" xml:space="preserve">
|
||||
<value>My sources say no</value>
|
||||
</data>
|
||||
<data name="EightBallNegative4" xml:space="preserve">
|
||||
<value>Outlook not so good</value>
|
||||
</data>
|
||||
<data name="EightBallNegative5" xml:space="preserve">
|
||||
<value>Very doubtful</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
|
@ -594,4 +594,64 @@
|
|||
<data name="ReminderEdited" xml:space="preserve">
|
||||
<value>Напоминание отредактировано</value>
|
||||
</data>
|
||||
<data name="EightBallPositive1" xml:space="preserve">
|
||||
<value>Бесспорно</value>
|
||||
</data>
|
||||
<data name="EightBallPositive2" xml:space="preserve">
|
||||
<value>Предрешено</value>
|
||||
</data>
|
||||
<data name="EightBallPositive3" xml:space="preserve">
|
||||
<value>Никаких сомнений</value>
|
||||
</data>
|
||||
<data name="EightBallPositive4" xml:space="preserve">
|
||||
<value>Определённо да</value>
|
||||
</data>
|
||||
<data name="EightBallPositive5" xml:space="preserve">
|
||||
<value>Можешь быть уверен в этом</value>
|
||||
</data>
|
||||
<data name="EightBallQuestionable1" xml:space="preserve">
|
||||
<value>Мне кажется — «да»</value>
|
||||
</data>
|
||||
<data name="EightBallQuestionable2" xml:space="preserve">
|
||||
<value>Вероятнее всего</value>
|
||||
</data>
|
||||
<data name="EightBallQuestionable3" xml:space="preserve">
|
||||
<value>Хорошие перспективы</value>
|
||||
</data>
|
||||
<data name="EightBallQuestionable4" xml:space="preserve">
|
||||
<value>Знаки говорят — «да»</value>
|
||||
</data>
|
||||
<data name="EightBallQuestionable5" xml:space="preserve">
|
||||
<value>Да</value>
|
||||
</data>
|
||||
<data name="EightBallNeutral1" xml:space="preserve">
|
||||
<value>Пока не ясно, попробуй снова</value>
|
||||
</data>
|
||||
<data name="EightBallNeutral2" xml:space="preserve">
|
||||
<value>Спроси позже</value>
|
||||
</data>
|
||||
<data name="EightBallNeutral3" xml:space="preserve">
|
||||
<value>Лучше не рассказывать</value>
|
||||
</data>
|
||||
<data name="EightBallNeutral4" xml:space="preserve">
|
||||
<value>Сейчас нельзя предсказать</value>
|
||||
</data>
|
||||
<data name="EightBallNeutral5" xml:space="preserve">
|
||||
<value>Сконцентрируйся и спроси снова</value>
|
||||
</data>
|
||||
<data name="EightBallNegative1" xml:space="preserve">
|
||||
<value>Даже не думай</value>
|
||||
</data>
|
||||
<data name="EightBallNegative2" xml:space="preserve">
|
||||
<value>Мой ответ — «нет»</value>
|
||||
</data>
|
||||
<data name="EightBallNegative3" xml:space="preserve">
|
||||
<value>По моим данным — «нет»</value>
|
||||
</data>
|
||||
<data name="EightBallNegative4" xml:space="preserve">
|
||||
<value>Перспективы не очень хорошие</value>
|
||||
</data>
|
||||
<data name="EightBallNegative5" xml:space="preserve">
|
||||
<value>Весьма сомнительно</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
|
@ -594,4 +594,64 @@
|
|||
<data name="ReminderEdited" xml:space="preserve">
|
||||
<value>напоминалка подправлена</value>
|
||||
</data>
|
||||
<data name="EightBallPositive1" xml:space="preserve">
|
||||
<value>абсолютли</value>
|
||||
</data>
|
||||
<data name="EightBallPositive2" xml:space="preserve">
|
||||
<value>заявлено</value>
|
||||
</data>
|
||||
<data name="EightBallPositive3" xml:space="preserve">
|
||||
<value>ваще не сомневайся</value>
|
||||
</data>
|
||||
<data name="EightBallPositive4" xml:space="preserve">
|
||||
<value>100% да</value>
|
||||
</data>
|
||||
<data name="EightBallPositive5" xml:space="preserve">
|
||||
<value>будь в этом уверен</value>
|
||||
</data>
|
||||
<data name="EightBallQuestionable1" xml:space="preserve">
|
||||
<value>я считаю что да</value>
|
||||
</data>
|
||||
<data name="EightBallQuestionable2" xml:space="preserve">
|
||||
<value>ну вполне вероятно</value>
|
||||
</data>
|
||||
<data name="EightBallQuestionable3" xml:space="preserve">
|
||||
<value>ну выглядит нормально</value>
|
||||
</data>
|
||||
<data name="EightBallQuestionable4" xml:space="preserve">
|
||||
<value>мне сказали ок</value>
|
||||
</data>
|
||||
<data name="EightBallQuestionable5" xml:space="preserve">
|
||||
<value>мгм</value>
|
||||
</data>
|
||||
<data name="EightBallNeutral1" xml:space="preserve">
|
||||
<value>ну-ка попробуй снова</value>
|
||||
</data>
|
||||
<data name="EightBallNeutral2" xml:space="preserve">
|
||||
<value>давай позже</value>
|
||||
</data>
|
||||
<data name="EightBallNeutral3" xml:space="preserve">
|
||||
<value>щас пока не скажу</value>
|
||||
</data>
|
||||
<data name="EightBallNeutral4" xml:space="preserve">
|
||||
<value>я не могу сейчас предсказать</value>
|
||||
</data>
|
||||
<data name="EightBallNeutral5" xml:space="preserve">
|
||||
<value>ну сконцентрируйся и давай еще раз</value>
|
||||
</data>
|
||||
<data name="EightBallNegative1" xml:space="preserve">
|
||||
<value>даже не думай</value>
|
||||
</data>
|
||||
<data name="EightBallNegative2" xml:space="preserve">
|
||||
<value>мое завление это нет</value>
|
||||
</data>
|
||||
<data name="EightBallNegative3" xml:space="preserve">
|
||||
<value>я тут посчитал, короче нет</value>
|
||||
</data>
|
||||
<data name="EightBallNegative4" xml:space="preserve">
|
||||
<value>выглядит такое себе</value>
|
||||
</data>
|
||||
<data name="EightBallNegative5" xml:space="preserve">
|
||||
<value>чот сомневаюсь</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
|
@ -21,7 +21,7 @@ using Remora.Results;
|
|||
namespace Octobot.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// Handles tool commands: /userinfo, /guildinfo, /random, /timestamp.
|
||||
/// Handles tool commands: /userinfo, /guildinfo, /random, /timestamp, /8ball.
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public class ToolsCommandGroup : CommandGroup
|
||||
|
@ -496,4 +496,65 @@ public class ToolsCommandGroup : CommandGroup
|
|||
|
||||
return _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A slash command that shows a random answer from the Magic 8-Ball.
|
||||
/// </summary>
|
||||
/// <param name="question">Unused input.</param>
|
||||
/// <remarks>
|
||||
/// The 8-Ball answers were taken from <a href="https://en.wikipedia.org/wiki/Magic_8_Ball#Possible_answers">Wikipedia</a>.
|
||||
/// </remarks>
|
||||
/// <returns>
|
||||
/// A feedback sending result which may or may not have succeeded.
|
||||
/// </returns>
|
||||
[Command("8ball")]
|
||||
[DiscordDefaultDMPermission(false)]
|
||||
[Description("Ask the Magic 8-Ball a question")]
|
||||
[UsedImplicitly]
|
||||
public async Task<Result> 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<Result> 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);
|
||||
}
|
||||
}
|
||||
|
|
120
src/Messages.Designer.cs
generated
120
src/Messages.Designer.cs
generated
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue