diff --git a/src/NadekoBot/Modules/Administration/Administration.cs b/src/NadekoBot/Modules/Administration/Administration.cs index af0d13df..2d62e236 100644 --- a/src/NadekoBot/Modules/Administration/Administration.cs +++ b/src/NadekoBot/Modules/Administration/Administration.cs @@ -432,7 +432,7 @@ namespace NadekoBot.Modules.Administration { var channel = (ITextChannel)umsg.Channel; topic = topic ?? ""; - await (channel as ITextChannel).ModifyAsync(c => c.Topic = topic); + await channel.ModifyAsync(c => c.Topic = topic); await channel.SendMessageAsync(":ok: **New channel topic set.**").ConfigureAwait(false); } @@ -467,7 +467,7 @@ namespace NadekoBot.Modules.Administration [RequirePermission(ChannelPermission.ManageMessages)] public async Task Prune(IUserMessage msg, int count) { - var channel = msg.Channel as ITextChannel; + var channel = (ITextChannel)msg.Channel; await (msg as IUserMessage).DeleteAsync(); while (count > 0) { @@ -485,7 +485,7 @@ namespace NadekoBot.Modules.Administration [RequireContext(ContextType.Guild)] public async Task Prune(IUserMessage msg, IGuildUser user, int count = 100) { - var channel = msg.Channel as ITextChannel; + var channel = (ITextChannel)msg.Channel; int limit = (count < 100) ? count : 100; var enumerable = (await msg.Channel.GetMessagesAsync(limit: limit)).Where(m => m.Author == user); await msg.Channel.DeleteMessagesAsync(enumerable); diff --git a/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs b/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs index 542946cd..c7e8e708 100644 --- a/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs +++ b/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs @@ -27,11 +27,8 @@ namespace NadekoBot.Modules.ClashOfClans uow.ClashOfClans .GetAll() .Select(cw => { - cw.Channel = NadekoBot.Client.GetGuilds() - .FirstOrDefault(s => s.Id == cw.GuildId)? - .GetChannels() - .FirstOrDefault(c => c.Id == cw.ChannelId) - as ITextChannel; + cw.Channel = NadekoBot.Client.GetGuild(cw.GuildId) + ?.GetTextChannel(cw.ChannelId); cw.Bases.Capacity = cw.Size; return cw; }) @@ -318,11 +315,8 @@ namespace NadekoBot.Modules.ClashOfClans Bases = new List(size), GuildId = serverId, ChannelId = channelId, - Channel = NadekoBot.Client.GetGuilds() - .FirstOrDefault(s => s.Id == serverId)? - .GetChannels() - .FirstOrDefault(c => c.Id == channelId) - as ITextChannel + Channel = NadekoBot.Client.GetGuild(serverId) + ?.GetTextChannel(channelId) }; uow.ClashOfClans.Add(cw); await uow.CompleteAsync(); diff --git a/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs b/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs index d6ecfa5e..0db9b5d1 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/DiceRollCommand.cs @@ -1,11 +1,14 @@ using Discord; using Discord.Commands; +using ImageProcessorCore; using NadekoBot.Attributes; using NadekoBot.Extensions; using NadekoBot.Services; using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Resources; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -17,94 +20,191 @@ namespace NadekoBot.Modules.Gambling [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] [RequireContext(ContextType.Guild)] - public Task Roll(IUserMessage umsg, [Remainder] string arg = null) => - publicRoll(umsg, arg, true); + public async Task Roll(IUserMessage umsg) + { + var channel = (ITextChannel)umsg.Channel; + if (channel == null) + return; + var rng = new NadekoRandom(); + var gen = rng.Next(1, 101); + + var num1 = gen / 10; + var num2 = gen % 10; + var imageStream = await Task.Run(() => + { + var ms = new MemoryStream(); + new[] { GetDice(num1), GetDice(num2) }.Merge().SaveAsPng(ms); + ms.Position = 0; + return ms; + }); + + await channel.SendFileAsync(imageStream, "dice.png", $"{umsg.Author.Mention} rolled " + Format.Code(gen.ToString())).ConfigureAwait(false); + } [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] [RequireContext(ContextType.Guild)] - public Task Rolluo(IUserMessage umsg, [Remainder] string arg = null) => - publicRoll(umsg, arg, false); - //todo drawing - private async Task publicRoll(IUserMessage umsg, string arg, bool ordered) + public async Task Roll(IUserMessage umsg, int num) { var channel = (ITextChannel)umsg.Channel; - var r = new NadekoRandom(); - //if (string.IsNullOrWhiteSpace(arg)) - //{ - // var gen = r.Next(0, 101); + if (channel == null) + return; - // var num1 = gen / 10; - // var num2 = gen % 10; + var ordered = true; + + if (num < 1 || num > 30) + { + await channel.SendMessageAsync("Invalid number specified. You can roll up to 1-30 dice at a time.").ConfigureAwait(false); + num = 30; + } - // var imageStream = await new Image[2] { GetDice(num1), GetDice(num2) }.Merge().ToStream(ImageFormat.Png); + var rng = new NadekoRandom(); - // await channel.SendFileAsync(imageStream, "dice.png").ConfigureAwait(false); - // return; - //} - Match m; - if ((m = dndRegex.Match(arg)).Length != 0) + var dice = new List(num); + var values = new List(num); + for (var i = 0; i < num; i++) + { + var randomNumber = rng.Next(1, 7); + var toInsert = dice.Count; + if (ordered) + { + if (randomNumber == 6 || dice.Count == 0) + toInsert = 0; + else if (randomNumber != 1) + for (var j = 0; j < dice.Count; j++) + { + if (values[j] < randomNumber) + { + toInsert = j; + break; + } + } + } + else + { + toInsert = dice.Count; + } + dice.Insert(toInsert, GetDice(randomNumber)); + values.Insert(toInsert, randomNumber); + } + + var bitmap = dice.Merge(); + var ms = new MemoryStream(); + bitmap.SaveAsPng(ms); + ms.Position = 0; + await channel.SendFileAsync(ms, "dice.png", $"{umsg.Author.Mention} rolled {values.Count} {(values.Count == 1 ? "die" : "dice")}. Total: **{values.Sum()}** Average: **{(values.Sum() / (1.0f * values.Count)).ToString("N2")}**").ConfigureAwait(false); + } + //todo merge into internallDndRoll and internalRoll + [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] + [RequireContext(ContextType.Guild)] + public async Task Roll(IUserMessage umsg, string arg = "") + { + var channel = (ITextChannel)umsg.Channel; + if (channel == null) + return; + + var ordered = true; + var rng = new NadekoRandom(); + Match match; + if ((match = 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) && + if (int.TryParse(match.Groups["n1"].ToString(), out n1) && + int.TryParse(match.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); + arr[i] = rng.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); + await channel.SendMessageAsync($"`{umsg.Author.Mention} 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(num); - // var values = new List(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, LocalizedAlias] + [RequireContext(ContextType.Guild)] + public async Task Rolluo(IUserMessage umsg, string arg = "") + { + var channel = (ITextChannel)umsg.Channel; + if (channel == null) + return; + + var ordered = false; + var rng = new NadekoRandom(); + Match match; + if ((match = dndRegex.Match(arg)).Length != 0) + { + int n1; + int n2; + if (int.TryParse(match.Groups["n1"].ToString(), out n1) && + int.TryParse(match.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] = rng.Next(1, n2 + 1); + } + var elemCnt = 0; + await channel.SendMessageAsync($"`{umsg.Author.Mention} 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); + } + } + } + + [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] + [RequireContext(ContextType.Guild)] + public async Task Rolluo(IUserMessage umsg, int num) + { + var channel = (ITextChannel)umsg.Channel; + if (channel == null) + return; + + var ordered = true; + + if (num < 1 || num > 30) + { + await channel.SendMessageAsync("Invalid number specified. You can roll up to 1-30 dice at a time.").ConfigureAwait(false); + num = 30; + } + + var rng = new NadekoRandom(); + + var dice = new List(num); + var values = new List(num); + for (var i = 0; i < num; i++) + { + var randomNumber = rng.Next(1, 7); + var toInsert = dice.Count; + if (ordered) + { + if (randomNumber == 6 || dice.Count == 0) + toInsert = 0; + else if (randomNumber != 1) + for (var j = 0; j < dice.Count; j++) + { + if (values[j] < randomNumber) + { + toInsert = j; + break; + } + } + } + else + { + toInsert = dice.Count; + } + dice.Insert(toInsert, GetDice(randomNumber)); + values.Insert(toInsert, randomNumber); + } + + var bitmap = dice.Merge(); + var ms = new MemoryStream(); + bitmap.SaveAsPng(ms); + ms.Position = 0; + await channel.SendFileAsync(ms, "dice.png", $"{umsg.Author.Mention} rolled {values.Count} {(values.Count == 1 ? "die" : "dice")}. Total: **{values.Sum()}** Average: **{(values.Sum() / (1.0f * values.Count)).ToString("N2")}**").ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] @@ -112,8 +212,7 @@ namespace NadekoBot.Modules.Gambling public async Task NRoll(IUserMessage umsg, [Remainder] string range) { var channel = (ITextChannel)umsg.Channel; - - + try { int rolled; @@ -140,14 +239,23 @@ namespace NadekoBot.Modules.Gambling } } + private Image GetDice(int num) + { + const string pathToImage = "data/images/dice"; + if(num != 10) + { + using (var stream = File.OpenRead(Path.Combine(pathToImage, $"{num}.png"))) + return new Image(stream); + } - ////todo drawing - //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(); + using (var one = File.OpenRead(Path.Combine(pathToImage, "1.png"))) + using (var zero = File.OpenRead(Path.Combine(pathToImage, "0.png"))) + { + Image imgOne = new Image(one); + Image imgZero = new Image(zero); + + return new[] { imgOne, imgZero }.Merge(); + } + } } } \ No newline at end of file diff --git a/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs b/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs index 17c5033b..af419051 100644 --- a/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs +++ b/src/NadekoBot/Modules/Gambling/Commands/DrawCommand.cs @@ -1,92 +1,70 @@ -//using Discord.Commands; -//using NadekoBot.Classes; -//using NadekoBot.Extensions; -//using NadekoBot.Modules.Gambling.Helpers; -//using System; -//using System.Collections.Concurrent; -//using System.Collections.Generic; -//using System.Drawing; -//using System.Threading.Tasks; +using Discord; +using Discord.Commands; +using ImageProcessorCore; +using NadekoBot.Attributes; +using NadekoBot.Extensions; +using NadekoBot.Modules.Gambling.Models; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; -////todo drawing -//namespace NadekoBot.Modules.Gambling -//{ -// public class DrawCommand : DiscordCommand -// { -// public DrawCommand(DiscordModule module) : base(module) { } +namespace NadekoBot.Modules.Gambling +{ + [Group] + public class DrawCommands + { + private static readonly ConcurrentDictionary AllDecks = new ConcurrentDictionary(); -// public override void Init(CommandGroupBuilder cgb) -// { -// 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]`") -// .Parameter("count", ParameterType.Optional) -// .Do(DrawCardFunc()); + private const string cardsPath = "data/images/cards"; + [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] + [RequireContext(ContextType.Guild)] + public async Task Draw(IUserMessage msg) + { + var channel = (ITextChannel)msg.Channel; + var cards = AllDecks.GetOrAdd(channel.Guild, (s) => new Cards()); + + var num = 1; + var images = new List(); + var cardObjects = new List(); + for (var i = 0; i < num; i++) + { + if (cards.CardPool.Count == 0 && i != 0) + { + await channel.SendMessageAsync("No more cards in a deck.").ConfigureAwait(false); + break; + } + var currentCard = cards.DrawACard(); + cardObjects.Add(currentCard); + using (var stream = File.OpenRead(Path.Combine(cardsPath, currentCard.GetName()))) + images.Add(new Image(stream)); + } + MemoryStream bitmapStream = new MemoryStream(); + images.Merge().SaveAsPng(bitmapStream); + bitmapStream.Position = 0; + await channel.SendFileAsync(bitmapStream, images.Count + " cards.jpg", $"{msg.Author.Mention} drew (TODO: CARD NAMES HERE)").ConfigureAwait(false); + if (cardObjects.Count == 5) + { + await channel.SendMessageAsync($"{msg.Author.Mention} `{Cards.GetHandValue(cardObjects)}`").ConfigureAwait(false); + } + } -// cgb.CreateCommand(Module.Prefix + "shuffle") -// .Alias(Module.Prefix + "sh") -// .Description($"Reshuffles all cards back into the deck.|`{Prefix}shuffle`") -// .Do(ReshuffleTask()); -// } + [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] + [RequireContext(ContextType.Guild)] + public async Task Shuffle(IUserMessage imsg) + { + var channel = (ITextChannel)imsg.Channel; -// private static readonly ConcurrentDictionary AllDecks = new ConcurrentDictionary(); + AllDecks.AddOrUpdate(channel.Guild, + (s) => new Cards(), + (s, c) => + { + c.Restart(); + return c; + }); -// private static Func ReshuffleTask() -// { -// return async e => -// { -// AllDecks.AddOrUpdate(e.Server, -// (s) => new Cards(), -// (s, c) => -// { -// c.Restart(); -// return c; -// }); - -// await channel.SendMessageAsync("Deck reshuffled.").ConfigureAwait(false); -// }; -// } - -// private Func DrawCardFunc() => async (e) => -// { -// var cards = AllDecks.GetOrAdd(e.Server, (s) => new Cards()); - -// try -// { -// var num = 1; -// var isParsed = int.TryParse(count, out num); -// if (!isParsed || num < 2) -// { -// var c = cards.DrawACard(); -// await e.Channel.SendFile(c.Name + ".jpg", (Properties.Resources.ResourceManager.GetObject(c.Name) as Image).ToStream()).ConfigureAwait(false); -// return; -// } -// if (num > 5) -// num = 5; - -// var images = new List(); -// var cardObjects = new List(); -// for (var i = 0; i < num; i++) -// { -// if (cards.CardPool.Count == 0 && i != 0) -// { -// await channel.SendMessageAsync("No more cards in a deck.").ConfigureAwait(false); -// break; -// } -// var currentCard = cards.DrawACard(); -// cardObjects.Add(currentCard); -// images.Add(Properties.Resources.ResourceManager.GetObject(currentCard.Name) as Image); -// } -// var bitmap = images.Merge(); -// await e.Channel.SendFile(images.Count + " cards.jpg", bitmap.ToStream()).ConfigureAwait(false); -// if (cardObjects.Count == 5) -// { -// await channel.SendMessageAsync($"{umsg.Author.Mention} `{Cards.GetHandValue(cardObjects)}`").ConfigureAwait(false); -// } -// } -// catch (Exception ex) -// { -// Console.WriteLine("Error drawing (a) card(s) " + ex.ToString()); -// } -// }; -// } -//} + await channel.SendMessageAsync("`Deck reshuffled.`").ConfigureAwait(false); + } + } +} diff --git a/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs b/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs index 53d3c01b..42a50242 100644 --- a/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/PlantAndPickCommands.cs @@ -14,7 +14,6 @@ using System.Security.Cryptography; using System.Threading; using System.Threading.Tasks; -//todo rewrite namespace NadekoBot.Modules.Games { public partial class Games @@ -150,6 +149,7 @@ namespace NadekoBot.Modules.Games var file = GetRandomCurrencyImagePath(); IUserMessage msg; var vowelFirst = new[] { 'a', 'e', 'i', 'o', 'u' }.Contains(Gambling.Gambling.CurrencyName[0]); + //todo add prefix var msgToSend = $"Oh how Nice! **{imsg.Author.Username}** planted {(vowelFirst ? "an" : "a")} {Gambling.Gambling.CurrencyName}. Pick it using >pick"; if (file == null) { @@ -157,7 +157,6 @@ namespace NadekoBot.Modules.Games } else { - //todo add prefix msg = await channel.SendFileAsync(file, msgToSend).ConfigureAwait(false); } plantedFlowers.AddOrUpdate(channel.Id, new List() { msg }, (id, old) => { old.Add(msg); return old; }); @@ -168,7 +167,7 @@ namespace NadekoBot.Modules.Games [RequirePermission(GuildPermission.ManageMessages)] public async Task Gencurrency(IUserMessage imsg) { - var channel = imsg.Channel as ITextChannel; + var channel = (ITextChannel)imsg.Channel; if (channel == null) return; diff --git a/src/NadekoBot/Modules/Games/Commands/TriviaCommands.cs b/src/NadekoBot/Modules/Games/Commands/TriviaCommands.cs index 959562a0..63a8a820 100644 --- a/src/NadekoBot/Modules/Games/Commands/TriviaCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/TriviaCommands.cs @@ -34,7 +34,7 @@ namespace NadekoBot.Modules.Games }).Where(t => t.Item1).Select(t => t.Item2).FirstOrDefault(); if (number < 0) return; - var triviaGame = new TriviaGame(channel.Guild, umsg.Channel as ITextChannel, showHints, number == 0 ? 10 : number); + var triviaGame = new TriviaGame(channel.Guild, (ITextChannel)umsg.Channel, showHints, number == 0 ? 10 : number); if (RunningTrivias.TryAdd(channel.Guild.Id, triviaGame)) await channel.SendMessageAsync($"**Trivia game started! {triviaGame.WinRequirement} points needed to win.**").ConfigureAwait(false); else diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index 2e987145..0ac25ca1 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -52,7 +52,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 public async Task Youtube(IUserMessage umsg, [Remainder] string query = null) { var channel = (ITextChannel)umsg.Channel; - if (!(await ValidateQuery(umsg.Channel as ITextChannel, query).ConfigureAwait(false))) return; + if (!(await ValidateQuery(channel, query).ConfigureAwait(false))) return; var result = (await _google.GetVideosByKeywordsAsync(query, 1)).FirstOrDefault(); if (string.IsNullOrWhiteSpace(result)) { @@ -68,7 +68,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】 { var channel = (ITextChannel)umsg.Channel; - if (!(await ValidateQuery(umsg.Channel as ITextChannel, query).ConfigureAwait(false))) return; + if (!(await ValidateQuery(channel, query).ConfigureAwait(false))) return; await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); string result; try diff --git a/src/NadekoBot/Modules/Utility/Commands/InfoCommands.cs b/src/NadekoBot/Modules/Utility/Commands/InfoCommands.cs index 7b5a9ef1..9993c1d3 100644 --- a/src/NadekoBot/Modules/Utility/Commands/InfoCommands.cs +++ b/src/NadekoBot/Modules/Utility/Commands/InfoCommands.cs @@ -16,7 +16,7 @@ namespace NadekoBot.Modules.Utility [RequireContext(ContextType.Guild)] public async Task ServerInfo(IUserMessage msg, string guild = null) { - var channel = msg.Channel as ITextChannel; + var channel = (ITextChannel)msg.Channel; guild = guild?.ToUpperInvariant(); IGuild server; if (guild == null) @@ -51,7 +51,7 @@ namespace NadekoBot.Modules.Utility [RequireContext(ContextType.Guild)] public async Task ChannelInfo(IUserMessage msg, ITextChannel channel = null) { - var ch = channel ?? msg.Channel as ITextChannel; + var ch = channel ?? (ITextChannel)msg.Channel; if (ch == null) return; var createdAt = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(ch.Id >> 22); @@ -67,7 +67,7 @@ namespace NadekoBot.Modules.Utility [RequireContext(ContextType.Guild)] public async Task UserInfo(IUserMessage msg, IGuildUser usr = null) { - var channel = msg.Channel as ITextChannel; + var channel = (ITextChannel)msg.Channel; var user = usr ?? msg.Author as IGuildUser; if (user == null) return; diff --git a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs index 98f62442..f2102c15 100644 --- a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs +++ b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs @@ -18,7 +18,7 @@ namespace NadekoBot.Modules.Utility [RequireContext(ContextType.Guild)] public async Task ShowQuote(IUserMessage umsg, string keyword) { - var channel = umsg.Channel as ITextChannel; + var channel = (ITextChannel)umsg.Channel; if (string.IsNullOrWhiteSpace(keyword)) return; @@ -41,7 +41,7 @@ namespace NadekoBot.Modules.Utility [RequireContext(ContextType.Guild)] public async Task AddQuote(IUserMessage umsg, string keyword, [Remainder] string text) { - var channel = umsg.Channel as ITextChannel; + var channel = (ITextChannel)umsg.Channel; if (string.IsNullOrWhiteSpace(keyword) || string.IsNullOrWhiteSpace(text)) return; @@ -67,7 +67,7 @@ namespace NadekoBot.Modules.Utility [RequireContext(ContextType.Guild)] public async Task DeleteQuote(IUserMessage umsg, string keyword) { - var channel = umsg.Channel as ITextChannel; + var channel = (ITextChannel)umsg.Channel; if (string.IsNullOrWhiteSpace(keyword)) return; @@ -94,7 +94,7 @@ namespace NadekoBot.Modules.Utility [RequireContext(ContextType.Guild)] public async Task DelAllQuotes(IUserMessage umsg, string keyword) { - var channel = umsg.Channel as ITextChannel; + var channel = (ITextChannel)umsg.Channel; if (string.IsNullOrWhiteSpace(keyword)) return; diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index 2464d5c9..5ce18ef3 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -83,7 +83,7 @@ namespace NadekoBot.Modules.Utility StringBuilder builder = new StringBuilder("```\n"); var user = msg.Author as IGuildUser; - var perms = user.GetPermissions(msg.Channel as ITextChannel); + var perms = user.GetPermissions((ITextChannel)msg.Channel); foreach (var p in perms.GetType().GetProperties().Where(p => !p.GetGetMethod().GetParameters().Any())) { builder.AppendLine($"{p.Name} : {p.GetValue(perms, null).ToString()}"); @@ -111,21 +111,22 @@ namespace NadekoBot.Modules.Utility [RequireContext(ContextType.Guild)] public async Task ServerId(IUserMessage msg) { - await msg.Reply($"This server's ID is {(msg.Channel as ITextChannel).Guild.Id}").ConfigureAwait(false); + await msg.Reply($"This server's ID is {((ITextChannel)msg.Channel).Guild.Id}").ConfigureAwait(false); } [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] [RequireContext(ContextType.Guild)] public async Task Roles(IUserMessage msg, IGuildUser target = null) { - var guild = (msg.Channel as ITextChannel).Guild; + var channel = (ITextChannel)msg.Channel; + var guild = channel.Guild; if (target != null) { await msg.Reply($"`List of roles for **{target.Username}**:` \n• " + string.Join("\n• ", target.Roles.Except(new[] { guild.EveryoneRole }).OrderBy(r => r.Position))); } else { - await msg.Reply("`List of roles:` \n• " + string.Join("\n• ", (msg.Channel as ITextChannel).Guild.Roles.Except(new[] { guild.EveryoneRole }).OrderBy(r=>r.Position))); + await msg.Reply("`List of roles:` \n• " + string.Join("\n• ", guild.Roles.Except(new[] { guild.EveryoneRole }).OrderBy(r=>r.Position))); } } diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index ed63b4ed..e9cf1a91 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -5622,7 +5622,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to 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.. + /// Looks up a localized string similar to Rolls X normal dice (up to 30) unordered. If you split 2 numbers with letter d (xdy) it will roll x dice from 1 to y.. /// public static string rolluo_desc { get { diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index b126ce83..029ba9f9 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -1408,7 +1408,7 @@ rolluo - 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. + Rolls X normal dice (up to 30) unordered. If you split 2 numbers with letter d (xdy) it will roll x dice from 1 to y. `$rolluo` or `$rolluo 7` or `$rolluo 3d5` diff --git a/src/NadekoBot/Resources/images/cards/10_of_clubs.jpg b/src/NadekoBot/Resources/images/cards/10_of_clubs.jpg deleted file mode 100644 index 6322cec5..00000000 Binary files a/src/NadekoBot/Resources/images/cards/10_of_clubs.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/10_of_diamonds.jpg b/src/NadekoBot/Resources/images/cards/10_of_diamonds.jpg deleted file mode 100644 index a79fb4f2..00000000 Binary files a/src/NadekoBot/Resources/images/cards/10_of_diamonds.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/10_of_hearts.jpg b/src/NadekoBot/Resources/images/cards/10_of_hearts.jpg deleted file mode 100644 index 3a39d044..00000000 Binary files a/src/NadekoBot/Resources/images/cards/10_of_hearts.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/10_of_spades.jpg b/src/NadekoBot/Resources/images/cards/10_of_spades.jpg deleted file mode 100644 index 7f300fb5..00000000 Binary files a/src/NadekoBot/Resources/images/cards/10_of_spades.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/2_of_clubs.jpg b/src/NadekoBot/Resources/images/cards/2_of_clubs.jpg deleted file mode 100644 index 25edc749..00000000 Binary files a/src/NadekoBot/Resources/images/cards/2_of_clubs.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/2_of_diamonds.jpg b/src/NadekoBot/Resources/images/cards/2_of_diamonds.jpg deleted file mode 100644 index 758cf6fb..00000000 Binary files a/src/NadekoBot/Resources/images/cards/2_of_diamonds.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/2_of_hearts.jpg b/src/NadekoBot/Resources/images/cards/2_of_hearts.jpg deleted file mode 100644 index b2758ea2..00000000 Binary files a/src/NadekoBot/Resources/images/cards/2_of_hearts.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/2_of_spades.jpg b/src/NadekoBot/Resources/images/cards/2_of_spades.jpg deleted file mode 100644 index 4e8da335..00000000 Binary files a/src/NadekoBot/Resources/images/cards/2_of_spades.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/3_of_clubs.jpg b/src/NadekoBot/Resources/images/cards/3_of_clubs.jpg deleted file mode 100644 index fd2cdb5a..00000000 Binary files a/src/NadekoBot/Resources/images/cards/3_of_clubs.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/3_of_diamonds.jpg b/src/NadekoBot/Resources/images/cards/3_of_diamonds.jpg deleted file mode 100644 index 920f2b58..00000000 Binary files a/src/NadekoBot/Resources/images/cards/3_of_diamonds.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/3_of_hearts.jpg b/src/NadekoBot/Resources/images/cards/3_of_hearts.jpg deleted file mode 100644 index a4624970..00000000 Binary files a/src/NadekoBot/Resources/images/cards/3_of_hearts.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/3_of_spades.jpg b/src/NadekoBot/Resources/images/cards/3_of_spades.jpg deleted file mode 100644 index 18772596..00000000 Binary files a/src/NadekoBot/Resources/images/cards/3_of_spades.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/4_of_clubs.jpg b/src/NadekoBot/Resources/images/cards/4_of_clubs.jpg deleted file mode 100644 index fec10981..00000000 Binary files a/src/NadekoBot/Resources/images/cards/4_of_clubs.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/4_of_diamonds.jpg b/src/NadekoBot/Resources/images/cards/4_of_diamonds.jpg deleted file mode 100644 index e1dfa3aa..00000000 Binary files a/src/NadekoBot/Resources/images/cards/4_of_diamonds.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/4_of_hearts.jpg b/src/NadekoBot/Resources/images/cards/4_of_hearts.jpg deleted file mode 100644 index cab1d8a4..00000000 Binary files a/src/NadekoBot/Resources/images/cards/4_of_hearts.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/4_of_spades.jpg b/src/NadekoBot/Resources/images/cards/4_of_spades.jpg deleted file mode 100644 index fdb1ca20..00000000 Binary files a/src/NadekoBot/Resources/images/cards/4_of_spades.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/5_of_clubs.jpg b/src/NadekoBot/Resources/images/cards/5_of_clubs.jpg deleted file mode 100644 index 4826957e..00000000 Binary files a/src/NadekoBot/Resources/images/cards/5_of_clubs.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/5_of_diamonds.jpg b/src/NadekoBot/Resources/images/cards/5_of_diamonds.jpg deleted file mode 100644 index 9e8a312f..00000000 Binary files a/src/NadekoBot/Resources/images/cards/5_of_diamonds.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/5_of_hearts.jpg b/src/NadekoBot/Resources/images/cards/5_of_hearts.jpg deleted file mode 100644 index 70aec60b..00000000 Binary files a/src/NadekoBot/Resources/images/cards/5_of_hearts.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/5_of_spades.jpg b/src/NadekoBot/Resources/images/cards/5_of_spades.jpg deleted file mode 100644 index 0221b914..00000000 Binary files a/src/NadekoBot/Resources/images/cards/5_of_spades.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/6_of_clubs.jpg b/src/NadekoBot/Resources/images/cards/6_of_clubs.jpg deleted file mode 100644 index f205dc0c..00000000 Binary files a/src/NadekoBot/Resources/images/cards/6_of_clubs.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/6_of_diamonds.jpg b/src/NadekoBot/Resources/images/cards/6_of_diamonds.jpg deleted file mode 100644 index 76a36be4..00000000 Binary files a/src/NadekoBot/Resources/images/cards/6_of_diamonds.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/6_of_hearts.jpg b/src/NadekoBot/Resources/images/cards/6_of_hearts.jpg deleted file mode 100644 index 2bdef7df..00000000 Binary files a/src/NadekoBot/Resources/images/cards/6_of_hearts.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/6_of_spades.jpg b/src/NadekoBot/Resources/images/cards/6_of_spades.jpg deleted file mode 100644 index e3877d2f..00000000 Binary files a/src/NadekoBot/Resources/images/cards/6_of_spades.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/7_of_clubs.jpg b/src/NadekoBot/Resources/images/cards/7_of_clubs.jpg deleted file mode 100644 index ad0c1cff..00000000 Binary files a/src/NadekoBot/Resources/images/cards/7_of_clubs.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/7_of_diamonds.jpg b/src/NadekoBot/Resources/images/cards/7_of_diamonds.jpg deleted file mode 100644 index c15cad88..00000000 Binary files a/src/NadekoBot/Resources/images/cards/7_of_diamonds.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/7_of_hearts.jpg b/src/NadekoBot/Resources/images/cards/7_of_hearts.jpg deleted file mode 100644 index 0dfe10bf..00000000 Binary files a/src/NadekoBot/Resources/images/cards/7_of_hearts.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/7_of_spades.jpg b/src/NadekoBot/Resources/images/cards/7_of_spades.jpg deleted file mode 100644 index 8458ab5f..00000000 Binary files a/src/NadekoBot/Resources/images/cards/7_of_spades.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/8_of_clubs.jpg b/src/NadekoBot/Resources/images/cards/8_of_clubs.jpg deleted file mode 100644 index df789839..00000000 Binary files a/src/NadekoBot/Resources/images/cards/8_of_clubs.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/8_of_diamonds.jpg b/src/NadekoBot/Resources/images/cards/8_of_diamonds.jpg deleted file mode 100644 index 82eda17d..00000000 Binary files a/src/NadekoBot/Resources/images/cards/8_of_diamonds.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/8_of_hearts.jpg b/src/NadekoBot/Resources/images/cards/8_of_hearts.jpg deleted file mode 100644 index bd5e7258..00000000 Binary files a/src/NadekoBot/Resources/images/cards/8_of_hearts.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/8_of_spades.jpg b/src/NadekoBot/Resources/images/cards/8_of_spades.jpg deleted file mode 100644 index 5b0deab6..00000000 Binary files a/src/NadekoBot/Resources/images/cards/8_of_spades.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/9_of_clubs.jpg b/src/NadekoBot/Resources/images/cards/9_of_clubs.jpg deleted file mode 100644 index ffe26ace..00000000 Binary files a/src/NadekoBot/Resources/images/cards/9_of_clubs.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/9_of_diamonds.jpg b/src/NadekoBot/Resources/images/cards/9_of_diamonds.jpg deleted file mode 100644 index 93cd63a5..00000000 Binary files a/src/NadekoBot/Resources/images/cards/9_of_diamonds.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/9_of_hearts.jpg b/src/NadekoBot/Resources/images/cards/9_of_hearts.jpg deleted file mode 100644 index cbfa0b16..00000000 Binary files a/src/NadekoBot/Resources/images/cards/9_of_hearts.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/9_of_spades.jpg b/src/NadekoBot/Resources/images/cards/9_of_spades.jpg deleted file mode 100644 index fad958b8..00000000 Binary files a/src/NadekoBot/Resources/images/cards/9_of_spades.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/Thumbs.db b/src/NadekoBot/Resources/images/cards/Thumbs.db deleted file mode 100644 index 13a0bb6c..00000000 Binary files a/src/NadekoBot/Resources/images/cards/Thumbs.db and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/ace_of_clubs.jpg b/src/NadekoBot/Resources/images/cards/ace_of_clubs.jpg deleted file mode 100644 index 1acc9d8c..00000000 Binary files a/src/NadekoBot/Resources/images/cards/ace_of_clubs.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/ace_of_diamonds.jpg b/src/NadekoBot/Resources/images/cards/ace_of_diamonds.jpg deleted file mode 100644 index e9a85d95..00000000 Binary files a/src/NadekoBot/Resources/images/cards/ace_of_diamonds.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/ace_of_hearts.jpg b/src/NadekoBot/Resources/images/cards/ace_of_hearts.jpg deleted file mode 100644 index 11b90a7f..00000000 Binary files a/src/NadekoBot/Resources/images/cards/ace_of_hearts.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/ace_of_spades.jpg b/src/NadekoBot/Resources/images/cards/ace_of_spades.jpg deleted file mode 100644 index 35a9cb3e..00000000 Binary files a/src/NadekoBot/Resources/images/cards/ace_of_spades.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/black_joker.jpg b/src/NadekoBot/Resources/images/cards/black_joker.jpg deleted file mode 100644 index 5894c672..00000000 Binary files a/src/NadekoBot/Resources/images/cards/black_joker.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/jack_of_clubs.jpg b/src/NadekoBot/Resources/images/cards/jack_of_clubs.jpg deleted file mode 100644 index a72dd2ed..00000000 Binary files a/src/NadekoBot/Resources/images/cards/jack_of_clubs.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/jack_of_diamonds.jpg b/src/NadekoBot/Resources/images/cards/jack_of_diamonds.jpg deleted file mode 100644 index 5058dc54..00000000 Binary files a/src/NadekoBot/Resources/images/cards/jack_of_diamonds.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/jack_of_hearts.jpg b/src/NadekoBot/Resources/images/cards/jack_of_hearts.jpg deleted file mode 100644 index 0fdb8e82..00000000 Binary files a/src/NadekoBot/Resources/images/cards/jack_of_hearts.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/jack_of_spades.jpg b/src/NadekoBot/Resources/images/cards/jack_of_spades.jpg deleted file mode 100644 index f30f7d27..00000000 Binary files a/src/NadekoBot/Resources/images/cards/jack_of_spades.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/king_of_clubs.jpg b/src/NadekoBot/Resources/images/cards/king_of_clubs.jpg deleted file mode 100644 index 01955d28..00000000 Binary files a/src/NadekoBot/Resources/images/cards/king_of_clubs.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/king_of_diamonds.jpg b/src/NadekoBot/Resources/images/cards/king_of_diamonds.jpg deleted file mode 100644 index ccca76a4..00000000 Binary files a/src/NadekoBot/Resources/images/cards/king_of_diamonds.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/king_of_hearts.jpg b/src/NadekoBot/Resources/images/cards/king_of_hearts.jpg deleted file mode 100644 index 467b0cec..00000000 Binary files a/src/NadekoBot/Resources/images/cards/king_of_hearts.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/king_of_spades.jpg b/src/NadekoBot/Resources/images/cards/king_of_spades.jpg deleted file mode 100644 index 5e7a6857..00000000 Binary files a/src/NadekoBot/Resources/images/cards/king_of_spades.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/queen_of_clubs.jpg b/src/NadekoBot/Resources/images/cards/queen_of_clubs.jpg deleted file mode 100644 index 0430fe4f..00000000 Binary files a/src/NadekoBot/Resources/images/cards/queen_of_clubs.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/queen_of_diamonds.jpg b/src/NadekoBot/Resources/images/cards/queen_of_diamonds.jpg deleted file mode 100644 index 47216eb4..00000000 Binary files a/src/NadekoBot/Resources/images/cards/queen_of_diamonds.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/queen_of_hearts.jpg b/src/NadekoBot/Resources/images/cards/queen_of_hearts.jpg deleted file mode 100644 index 69f02e35..00000000 Binary files a/src/NadekoBot/Resources/images/cards/queen_of_hearts.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/queen_of_spades.jpg b/src/NadekoBot/Resources/images/cards/queen_of_spades.jpg deleted file mode 100644 index 69e95315..00000000 Binary files a/src/NadekoBot/Resources/images/cards/queen_of_spades.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/cards/red_joker.jpg b/src/NadekoBot/Resources/images/cards/red_joker.jpg deleted file mode 100644 index 1e909c5b..00000000 Binary files a/src/NadekoBot/Resources/images/cards/red_joker.jpg and /dev/null differ diff --git a/src/NadekoBot/Resources/images/coins/heads.png b/src/NadekoBot/Resources/images/coins/heads.png deleted file mode 100644 index 95fb7336..00000000 Binary files a/src/NadekoBot/Resources/images/coins/heads.png and /dev/null differ diff --git a/src/NadekoBot/Resources/images/coins/tails.png b/src/NadekoBot/Resources/images/coins/tails.png deleted file mode 100644 index c3cc8d19..00000000 Binary files a/src/NadekoBot/Resources/images/coins/tails.png and /dev/null differ diff --git a/src/NadekoBot/Resources/images/dice/0.png b/src/NadekoBot/Resources/images/dice/0.png deleted file mode 100644 index 8c507544..00000000 Binary files a/src/NadekoBot/Resources/images/dice/0.png and /dev/null differ diff --git a/src/NadekoBot/Resources/images/dice/1.png b/src/NadekoBot/Resources/images/dice/1.png deleted file mode 100644 index bc1fbc3e..00000000 Binary files a/src/NadekoBot/Resources/images/dice/1.png and /dev/null differ diff --git a/src/NadekoBot/Resources/images/dice/2.png b/src/NadekoBot/Resources/images/dice/2.png deleted file mode 100644 index 2e2016eb..00000000 Binary files a/src/NadekoBot/Resources/images/dice/2.png and /dev/null differ diff --git a/src/NadekoBot/Resources/images/dice/3.png b/src/NadekoBot/Resources/images/dice/3.png deleted file mode 100644 index 1e099590..00000000 Binary files a/src/NadekoBot/Resources/images/dice/3.png and /dev/null differ diff --git a/src/NadekoBot/Resources/images/dice/4.png b/src/NadekoBot/Resources/images/dice/4.png deleted file mode 100644 index b9be3c4f..00000000 Binary files a/src/NadekoBot/Resources/images/dice/4.png and /dev/null differ diff --git a/src/NadekoBot/Resources/images/dice/5.png b/src/NadekoBot/Resources/images/dice/5.png deleted file mode 100644 index c25c5752..00000000 Binary files a/src/NadekoBot/Resources/images/dice/5.png and /dev/null differ diff --git a/src/NadekoBot/Resources/images/dice/6.png b/src/NadekoBot/Resources/images/dice/6.png deleted file mode 100644 index 3bc4403a..00000000 Binary files a/src/NadekoBot/Resources/images/dice/6.png and /dev/null differ diff --git a/src/NadekoBot/Resources/images/dice/7.png b/src/NadekoBot/Resources/images/dice/7.png deleted file mode 100644 index 4041c73c..00000000 Binary files a/src/NadekoBot/Resources/images/dice/7.png and /dev/null differ diff --git a/src/NadekoBot/Resources/images/dice/8.png b/src/NadekoBot/Resources/images/dice/8.png deleted file mode 100644 index ff1e0ac3..00000000 Binary files a/src/NadekoBot/Resources/images/dice/8.png and /dev/null differ diff --git a/src/NadekoBot/Resources/images/dice/9.png b/src/NadekoBot/Resources/images/dice/9.png deleted file mode 100644 index ce17e20d..00000000 Binary files a/src/NadekoBot/Resources/images/dice/9.png and /dev/null differ diff --git a/src/NadekoBot/Resources/images/hidden.png b/src/NadekoBot/Resources/images/hidden.png deleted file mode 100644 index 11bcc55b..00000000 Binary files a/src/NadekoBot/Resources/images/hidden.png and /dev/null differ diff --git a/src/NadekoBot/Resources/images/rip.png b/src/NadekoBot/Resources/images/rip.png deleted file mode 100644 index 6225b171..00000000 Binary files a/src/NadekoBot/Resources/images/rip.png and /dev/null differ diff --git a/src/NadekoBot/Resources/images/rose_overlay.png b/src/NadekoBot/Resources/images/rose_overlay.png deleted file mode 100644 index 767dcd1a..00000000 Binary files a/src/NadekoBot/Resources/images/rose_overlay.png and /dev/null differ diff --git a/src/NadekoBot/_Extensions/Extensions.cs b/src/NadekoBot/_Extensions/Extensions.cs index e0d37a55..008fe97b 100644 --- a/src/NadekoBot/_Extensions/Extensions.cs +++ b/src/NadekoBot/_Extensions/Extensions.cs @@ -1,5 +1,6 @@ using Discord; using Discord.WebSocket; +using ImageProcessorCore; using System; using System.Collections.Generic; using System.IO; @@ -266,5 +267,28 @@ namespace NadekoBot.Extensions public static ulong GB(this ulong value) => value.MB() * 1000; public static string Unmention(this string str) => str.Replace("@", "ම"); + + public static Image Merge(this IEnumerable images) + { + var imgList = images.ToList(); + + var canvas = new Image(imgList.Sum(img => img.Width), imgList.Max(img => img.Height)); + + var canvasPixels = canvas.Lock(); + int offsetX = 0; + foreach (var img in imgList.Select(img=>img.Lock())) + { + for (int i = 0; i < img.Width; i++) + { + for (int j = 0; j < img.Height; j++) + { + canvasPixels[i + offsetX, j] = img[i, j]; + } + } + offsetX += img.Width; + } + + return canvas; + } } } \ No newline at end of file diff --git a/src/NadekoBot/project.json b/src/NadekoBot/project.json index 1aecd709..dd7c9f50 100644 --- a/src/NadekoBot/project.json +++ b/src/NadekoBot/project.json @@ -31,7 +31,8 @@ "Microsoft.EntityFrameworkCore": "1.0.0", "Microsoft.EntityFrameworkCore.Design": "1.0.0-preview2-final", "Microsoft.EntityFrameworkCore.Sqlite": "1.0.0", - "CoreCLR-NCalc": "2.1.0" + "CoreCLR-NCalc": "2.1.0", + "ImageProcessorCore": "1.0.0-alpha1039" }, "tools": { "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final" diff --git a/src/NadekoBot/project.lock.json b/src/NadekoBot/project.lock.json index 57023365..70619baf 100644 --- a/src/NadekoBot/project.lock.json +++ b/src/NadekoBot/project.lock.json @@ -146,6 +146,34 @@ "lib/netstandard1.3/Google.Apis.YouTube.v3.dll": {} } }, + "ImageProcessorCore/1.0.0-alpha1039": { + "type": "package", + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tools": "4.0.1", + "System.IO": "4.1.0", + "System.IO.Compression": "4.1.0", + "System.Linq": "4.1.0", + "System.Numerics.Vectors": "4.1.1", + "System.ObjectModel": "4.0.12", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime.CompilerServices.Unsafe": "4.0.0", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.InteropServices": "4.1.0", + "System.Runtime.Numerics": "4.0.1", + "System.Text.Encoding.Extensions": "4.0.11", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11", + "System.Threading.Tasks.Parallel": "4.0.1" + }, + "compile": { + "lib/netstandard1.1/ImageProcessorCore.dll": {} + }, + "runtime": { + "lib/netstandard1.1/ImageProcessorCore.dll": {} + } + }, "Libuv/1.9.0": { "type": "package", "dependencies": { @@ -2380,6 +2408,18 @@ "lib/portable-net45+win8+wp80+wpa81/_._": {} } }, + "System.Runtime.CompilerServices.Unsafe/4.0.0": { + "type": "package", + "dependencies": { + "System.Runtime": "4.1.0" + }, + "compile": { + "lib/netstandard1.0/System.Runtime.CompilerServices.Unsafe.dll": {} + }, + "runtime": { + "lib/netstandard1.0/System.Runtime.CompilerServices.Unsafe.dll": {} + } + }, "System.Runtime.Extensions/4.1.0": { "type": "package", "dependencies": { @@ -3371,6 +3411,16 @@ "lib/portable-net45+netcore45+wpa81+wp8/Google.Apis.YouTube.v3.xml" ] }, + "ImageProcessorCore/1.0.0-alpha1039": { + "sha512": "nNLCXniPRY+m59tIQRA71uQQGmbtL0GASzex7zIz0PH6M1/yHxgYtlXZQmeyfkJIrGhJmqJDlYwEu3aZxlTfHw==", + "type": "package", + "path": "ImageProcessorCore/1.0.0-alpha1039", + "files": [ + "ImageProcessorCore.1.0.0-alpha1039.nupkg.sha512", + "ImageProcessorCore.nuspec", + "lib/netstandard1.1/ImageProcessorCore.dll" + ] + }, "Libuv/1.9.0": { "sha512": "9Q7AaqtQhS8JDSIvRBt6ODSLWDBI4c8YxNxyCQemWebBFUtBbc6M5Vi5Gz1ZyIUlTW3rZK9bIr5gnVyv0z7a2Q==", "type": "package", @@ -7249,6 +7299,19 @@ "ref/xamarinwatchos10/_._" ] }, + "System.Runtime.CompilerServices.Unsafe/4.0.0": { + "sha512": "LDvjxLx2fkThOFo/SC+901fJrh5artALmgzeSqnVxzvFp4q3HO8BkeLyshPdcbs5zpN7Xh9G23M6sDhgIPbG9A==", + "type": "package", + "path": "System.Runtime.CompilerServices.Unsafe/4.0.0", + "files": [ + "System.Runtime.CompilerServices.Unsafe.4.0.0.nupkg.sha512", + "System.Runtime.CompilerServices.Unsafe.nuspec", + "ThirdPartyNotices.txt", + "dotnet_library_license.txt", + "lib/netstandard1.0/System.Runtime.CompilerServices.Unsafe.dll", + "lib/netstandard1.0/System.Runtime.CompilerServices.Unsafe.xml" + ] + }, "System.Runtime.Extensions/4.1.0": { "sha512": "CUOHjTT/vgP0qGW22U4/hDlOqXmcPq5YicBaXdUR2UiUoLwBT+olO6we4DVbq57jeX5uXH2uerVZhf0qGj+sVQ==", "type": "package", @@ -9037,6 +9100,7 @@ "Google.Apis.Customsearch.v1 >= 1.16.0.466", "Google.Apis.Urlshortener.v1 >= 1.15.0.138", "Google.Apis.YouTube.v3 >= 1.15.0.582", + "ImageProcessorCore >= 1.0.0-alpha1039", "Microsoft.EntityFrameworkCore >= 1.0.0", "Microsoft.EntityFrameworkCore.Design >= 1.0.0-preview2-final", "Microsoft.EntityFrameworkCore.Sqlite >= 1.0.0",