2017-05-27 23:51:22 +00:00
using Discord.Commands ;
2017-01-14 16:37:11 +00:00
using System.Collections.Concurrent ;
using System.Collections.Generic ;
namespace NadekoBot.Modules.Permissions
{
public partial class Permissions
{
[Group]
2017-02-24 09:53:42 +00:00
public class CommandCostCommands : NadekoSubmodule
2017-01-14 16:37:11 +00:00
{
private static readonly ConcurrentDictionary < string , int > _commandCosts = new ConcurrentDictionary < string , int > ( ) ;
public static IReadOnlyDictionary < string , int > CommandCosts = > _commandCosts ;
static CommandCostCommands ( )
{
//_commandCosts = new ConcurrentDictionary<string, int>(NadekoBot.BotConfig.CommandCosts.ToDictionary(
// x => x.CommandName.Trim().ToUpperInvariant(),
// x => x.Cost));
}
2017-02-24 09:53:42 +00:00
//[NadekoCommand, Usage, Description, Aliases]
//public async Task CmdCosts(int page = 1)
//{
// var prices = _commandCosts.ToList();
2017-01-14 16:37:11 +00:00
2017-02-24 09:53:42 +00:00
// if (!prices.Any())
// {
// await Context.Channel.SendConfirmAsync(GetText("no_costs")).ConfigureAwait(false);
// return;
// }
2017-01-14 16:37:11 +00:00
2017-02-24 09:53:42 +00:00
// await Context.Channel.SendPaginatedConfirmAsync(page, (curPage) => {
// var embed = new EmbedBuilder().WithOkColor()
// .WithTitle(GetText("command_costs"));
// var current = prices.Skip((curPage - 1) * 9)
// .Take(9);
// foreach (var price in current)
// {
// embed.AddField(efb => efb.WithName(price.Key).WithValue(price.Value.ToString()).WithIsInline(true));
// }
// return embed;
// }, prices.Count / 9).ConfigureAwait(false);
//}
2017-01-14 16:37:11 +00:00
//[NadekoCommand, Usage, Description, Aliases]
//public async Task CommandCost(int cost, CommandInfo cmd)
//{
// if (cost < 0)
// return;
// var cmdName = cmd.Aliases.First().ToLowerInvariant();
// var cmdPrice = new CommandCost()
// {
// CommandName = cmdName,
// Cost = cost
// };
2017-05-27 23:51:22 +00:00
// using (var uow = _db.UnitOfWork)
2017-01-14 16:37:11 +00:00
// {
// var bc = uow.BotConfig.GetOrCreate();
// if (cost != 0)
// {
// var elem = bc.CommandCosts.Where(cc => cc.CommandName == cmdPrice.CommandName).FirstOrDefault();
// if (elem == null)
// bc.CommandCosts.Add(cmdPrice);
// else
// elem.Cost = cost;
// _commandCosts.AddOrUpdate(cmdName, cost, (key, old) => cost);
// }
// else
// {
// bc.CommandCosts.RemoveAt(bc.CommandCosts.IndexOf(cmdPrice));
2017-07-25 16:31:30 +00:00
// _commandCosts.TryRemove(cmdName, out _);
2017-01-14 16:37:11 +00:00
// }
// await uow.CompleteAsync().ConfigureAwait(false);
// }
// if (cost == 0)
// await Context.Channel.SendConfirmAsync($"Removed the cost from the {Format.Bold(cmd.Name)} command.").ConfigureAwait(false);
// else
// await Context.Channel.SendConfirmAsync($"{Format.Bold(cmd.Name)} now costs {cost}{NadekoBot.BotConfig.CurrencySign} to run.").ConfigureAwait(false);
//}
}
}
}