show math help when people are not very smart

This commit is contained in:
13xforever 2020-02-07 15:50:54 +05:00
parent 27907c7ee1
commit 91258e549f

View File

@ -1,7 +1,6 @@
using System;
using System.Threading.Tasks;
using CompatBot.Commands.Attributes;
using CompatBot.Utils;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using org.mariuszgromada.math.mxparser;
@ -15,6 +14,19 @@ namespace CompatBot.Commands
[GroupCommand, Priority(9)]
public async Task Expression(CommandContext ctx, [RemainingText, Description("Math expression")] string expression)
{
if (string.IsNullOrEmpty(expression))
{
try
{
var helpCmd = ctx.CommandsNext.FindCommand("math help", out _);
var helpCtx = ctx.CommandsNext.CreateContext(ctx.Message, ctx.Prefix, helpCmd);
await helpCmd.ExecuteAsync(helpCtx).ConfigureAwait(false);
}
catch { }
return;
}
var result = @"Something went wrong ¯\\_(ツ)\_/¯" + "\nMath is hard, yo";
try
{
@ -30,7 +42,7 @@ namespace CompatBot.Commands
[Command("help"), LimitedToSpamChannel, Cooldown(1, 5, CooldownBucketType.Channel)]
[Description("General math expression help, or description of specific math word")]
public Task Help(CommandContext ctx, string word = null)
public Task Help(CommandContext ctx)
{
return ctx.RespondAsync("Help for all the features and built-in constants and functions could be found at <https://mathparser.org/mxparser-math-collection/>");
}