utility done
This commit is contained in:
parent
14876012f5
commit
091ea0fd32
@ -10,9 +10,11 @@ using System.Threading.Tasks;
|
|||||||
namespace NadekoBot.Modules.Utility
|
namespace NadekoBot.Modules.Utility
|
||||||
{
|
{
|
||||||
public partial class Utility
|
public partial class Utility
|
||||||
|
{
|
||||||
|
[Group]
|
||||||
|
public class CalcCommands : ModuleBase
|
||||||
{
|
{
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
|
||||||
public async Task Calculate([Remainder] string expression)
|
public async Task Calculate([Remainder] string expression)
|
||||||
{
|
{
|
||||||
var expr = new NCalc.Expression(expression, NCalc.EvaluateOptions.IgnoreCase);
|
var expr = new NCalc.Expression(expression, NCalc.EvaluateOptions.IgnoreCase);
|
||||||
@ -26,16 +28,18 @@ namespace NadekoBot.Modules.Utility
|
|||||||
|
|
||||||
private static void Expr_EvaluateParameter(string name, NCalc.ParameterArgs args)
|
private static void Expr_EvaluateParameter(string name, NCalc.ParameterArgs args)
|
||||||
{
|
{
|
||||||
switch (name.ToLowerInvariant()) {
|
switch (name.ToLowerInvariant())
|
||||||
case "pi": args.Result= Math.PI;
|
{
|
||||||
|
case "pi":
|
||||||
|
args.Result = Math.PI;
|
||||||
break;
|
break;
|
||||||
case "e": args.Result = Math.E;
|
case "e":
|
||||||
|
args.Result = Math.E;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
|
||||||
public async Task CalcOps()
|
public async Task CalcOps()
|
||||||
{
|
{
|
||||||
var selection = typeof(Math).GetTypeInfo().GetMethods().Except(typeof(object).GetTypeInfo().GetMethods()).Distinct(new MethodInfoEqualityComparer()).Select(x =>
|
var selection = typeof(Math).GetTypeInfo().GetMethods().Except(typeof(object).GetTypeInfo().GetMethods()).Distinct(new MethodInfoEqualityComparer()).Select(x =>
|
||||||
@ -63,3 +67,4 @@ namespace NadekoBot.Modules.Utility
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
@ -10,6 +10,9 @@ using System.Threading.Tasks;
|
|||||||
namespace NadekoBot.Modules.Utility
|
namespace NadekoBot.Modules.Utility
|
||||||
{
|
{
|
||||||
public partial class Utility
|
public partial class Utility
|
||||||
|
{
|
||||||
|
[Group]
|
||||||
|
public class InfoCommands : ModuleBase
|
||||||
{
|
{
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
@ -82,7 +85,8 @@ namespace NadekoBot.Modules.Utility
|
|||||||
|
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
.AddField(fb => fb.WithName("**Name**").WithValue($"**{user.Username}**#{user.Discriminator}").WithIsInline(true));
|
.AddField(fb => fb.WithName("**Name**").WithValue($"**{user.Username}**#{user.Discriminator}").WithIsInline(true));
|
||||||
if (!string.IsNullOrWhiteSpace(user.Nickname)) {
|
if (!string.IsNullOrWhiteSpace(user.Nickname))
|
||||||
|
{
|
||||||
embed.AddField(fb => fb.WithName("**Nickname**").WithValue(user.Nickname).WithIsInline(true));
|
embed.AddField(fb => fb.WithName("**Nickname**").WithValue(user.Nickname).WithIsInline(true));
|
||||||
}
|
}
|
||||||
embed.AddField(fb => fb.WithName("**ID**").WithValue(user.Id.ToString()).WithIsInline(true))
|
embed.AddField(fb => fb.WithName("**ID**").WithValue(user.Id.ToString()).WithIsInline(true))
|
||||||
@ -96,3 +100,4 @@ namespace NadekoBot.Modules.Utility
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
@ -12,6 +12,9 @@ using System.Threading.Tasks;
|
|||||||
namespace NadekoBot.Modules.Utility
|
namespace NadekoBot.Modules.Utility
|
||||||
{
|
{
|
||||||
public partial class Utility
|
public partial class Utility
|
||||||
|
{
|
||||||
|
[Group]
|
||||||
|
public class QuoteCommands : ModuleBase
|
||||||
{
|
{
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
@ -133,3 +136,4 @@ namespace NadekoBot.Modules.Utility
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
@ -22,7 +22,6 @@ namespace NadekoBot.Modules.Utility
|
|||||||
[Group]
|
[Group]
|
||||||
public class UnitConverterCommands : ModuleBase
|
public class UnitConverterCommands : ModuleBase
|
||||||
{
|
{
|
||||||
|
|
||||||
public static List<ConvertUnit> Units { get; set; } = new List<ConvertUnit>();
|
public static List<ConvertUnit> Units { get; set; } = new List<ConvertUnit>();
|
||||||
private static Logger _log { get; }
|
private static Logger _log { get; }
|
||||||
private static Timer _timer;
|
private static Timer _timer;
|
||||||
@ -64,7 +63,8 @@ namespace NadekoBot.Modules.Utility
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateCurrency()
|
public async Task UpdateCurrency()
|
||||||
{try
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var currencyRates = await UpdateCurrencyRates();
|
var currencyRates = await UpdateCurrencyRates();
|
||||||
var unitTypeString = "currency";
|
var unitTypeString = "currency";
|
||||||
@ -95,12 +95,13 @@ namespace NadekoBot.Modules.Utility
|
|||||||
Units.AddRange(range);
|
Units.AddRange(range);
|
||||||
_log.Info("Updated Currency");
|
_log.Info("Updated Currency");
|
||||||
}
|
}
|
||||||
catch {
|
catch
|
||||||
|
{
|
||||||
_log.Warn("Failed updating currency.");
|
_log.Warn("Failed updating currency.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
|
||||||
public async Task ConvertList()
|
public async Task ConvertList()
|
||||||
{
|
{
|
||||||
var res = Units.GroupBy(x => x.UnitType)
|
var res = Units.GroupBy(x => x.UnitType)
|
||||||
|
@ -211,7 +211,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
|
|
||||||
await channel.EmbedAsync(guilds.Aggregate(new EmbedBuilder().WithColor(NadekoBot.OkColor),
|
await channel.EmbedAsync(guilds.Aggregate(new EmbedBuilder().WithColor(NadekoBot.OkColor),
|
||||||
(embed, g) => embed.AddField(efb => efb.WithName(g.Name)
|
(embed, g) => embed.AddField(efb => efb.WithName(g.Name)
|
||||||
.WithValue($"```css\nID: {g.Id}\nMembers: {(g.GetUsersAsync().GetAwaiter().GetResult()).Count}\nOwnerID: {g.OwnerId} ```")
|
.WithValue($"```css\nID: {g.Id}\nMembers: {g.Users.Count}\nOwnerID: {g.OwnerId} ```")
|
||||||
.WithIsInline(false))))
|
.WithIsInline(false))))
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user