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 =>
|
||||||
@ -46,7 +50,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
"Equals",
|
"Equals",
|
||||||
"GetHashCode",
|
"GetHashCode",
|
||||||
"GetType"});
|
"GetType"});
|
||||||
await Context.Channel.SendConfirmAsync(string.Join(", ",selection));
|
await Context.Channel.SendConfirmAsync(string.Join(", ", selection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,4 +66,5 @@ namespace NadekoBot.Modules.Utility
|
|||||||
public double Pi { get; set; } = Math.PI;
|
public double Pi { get; set; } = Math.PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
@ -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))
|
||||||
@ -95,4 +99,5 @@ namespace NadekoBot.Modules.Utility
|
|||||||
await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -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)]
|
||||||
@ -95,7 +98,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
{
|
{
|
||||||
var qs = uow.Quotes.GetAllQuotesByKeyword(Context.Guild.Id, keyword);
|
var qs = uow.Quotes.GetAllQuotesByKeyword(Context.Guild.Id, keyword);
|
||||||
|
|
||||||
if (qs==null || !qs.Any())
|
if (qs == null || !qs.Any())
|
||||||
{
|
{
|
||||||
await Context.Channel.SendErrorAsync("No quotes found.").ConfigureAwait(false);
|
await Context.Channel.SendErrorAsync("No quotes found.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
@ -132,4 +135,5 @@ namespace NadekoBot.Modules.Utility
|
|||||||
await Context.Channel.SendConfirmAsync($"🗑 **Deleted all quotes** with **{keyword}** keyword.");
|
await Context.Channel.SendConfirmAsync($"🗑 **Deleted all quotes** with **{keyword}** keyword.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -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…
Reference in New Issue
Block a user