Work on gambling, lolban
This commit is contained in:
parent
acebc6e914
commit
c446b889c7
@ -1,4 +1,6 @@
|
|||||||
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
|
using NadekoBot.Attributes;
|
||||||
using NadekoBot.Classes;
|
using NadekoBot.Classes;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using System;
|
using System;
|
||||||
@ -9,154 +11,142 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace NadekoBot.Modules.Gambling
|
namespace NadekoBot.Modules.Gambling
|
||||||
{
|
{
|
||||||
public partial class DiceRollCommands
|
public partial class Gambling
|
||||||
{
|
{
|
||||||
|
private Regex dndRegex { get; } = new Regex(@"(?<n1>\d+)d(?<n2>\d+)", RegexOptions.Compiled);
|
||||||
|
////todo drawing
|
||||||
|
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
|
//[RequireContext(ContextType.Guild)]
|
||||||
|
//public Task Roll(IMessage imsg, [Remainder] string arg = null) =>
|
||||||
|
// InternalRoll(imsg, arg, true);
|
||||||
|
|
||||||
public DiceRollCommand(DiscordModule module) : base(module) { }
|
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
|
//[RequireContext(ContextType.Guild)]
|
||||||
|
//public Task Rolluo(IMessage imsg, [Remainder] string arg = null) =>
|
||||||
|
// InternalRoll(imsg, arg, false);
|
||||||
|
|
||||||
|
//private async Task InternalRoll(IMessage imsg, string arg, bool ordered) {
|
||||||
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
|
// var r = new Random();
|
||||||
|
// if (string.IsNullOrWhiteSpace(arg))
|
||||||
|
// {
|
||||||
|
// var gen = r.Next(0, 101);
|
||||||
|
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
// var num1 = gen / 10;
|
||||||
|
// var num2 = gen % 10;
|
||||||
|
|
||||||
|
// var imageStream = await new Image[2] { GetDice(num1), GetDice(num2) }.Merge().ToStream(ImageFormat.Png);
|
||||||
|
|
||||||
|
// await channel.SendFileAsync(imageStream, "dice.png").ConfigureAwait(false);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// Match m;
|
||||||
|
// if ((m = dndRegex.Match(arg)).Length != 0)
|
||||||
|
// {
|
||||||
|
// int n1;
|
||||||
|
// int n2;
|
||||||
|
// if (int.TryParse(m.Groups["n1"].ToString(), out n1) &&
|
||||||
|
// int.TryParse(m.Groups["n2"].ToString(), out n2) &&
|
||||||
|
// n1 <= 50 && n2 <= 100000 && n1 > 0 && n2 > 0)
|
||||||
|
// {
|
||||||
|
// var arr = new int[n1];
|
||||||
|
// for (int i = 0; i < n1; i++)
|
||||||
|
// {
|
||||||
|
// arr[i] = r.Next(1, n2 + 1);
|
||||||
|
// }
|
||||||
|
// var elemCnt = 0;
|
||||||
|
// await channel.SendMessageAsync($"`Rolled {n1} {(n1 == 1 ? "die" : "dice")} 1-{n2}.`\n`Result:` " + string.Join(", ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false);
|
||||||
|
// }
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// var num = int.Parse(e.Args[0]);
|
||||||
|
// if (num < 1) num = 1;
|
||||||
|
// if (num > 30)
|
||||||
|
// {
|
||||||
|
// await channel.SendMessageAsync("You can roll up to 30 dice at a time.").ConfigureAwait(false);
|
||||||
|
// num = 30;
|
||||||
|
// }
|
||||||
|
// var dices = new List<Image>(num);
|
||||||
|
// var values = new List<int>(num);
|
||||||
|
// for (var i = 0; i < num; i++)
|
||||||
|
// {
|
||||||
|
// var randomNumber = r.Next(1, 7);
|
||||||
|
// var toInsert = dices.Count;
|
||||||
|
// if (ordered)
|
||||||
|
// {
|
||||||
|
// if (randomNumber == 6 || dices.Count == 0)
|
||||||
|
// toInsert = 0;
|
||||||
|
// else if (randomNumber != 1)
|
||||||
|
// for (var j = 0; j < dices.Count; j++)
|
||||||
|
// {
|
||||||
|
// if (values[j] < randomNumber)
|
||||||
|
// {
|
||||||
|
// toInsert = j;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// toInsert = dices.Count;
|
||||||
|
// }
|
||||||
|
// dices.Insert(toInsert, GetDice(randomNumber));
|
||||||
|
// values.Insert(toInsert, randomNumber);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// var bitmap = dices.Merge();
|
||||||
|
// await channel.SendMessageAsync(values.Count + " Dice rolled. Total: **" + values.Sum() + "** Average: **" + (values.Sum() / (1.0f * values.Count)).ToString("N2") + "**").ConfigureAwait(false);
|
||||||
|
// await channel.SendFileAsync("dice.png", bitmap.ToStream(ImageFormat.Png)).ConfigureAwait(false);
|
||||||
|
// }
|
||||||
|
// catch
|
||||||
|
// {
|
||||||
|
// await channel.SendMessageAsync("Please enter a number of dice to roll.").ConfigureAwait(false);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
|
[RequireContext(ContextType.Guild)]
|
||||||
|
public async Task NRoll(IMessage imsg, [Remainder] string range)
|
||||||
{
|
{
|
||||||
cgb.CreateCommand(Module.Prefix + "roll")
|
var channel = imsg.Channel as ITextChannel;
|
||||||
.Description("Rolls 0-100. If you supply a number [x] it rolls up to 30 normal dice." +
|
|
||||||
$" If you split 2 numbers with letter d (xdy) it will roll x dice from 1 to y. | `{Prefix}roll` or `{Prefix}roll 7` or `{Prefix}roll 3d5`")
|
|
||||||
.Parameter("num", ParameterType.Optional)
|
|
||||||
.Do(RollFunc());
|
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "rolluo")
|
|
||||||
.Description("Rolls 0-100. If you supply a number [x] it rolls up to 30 normal dice (unordered)." +
|
|
||||||
$" If you split 2 numbers with letter d (xdy) it will roll x dice from 1 to y. | `{Prefix}roll` or `{Prefix}roll` 7 or `{Prefix}roll 3d5`")
|
|
||||||
.Parameter("num", ParameterType.Optional)
|
|
||||||
.Do(RollFunc(false));
|
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "nroll")
|
|
||||||
.Description($"Rolls in a given range. | `{Prefix}nroll 5` (rolls 0-5) or `{Prefix}nroll 5-15`")
|
|
||||||
.Parameter("range", ParameterType.Required)
|
|
||||||
.Do(NRollFunc());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Image GetDice(int num) => num != 10
|
|
||||||
? Properties.Resources.ResourceManager.GetObject("_" + num) as Image
|
|
||||||
: new[]
|
|
||||||
{
|
|
||||||
(Properties.Resources.ResourceManager.GetObject("_" + 1) as Image),
|
|
||||||
(Properties.Resources.ResourceManager.GetObject("_" + 0) as Image),
|
|
||||||
}.Merge();
|
|
||||||
|
|
||||||
|
|
||||||
Regex dndRegex = new Regex(@"(?<n1>\d+)d(?<n2>\d+)", RegexOptions.Compiled);
|
try
|
||||||
private Func<CommandEventArgs, Task> RollFunc(bool ordered = true)
|
|
||||||
{
|
|
||||||
var r = new Random();
|
|
||||||
return async e =>
|
|
||||||
{
|
{
|
||||||
var arg = e.Args[0]?.Trim();
|
int rolled;
|
||||||
if (string.IsNullOrWhiteSpace(arg))
|
if (range.Contains("-"))
|
||||||
{
|
{
|
||||||
var gen = r.Next(0, 101);
|
var arr = range.Split('-')
|
||||||
|
.Take(2)
|
||||||
var num1 = gen / 10;
|
.Select(int.Parse)
|
||||||
var num2 = gen % 10;
|
.ToArray();
|
||||||
|
if (arr[0] > arr[1])
|
||||||
var imageStream = new Image[2] { GetDice(num1), GetDice(num2) }.Merge().ToStream(ImageFormat.Png);
|
throw new ArgumentException("First argument should be bigger than the second one.");
|
||||||
|
rolled = new Random().Next(arr[0], arr[1] + 1);
|
||||||
await e.Channel.SendFile("dice.png", imageStream).ConfigureAwait(false);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Match m;
|
else
|
||||||
if ((m = dndRegex.Match(arg)).Length != 0)
|
|
||||||
{
|
{
|
||||||
int n1;
|
rolled = new Random().Next(0, int.Parse(range) + 1);
|
||||||
int n2;
|
|
||||||
if (int.TryParse(m.Groups["n1"].ToString(), out n1) &&
|
|
||||||
int.TryParse(m.Groups["n2"].ToString(), out n2) &&
|
|
||||||
n1 <= 50 && n2 <= 100000 && n1 > 0 && n2 > 0)
|
|
||||||
{
|
|
||||||
var arr = new int[n1];
|
|
||||||
for (int i = 0; i < n1; i++)
|
|
||||||
{
|
|
||||||
arr[i] = r.Next(1, n2 + 1);
|
|
||||||
}
|
|
||||||
var elemCnt = 0;
|
|
||||||
await channel.SendMessageAsync($"`Rolled {n1} {(n1 == 1 ? "die" : "dice")} 1-{n2}.`\n`Result:` " + string.Join(", ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => elemCnt++ % 2 == 0 ? $"**{x}**" : x.ToString()))).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
try
|
|
||||||
{
|
|
||||||
var num = int.Parse(e.Args[0]);
|
|
||||||
if (num < 1) num = 1;
|
|
||||||
if (num > 30)
|
|
||||||
{
|
|
||||||
await channel.SendMessageAsync("You can roll up to 30 dice at a time.").ConfigureAwait(false);
|
|
||||||
num = 30;
|
|
||||||
}
|
|
||||||
var dices = new List<Image>(num);
|
|
||||||
var values = new List<int>(num);
|
|
||||||
for (var i = 0; i < num; i++)
|
|
||||||
{
|
|
||||||
var randomNumber = r.Next(1, 7);
|
|
||||||
var toInsert = dices.Count;
|
|
||||||
if (ordered)
|
|
||||||
{
|
|
||||||
if (randomNumber == 6 || dices.Count == 0)
|
|
||||||
toInsert = 0;
|
|
||||||
else if (randomNumber != 1)
|
|
||||||
for (var j = 0; j < dices.Count; j++)
|
|
||||||
{
|
|
||||||
if (values[j] < randomNumber)
|
|
||||||
{
|
|
||||||
toInsert = j;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
toInsert = dices.Count;
|
|
||||||
}
|
|
||||||
dices.Insert(toInsert, GetDice(randomNumber));
|
|
||||||
values.Insert(toInsert, randomNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
var bitmap = dices.Merge();
|
await channel.SendMessageAsync($"{imsg.Author.Mention} rolled **{rolled}**.").ConfigureAwait(false);
|
||||||
await channel.SendMessageAsync(values.Count + " Dice rolled. Total: **" + values.Sum() + "** Average: **" + (values.Sum() / (1.0f * values.Count)).ToString("N2") + "**").ConfigureAwait(false);
|
}
|
||||||
await e.Channel.SendFile("dice.png", bitmap.ToStream(ImageFormat.Png)).ConfigureAwait(false);
|
catch (Exception ex)
|
||||||
}
|
{
|
||||||
catch
|
await channel.SendMessageAsync($":anger: {ex.Message}").ConfigureAwait(false);
|
||||||
{
|
}
|
||||||
await channel.SendMessageAsync("Please enter a number of dice to roll.").ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Func<CommandEventArgs, Task> NRollFunc() =>
|
////todo drawing
|
||||||
async e =>
|
//private Image GetDice(int num) => num != 10
|
||||||
{
|
// ? Properties.Resources.ResourceManager.GetObject("_" + num) as Image
|
||||||
try
|
// : new[]
|
||||||
{
|
// {
|
||||||
int rolled;
|
// (Properties.Resources.ResourceManager.GetObject("_" + 1) as Image),
|
||||||
if (e.GetArg("range").Contains("-"))
|
// (Properties.Resources.ResourceManager.GetObject("_" + 0) as Image),
|
||||||
{
|
// }.Merge();
|
||||||
var arr = e.GetArg("range").Split('-')
|
|
||||||
.Take(2)
|
|
||||||
.Select(int.Parse)
|
|
||||||
.ToArray();
|
|
||||||
if (arr[0] > arr[1])
|
|
||||||
throw new ArgumentException("First argument should be bigger than the second one.");
|
|
||||||
rolled = new Random().Next(arr[0], arr[1] + 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rolled = new Random().Next(0, int.Parse(e.GetArg("range")) + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
await channel.SendMessageAsync($"{imsg.Author.Mention} rolled **{rolled}**.").ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await channel.SendMessageAsync($":anger: {ex.Message}").ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,91 +1,92 @@
|
|||||||
using Discord.Commands;
|
//using Discord.Commands;
|
||||||
using NadekoBot.Classes;
|
//using NadekoBot.Classes;
|
||||||
using NadekoBot.Extensions;
|
//using NadekoBot.Extensions;
|
||||||
using NadekoBot.Modules.Gambling.Helpers;
|
//using NadekoBot.Modules.Gambling.Helpers;
|
||||||
using System;
|
//using System;
|
||||||
using System.Collections.Concurrent;
|
//using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using System.Drawing;
|
//using System.Drawing;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Gambling
|
////todo drawing
|
||||||
{
|
//namespace NadekoBot.Modules.Gambling
|
||||||
internal class DrawCommand : DiscordCommand
|
//{
|
||||||
{
|
// internal class DrawCommand : DiscordCommand
|
||||||
public DrawCommand(DiscordModule module) : base(module) { }
|
// {
|
||||||
|
// public DrawCommand(DiscordModule module) : base(module) { }
|
||||||
|
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
// internal override void Init(CommandGroupBuilder cgb)
|
||||||
{
|
// {
|
||||||
cgb.CreateCommand(Module.Prefix + "draw")
|
// cgb.CreateCommand(Module.Prefix + "draw")
|
||||||
.Description($"Draws a card from the deck.If you supply number [x], she draws up to 5 cards from the deck. | `{Prefix}draw [x]`")
|
// .Description($"Draws a card from the deck.If you supply number [x], she draws up to 5 cards from the deck. | `{Prefix}draw [x]`")
|
||||||
.Parameter("count", ParameterType.Optional)
|
// .Parameter("count", ParameterType.Optional)
|
||||||
.Do(DrawCardFunc());
|
// .Do(DrawCardFunc());
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "shuffle")
|
// cgb.CreateCommand(Module.Prefix + "shuffle")
|
||||||
.Alias(Module.Prefix + "sh")
|
// .Alias(Module.Prefix + "sh")
|
||||||
.Description($"Reshuffles all cards back into the deck.|`{Prefix}shuffle`")
|
// .Description($"Reshuffles all cards back into the deck.|`{Prefix}shuffle`")
|
||||||
.Do(ReshuffleTask());
|
// .Do(ReshuffleTask());
|
||||||
}
|
// }
|
||||||
|
|
||||||
private static readonly ConcurrentDictionary<Discord.Server, Cards> AllDecks = new ConcurrentDictionary<Discord.Server, Cards>();
|
// private static readonly ConcurrentDictionary<Discord.Server, Cards> AllDecks = new ConcurrentDictionary<Discord.Server, Cards>();
|
||||||
|
|
||||||
private static Func<CommandEventArgs, Task> ReshuffleTask()
|
// private static Func<CommandEventArgs, Task> ReshuffleTask()
|
||||||
{
|
// {
|
||||||
return async e =>
|
// return async e =>
|
||||||
{
|
// {
|
||||||
AllDecks.AddOrUpdate(e.Server,
|
// AllDecks.AddOrUpdate(e.Server,
|
||||||
(s) => new Cards(),
|
// (s) => new Cards(),
|
||||||
(s, c) =>
|
// (s, c) =>
|
||||||
{
|
// {
|
||||||
c.Restart();
|
// c.Restart();
|
||||||
return c;
|
// return c;
|
||||||
});
|
// });
|
||||||
|
|
||||||
await channel.SendMessageAsync("Deck reshuffled.").ConfigureAwait(false);
|
// await channel.SendMessageAsync("Deck reshuffled.").ConfigureAwait(false);
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
|
|
||||||
private Func<CommandEventArgs, Task> DrawCardFunc() => async (e) =>
|
// private Func<CommandEventArgs, Task> DrawCardFunc() => async (e) =>
|
||||||
{
|
// {
|
||||||
var cards = AllDecks.GetOrAdd(e.Server, (s) => new Cards());
|
// var cards = AllDecks.GetOrAdd(e.Server, (s) => new Cards());
|
||||||
|
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var num = 1;
|
// var num = 1;
|
||||||
var isParsed = int.TryParse(e.GetArg("count"), out num);
|
// var isParsed = int.TryParse(e.GetArg("count"), out num);
|
||||||
if (!isParsed || num < 2)
|
// if (!isParsed || num < 2)
|
||||||
{
|
// {
|
||||||
var c = cards.DrawACard();
|
// var c = cards.DrawACard();
|
||||||
await e.Channel.SendFile(c.Name + ".jpg", (Properties.Resources.ResourceManager.GetObject(c.Name) as Image).ToStream()).ConfigureAwait(false);
|
// await e.Channel.SendFile(c.Name + ".jpg", (Properties.Resources.ResourceManager.GetObject(c.Name) as Image).ToStream()).ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (num > 5)
|
// if (num > 5)
|
||||||
num = 5;
|
// num = 5;
|
||||||
|
|
||||||
var images = new List<Image>();
|
// var images = new List<Image>();
|
||||||
var cardObjects = new List<Cards.Card>();
|
// var cardObjects = new List<Cards.Card>();
|
||||||
for (var i = 0; i < num; i++)
|
// for (var i = 0; i < num; i++)
|
||||||
{
|
// {
|
||||||
if (cards.CardPool.Count == 0 && i != 0)
|
// if (cards.CardPool.Count == 0 && i != 0)
|
||||||
{
|
// {
|
||||||
await channel.SendMessageAsync("No more cards in a deck.").ConfigureAwait(false);
|
// await channel.SendMessageAsync("No more cards in a deck.").ConfigureAwait(false);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
var currentCard = cards.DrawACard();
|
// var currentCard = cards.DrawACard();
|
||||||
cardObjects.Add(currentCard);
|
// cardObjects.Add(currentCard);
|
||||||
images.Add(Properties.Resources.ResourceManager.GetObject(currentCard.Name) as Image);
|
// images.Add(Properties.Resources.ResourceManager.GetObject(currentCard.Name) as Image);
|
||||||
}
|
// }
|
||||||
var bitmap = images.Merge();
|
// var bitmap = images.Merge();
|
||||||
await e.Channel.SendFile(images.Count + " cards.jpg", bitmap.ToStream()).ConfigureAwait(false);
|
// await e.Channel.SendFile(images.Count + " cards.jpg", bitmap.ToStream()).ConfigureAwait(false);
|
||||||
if (cardObjects.Count == 5)
|
// if (cardObjects.Count == 5)
|
||||||
{
|
// {
|
||||||
await channel.SendMessageAsync($"{imsg.Author.Mention} `{Cards.GetHandValue(cardObjects)}`").ConfigureAwait(false);
|
// await channel.SendMessageAsync($"{imsg.Author.Mention} `{Cards.GetHandValue(cardObjects)}`").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
Console.WriteLine("Error drawing (a) card(s) " + ex.ToString());
|
// Console.WriteLine("Error drawing (a) card(s) " + ex.ToString());
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
@ -1,112 +1,113 @@
|
|||||||
using Discord.Commands;
|
//using Discord.Commands;
|
||||||
using NadekoBot.Classes;
|
//using NadekoBot.Classes;
|
||||||
using NadekoBot.Extensions;
|
//using NadekoBot.Extensions;
|
||||||
using System;
|
//using System;
|
||||||
using System.Drawing;
|
//using System.Drawing;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Gambling
|
////todo drawing
|
||||||
{
|
//namespace NadekoBot.Modules.Gambling
|
||||||
internal class FlipCoinCommand : DiscordCommand
|
//{
|
||||||
{
|
// internal class FlipCoinCommand : DiscordCommand
|
||||||
|
// {
|
||||||
|
|
||||||
public FlipCoinCommand(DiscordModule module) : base(module) { }
|
// public FlipCoinCommand(DiscordModule module) : base(module) { }
|
||||||
|
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
// internal override void Init(CommandGroupBuilder cgb)
|
||||||
{
|
// {
|
||||||
cgb.CreateCommand(Module.Prefix + "flip")
|
// cgb.CreateCommand(Module.Prefix + "flip")
|
||||||
.Description($"Flips coin(s) - heads or tails, and shows an image. | `{Prefix}flip` or `{Prefix}flip 3`")
|
// .Description($"Flips coin(s) - heads or tails, and shows an image. | `{Prefix}flip` or `{Prefix}flip 3`")
|
||||||
.Parameter("count", ParameterType.Optional)
|
// .Parameter("count", ParameterType.Optional)
|
||||||
.Do(FlipCoinFunc());
|
// .Do(FlipCoinFunc());
|
||||||
|
|
||||||
cgb.CreateCommand(Module.Prefix + "betflip")
|
// cgb.CreateCommand(Module.Prefix + "betflip")
|
||||||
.Alias(Prefix+"bf")
|
// .Alias(Prefix+"bf")
|
||||||
.Description($"Bet to guess will the result be heads or tails. Guessing award you double flowers you've bet. | `{Prefix}bf 5 heads` or `{Prefix}bf 3 t`")
|
// .Description($"Bet to guess will the result be heads or tails. Guessing award you double flowers you've bet. | `{Prefix}bf 5 heads` or `{Prefix}bf 3 t`")
|
||||||
.Parameter("amount", ParameterType.Required)
|
// .Parameter("amount", ParameterType.Required)
|
||||||
.Parameter("guess", ParameterType.Required)
|
// .Parameter("guess", ParameterType.Required)
|
||||||
.Do(BetFlipCoinFunc());
|
// .Do(BetFlipCoinFunc());
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private readonly Random rng = new Random();
|
// private readonly Random rng = new Random();
|
||||||
public Func<CommandEventArgs, Task> BetFlipCoinFunc() => async e =>
|
// public Func<CommandEventArgs, Task> BetFlipCoinFunc() => async e =>
|
||||||
{
|
// {
|
||||||
|
|
||||||
var amountstr = e.GetArg("amount").Trim();
|
// var amountstr = e.GetArg("amount").Trim();
|
||||||
|
|
||||||
var guessStr = e.GetArg("guess").Trim().ToUpperInvariant();
|
// var guessStr = e.GetArg("guess").Trim().ToUpperInvariant();
|
||||||
if (guessStr != "H" && guessStr != "T" && guessStr != "HEADS" && guessStr != "TAILS")
|
// if (guessStr != "H" && guessStr != "T" && guessStr != "HEADS" && guessStr != "TAILS")
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
int amount;
|
// int amount;
|
||||||
if (!int.TryParse(amountstr, out amount) || amount < 1)
|
// if (!int.TryParse(amountstr, out amount) || amount < 1)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
var userFlowers = GamblingModule.GetUserFlowers(e.User.Id);
|
// var userFlowers = Gambling.GetUserFlowers(imsg.Author.Id);
|
||||||
|
|
||||||
if (userFlowers < amount)
|
// if (userFlowers < amount)
|
||||||
{
|
// {
|
||||||
await imsg.Channel.SendMessageAsync($"{e.User.Mention} You don't have enough {NadekoBot.Config.CurrencyName}s. You only have {userFlowers}{NadekoBot.Config.CurrencySign}.").ConfigureAwait(false);
|
// await channel.SendMessageAsync($"{imsg.Author.Mention} You don't have enough {NadekoBot.Config.CurrencyName}s. You only have {userFlowers}{NadekoBot.Config.CurrencySign}.").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
await FlowersHandler.RemoveFlowers(e.User, "Betflip Gamble", (int)amount, true).ConfigureAwait(false);
|
// await FlowersHandler.RemoveFlowers(imsg.Author, "Betflip Gamble", (int)amount, true).ConfigureAwait(false);
|
||||||
//heads = true
|
// //heads = true
|
||||||
//tails = false
|
// //tails = false
|
||||||
|
|
||||||
var guess = guessStr == "HEADS" || guessStr == "H";
|
// var guess = guessStr == "HEADS" || guessStr == "H";
|
||||||
bool result = false;
|
// bool result = false;
|
||||||
if (rng.Next(0, 2) == 1) {
|
// if (rng.Next(0, 2) == 1) {
|
||||||
await e.Channel.SendFile("heads.png", Properties.Resources.heads.ToStream(System.Drawing.Imaging.ImageFormat.Png)).ConfigureAwait(false);
|
// await e.Channel.SendFile("heads.png", Properties.Resources.heads.ToStream(System.Drawing.Imaging.ImageFormat.Png)).ConfigureAwait(false);
|
||||||
result = true;
|
// result = true;
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
await e.Channel.SendFile("tails.png", Properties.Resources.tails.ToStream(System.Drawing.Imaging.ImageFormat.Png)).ConfigureAwait(false);
|
// await e.Channel.SendFile("tails.png", Properties.Resources.tails.ToStream(System.Drawing.Imaging.ImageFormat.Png)).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
|
|
||||||
string str;
|
// string str;
|
||||||
if (guess == result)
|
// if (guess == result)
|
||||||
{
|
// {
|
||||||
str = $"{e.User.Mention}`You guessed it!` You won {amount * 2}{NadekoBot.Config.CurrencySign}";
|
// str = $"{imsg.Author.Mention}`You guessed it!` You won {amount * 2}{NadekoBot.Config.CurrencySign}";
|
||||||
await FlowersHandler.AddFlowersAsync(e.User, "Betflip Gamble", amount * 2, true).ConfigureAwait(false);
|
// await FlowersHandler.AddFlowersAsync(imsg.Author, "Betflip Gamble", amount * 2, true).ConfigureAwait(false);
|
||||||
|
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
str = $"{e.User.Mention}`More luck next time.`";
|
// str = $"{imsg.Author.Mention}`More luck next time.`";
|
||||||
|
|
||||||
await imsg.Channel.SendMessageAsync(str).ConfigureAwait(false);
|
// await channel.SendMessageAsync(str).ConfigureAwait(false);
|
||||||
};
|
// };
|
||||||
|
|
||||||
public Func<CommandEventArgs, Task> FlipCoinFunc() => async e =>
|
// public Func<CommandEventArgs, Task> FlipCoinFunc() => async e =>
|
||||||
{
|
// {
|
||||||
|
|
||||||
if (e.GetArg("count") == "")
|
// if (e.GetArg("count") == "")
|
||||||
{
|
// {
|
||||||
if (rng.Next(0, 2) == 1)
|
// if (rng.Next(0, 2) == 1)
|
||||||
await e.Channel.SendFile("heads.png", Properties.Resources.heads.ToStream(System.Drawing.Imaging.ImageFormat.Png)).ConfigureAwait(false);
|
// await e.Channel.SendFile("heads.png", Properties.Resources.heads.ToStream(System.Drawing.Imaging.ImageFormat.Png)).ConfigureAwait(false);
|
||||||
else
|
// else
|
||||||
await e.Channel.SendFile("tails.png", Properties.Resources.tails.ToStream(System.Drawing.Imaging.ImageFormat.Png)).ConfigureAwait(false);
|
// await e.Channel.SendFile("tails.png", Properties.Resources.tails.ToStream(System.Drawing.Imaging.ImageFormat.Png)).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
int result;
|
// int result;
|
||||||
if (int.TryParse(e.GetArg("count"), out result))
|
// if (int.TryParse(e.GetArg("count"), out result))
|
||||||
{
|
// {
|
||||||
if (result > 10)
|
// if (result > 10)
|
||||||
result = 10;
|
// result = 10;
|
||||||
var imgs = new Image[result];
|
// var imgs = new Image[result];
|
||||||
for (var i = 0; i < result; i++)
|
// for (var i = 0; i < result; i++)
|
||||||
{
|
// {
|
||||||
imgs[i] = rng.Next(0, 2) == 0 ?
|
// imgs[i] = rng.Next(0, 2) == 0 ?
|
||||||
Properties.Resources.tails :
|
// Properties.Resources.tails :
|
||||||
Properties.Resources.heads;
|
// Properties.Resources.heads;
|
||||||
}
|
// }
|
||||||
await e.Channel.SendFile($"{result} coins.png", imgs.Merge().ToStream(System.Drawing.Imaging.ImageFormat.Png)).ConfigureAwait(false);
|
// await e.Channel.SendFile($"{result} coins.png", imgs.Merge().ToStream(System.Drawing.Imaging.ImageFormat.Png)).ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
await imsg.Channel.SendMessageAsync("Invalid number").ConfigureAwait(false);
|
// await channel.SendMessageAsync("Invalid number").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Gambling.Helpers
|
namespace NadekoBot.Modules.Gambling.Commands.Models
|
||||||
{
|
{
|
||||||
public class Cards
|
public class Cards
|
||||||
{
|
{
|
@ -175,6 +175,6 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
//$@"┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━┫
|
//$@"┣━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━┫
|
||||||
//┃{(e.Server.Users.Where(u => u.Id == (ulong)cs.UserId).FirstOrDefault()?.Name.TrimTo(18, true) ?? cs.UserId.ToString()),-20} ┃ {cs.Value,5} ┃")
|
//┃{(e.Server.Users.Where(u => u.Id == (ulong)cs.UserId).FirstOrDefault()?.Name.TrimTo(18, true) ?? cs.UserId.ToString()),-20} ┃ {cs.Value,5} ┃")
|
||||||
// ).ToString() + "┗━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━┛```").ConfigureAwait(false);
|
// ).ToString() + "┗━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━┛```").ConfigureAwait(false);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
var num = 1;
|
var num = 1;
|
||||||
msgToSend = answers.Aggregate(msgToSend, (current, answ) => current + $"`{num++}.` **{answ}**\n");
|
msgToSend = answers.Aggregate(msgToSend, (current, answ) => current + $"`{num++}.` **{answ}**\n");
|
||||||
msgToSend += "\n**Private Message me with the corresponding number of the answer.**";
|
msgToSend += "\n**Private Message me with the corresponding number of the answer.**";
|
||||||
await channel.SendMessageAsync(msgToSend).ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync(msgToSend).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StopPoll(IGuildChannel ch)
|
public async Task StopPoll(IGuildChannel ch)
|
||||||
@ -91,7 +91,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
var totalVotesCast = results.Sum(kvp => kvp.Value);
|
var totalVotesCast = results.Sum(kvp => kvp.Value);
|
||||||
if (totalVotesCast == 0)
|
if (totalVotesCast == 0)
|
||||||
{
|
{
|
||||||
await channel.SendMessageAsync("📄 **No votes have been cast.**").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync("📄 **No votes have been cast.**").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var closeMessage = $"--------------**POLL CLOSED**--------------\n" +
|
var closeMessage = $"--------------**POLL CLOSED**--------------\n" +
|
||||||
@ -100,7 +100,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
$" has {kvp.Value} votes." +
|
$" has {kvp.Value} votes." +
|
||||||
$"({kvp.Value * 1.0f / totalVotesCast * 100}%)\n");
|
$"({kvp.Value * 1.0f / totalVotesCast * 100}%)\n");
|
||||||
|
|
||||||
await channel.SendMessageAsync($"📄 **Total votes cast**: {totalVotesCast}\n{closeMessage}").ConfigureAwait(false);
|
await imsg.Channel.SendMessageAsync($"📄 **Total votes cast**: {totalVotesCast}\n{closeMessage}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -1,19 +1,75 @@
|
|||||||
//using Discord.Commands;
|
using Discord;
|
||||||
//using NadekoBot.Classes;
|
using Discord.Commands;
|
||||||
//using NadekoBot.Extensions;
|
using NadekoBot.Attributes;
|
||||||
//using Newtonsoft.Json.Linq;
|
using NadekoBot.Extensions;
|
||||||
//using System;
|
using Newtonsoft.Json.Linq;
|
||||||
//using System.Collections.Generic;
|
using System;
|
||||||
//using System.Drawing;
|
using System.Collections.Generic;
|
||||||
//using System.Linq;
|
using System.Linq;
|
||||||
//using System.Text;
|
using System.Net.Http;
|
||||||
//using System.Threading.Tasks;
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
////todo drawing
|
//todo drawing
|
||||||
//namespace NadekoBot.Modules.Searches.Commands
|
namespace NadekoBot.Modules.Searches.Commands
|
||||||
//{
|
{
|
||||||
// internal class LoLCommands : DiscordCommand
|
public partial class Searches
|
||||||
// {
|
{
|
||||||
|
private class ChampionNameComparer : IEqualityComparer<JToken>
|
||||||
|
{
|
||||||
|
public bool Equals(JToken a, JToken b) => a["name"].ToString() == b["name"].ToString();
|
||||||
|
|
||||||
|
public int GetHashCode(JToken obj) =>
|
||||||
|
obj["name"].GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string[] trashTalk { get; } = { "Better ban your counters. You are going to carry the game anyway.",
|
||||||
|
"Go with the flow. Don't think. Just ban one of these.",
|
||||||
|
"DONT READ BELOW! Ban Urgot mid OP 100%. Im smurf Diamond 1.",
|
||||||
|
"Ask your teammates what would they like to play, and ban that.",
|
||||||
|
"If you consider playing teemo, do it. If you consider teemo, you deserve him.",
|
||||||
|
"Doesn't matter what you ban really. Enemy will ban your main and you will lose." };
|
||||||
|
|
||||||
|
|
||||||
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
|
[RequireContext(ContextType.Guild)]
|
||||||
|
public async Task Lolban(IMessage imsg)
|
||||||
|
{
|
||||||
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var showCount = 8;
|
||||||
|
//http://api.champion.gg/stats/champs/mostBanned?api_key=YOUR_API_TOKEN&page=1&limit=2
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var http = new HttpClient())
|
||||||
|
{
|
||||||
|
var data = JObject.Parse(await http.GetStringAsync($"http://api.champion.gg/stats/champs/mostBanned?" +
|
||||||
|
$"api_key={NadekoBot.Credentials.LoLApiKey}&page=1&" +
|
||||||
|
$"limit={showCount}")
|
||||||
|
.ConfigureAwait(false))["data"] as JArray;
|
||||||
|
var dataList = data.Distinct(new ChampionNameComparer()).Take(showCount).ToList();
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
sb.AppendLine($"**Showing {showCount} top banned champions.**");
|
||||||
|
sb.AppendLine($"`{trashTalk[new Random().Next(0, trashTalk.Length)]}`");
|
||||||
|
for (var i = 0; i < dataList.Count; i++)
|
||||||
|
{
|
||||||
|
if (i % 2 == 0 && i != 0)
|
||||||
|
sb.AppendLine();
|
||||||
|
sb.Append($"`{i + 1}.` **{dataList[i]["name"]}** ");
|
||||||
|
}
|
||||||
|
|
||||||
|
await channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
await channel.SendMessageAsync($":anger: Fail: Champion.gg didsabled ban data until next patch. Sorry for the inconvenience.").ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// private class CachedChampion
|
// private class CachedChampion
|
||||||
// {
|
// {
|
||||||
@ -22,14 +78,7 @@
|
|||||||
// public string Name { get; set; }
|
// public string Name { get; set; }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// private class ChampionNameComparer : IEqualityComparer<JToken>
|
//
|
||||||
// {
|
|
||||||
// public bool Equals(JToken a, JToken b) => a["name"].ToString() == b["name"].ToString();
|
|
||||||
|
|
||||||
// public int GetHashCode(JToken obj) =>
|
|
||||||
// obj["name"].GetHashCode();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private static Dictionary<string, CachedChampion> CachedChampionImages = new Dictionary<string, CachedChampion>();
|
// private static Dictionary<string, CachedChampion> CachedChampionImages = new Dictionary<string, CachedChampion>();
|
||||||
|
|
||||||
// private System.Timers.Timer clearTimer { get; } = new System.Timers.Timer();
|
// private System.Timers.Timer clearTimer { get; } = new System.Timers.Timer();
|
||||||
@ -41,21 +90,14 @@
|
|||||||
// {
|
// {
|
||||||
// try
|
// try
|
||||||
// {
|
// {
|
||||||
// CachedChampionImages = CachedChampionImages
|
// CachedChampionImages = CachedChampionImages
|
||||||
// .Where(kvp => DateTime.Now - kvp.Value.AddedAt > new TimeSpan(1, 0, 0))
|
// .Where(kvp => DateTime.Now - kvp.Value.AddedAt > new TimeSpan(1, 0, 0))
|
||||||
// .ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
|
// .ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
|
||||||
// }
|
// }
|
||||||
// catch { }
|
// catch { }
|
||||||
// };
|
// };
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// private readonly string[] trashTalk = { "Better ban your counters. You are going to carry the game anyway.",
|
|
||||||
// "Go with the flow. Don't think. Just ban one of these.",
|
|
||||||
// "DONT READ BELOW! Ban Urgot mid OP 100%. Im smurf Diamond 1.",
|
|
||||||
// "Ask your teammates what would they like to play, and ban that.",
|
|
||||||
// "If you consider playing teemo, do it. If you consider teemo, you deserve him.",
|
|
||||||
// "Doesn't matter what you ban really. Enemy will ban your main and you will lose." };
|
|
||||||
|
|
||||||
// public Func<CommandEventArgs, Task> DoFunc()
|
// public Func<CommandEventArgs, Task> DoFunc()
|
||||||
// {
|
// {
|
||||||
// throw new NotImplementedException();
|
// throw new NotImplementedException();
|
||||||
@ -86,7 +128,7 @@
|
|||||||
// var name = e.GetArg("champ").Replace(" ", "").ToLower();
|
// var name = e.GetArg("champ").Replace(" ", "").ToLower();
|
||||||
// CachedChampion champ = null;
|
// CachedChampion champ = null;
|
||||||
|
|
||||||
// if(CachedChampionImages.TryGetValue(name + "_" + resolvedRole, out champ))
|
// if (CachedChampionImages.TryGetValue(name + "_" + resolvedRole, out champ))
|
||||||
// if (champ != null)
|
// if (champ != null)
|
||||||
// {
|
// {
|
||||||
// champ.ImageStream.Position = 0;
|
// champ.ImageStream.Position = 0;
|
||||||
@ -117,7 +159,7 @@
|
|||||||
// role = allData[0]["role"].ToString();
|
// role = allData[0]["role"].ToString();
|
||||||
// resolvedRole = ResolvePos(role);
|
// resolvedRole = ResolvePos(role);
|
||||||
// }
|
// }
|
||||||
// if(CachedChampionImages.TryGetValue(name + "_" + resolvedRole, out champ))
|
// if (CachedChampionImages.TryGetValue(name + "_" + resolvedRole, out champ))
|
||||||
// if (champ != null)
|
// if (champ != null)
|
||||||
// {
|
// {
|
||||||
// champ.ImageStream.Position = 0;
|
// champ.ImageStream.Position = 0;
|
||||||
@ -279,42 +321,6 @@
|
|||||||
// await channel.SendMessageAsync("💢 Failed retreiving data for that champion.").ConfigureAwait(false);
|
// await channel.SendMessageAsync("💢 Failed retreiving data for that champion.").ConfigureAwait(false);
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// cgb.CreateCommand(Module.Prefix + "lolban")
|
|
||||||
// .Description($"Shows top 6 banned champions ordered by ban rate. Ban these champions and you will be Plat 5 in no time. | `{Prefix}lolban`")
|
|
||||||
// .Do(async e =>
|
|
||||||
// {
|
|
||||||
|
|
||||||
// var showCount = 8;
|
|
||||||
// //http://api.champion.gg/stats/champs/mostBanned?api_key=YOUR_API_TOKEN&page=1&limit=2
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// var data = JObject.Parse(
|
|
||||||
// await Classes
|
|
||||||
// .SearchHelper
|
|
||||||
// .GetResponseStringAsync($"http://api.champion.gg/stats/champs/mostBanned?" +
|
|
||||||
// $"api_key={NadekoBot.Creds.LOLAPIKey}&page=1&" +
|
|
||||||
// $"limit={showCount}")
|
|
||||||
// .ConfigureAwait(false))["data"] as JArray;
|
|
||||||
// var dataList = data.Distinct(new ChampionNameComparer()).Take(showCount).ToList();
|
|
||||||
// var sb = new StringBuilder();
|
|
||||||
// sb.AppendLine($"**Showing {showCount} top banned champions.**");
|
|
||||||
// sb.AppendLine($"`{trashTalk[new Random().Next(0, trashTalk.Length)]}`");
|
|
||||||
// for (var i = 0; i < dataList.Count; i++)
|
|
||||||
// {
|
|
||||||
// if (i % 2 == 0 && i != 0)
|
|
||||||
// sb.AppendLine();
|
|
||||||
// sb.Append($"`{i + 1}.` **{dataList[i]["name"]}** ");
|
|
||||||
// //sb.AppendLine($" ({dataList[i]["general"]["banRate"]}%)");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// await channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false);
|
|
||||||
// }
|
|
||||||
// catch (Exception)
|
|
||||||
// {
|
|
||||||
// await channel.SendMessageAsync($":anger: Fail: Champion.gg didsabled ban data until next patch. Sorry for the inconvenience.").ConfigureAwait(false);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// private enum GetImageType
|
// private enum GetImageType
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace NadekoBot.Services
|
namespace NadekoBot.Services
|
||||||
@ -9,7 +10,8 @@ namespace NadekoBot.Services
|
|||||||
string Token { get; }
|
string Token { get; }
|
||||||
string GoogleApiKey { get; }
|
string GoogleApiKey { get; }
|
||||||
ulong[] OwnerIds { get; }
|
ulong[] OwnerIds { get; }
|
||||||
|
IEnumerable<string> MashapeKey { get; }
|
||||||
|
string LoLApiKey { get; }
|
||||||
|
|
||||||
bool IsOwner(IUser u);
|
bool IsOwner(IUser u);
|
||||||
}
|
}
|
||||||
|
@ -20,16 +20,20 @@ namespace NadekoBot.Services.Impl
|
|||||||
|
|
||||||
public ulong[] OwnerIds { get; }
|
public ulong[] OwnerIds { get; }
|
||||||
|
|
||||||
|
public string LoLApiKey { get; }
|
||||||
|
|
||||||
public BotCredentials()
|
public BotCredentials()
|
||||||
{
|
{
|
||||||
var cm = JsonConvert.DeserializeObject<CredentialsModel>(File.ReadAllText("./credentials.json"));
|
var cm = JsonConvert.DeserializeObject<CredentialsModel>(File.ReadAllText("./credentials.json"));
|
||||||
Token = cm.Token;
|
Token = cm.Token;
|
||||||
OwnerIds = cm.OwnerIds;
|
OwnerIds = cm.OwnerIds;
|
||||||
|
LoLApiKey = cm.LoLApiKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CredentialsModel {
|
private class CredentialsModel {
|
||||||
public string Token { get; set; }
|
public string Token { get; set; }
|
||||||
public ulong[] OwnerIds { get; set; }
|
public ulong[] OwnerIds { get; set; }
|
||||||
|
public string LoLApiKey { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsOwner(IUser u) => OwnerIds.Contains(u.Id);
|
public bool IsOwner(IUser u) => OwnerIds.Contains(u.Id);
|
||||||
|
Loading…
Reference in New Issue
Block a user