From 10145f3cae535fd1805a9ff446ea40cf2d890f87 Mon Sep 17 00:00:00 2001 From: Khionu Terabite Date: Tue, 6 Sep 2016 20:29:46 -0400 Subject: [PATCH] Delete WIP file --- .../Extensions/FindEntityExtensions.cs | 68 ------------------- 1 file changed, 68 deletions(-) diff --git a/src/Discord.Net/Extensions/FindEntityExtensions.cs b/src/Discord.Net/Extensions/FindEntityExtensions.cs index 9a2c276b3..8b1378917 100644 --- a/src/Discord.Net/Extensions/FindEntityExtensions.cs +++ b/src/Discord.Net/Extensions/FindEntityExtensions.cs @@ -1,69 +1 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -namespace Discord.Extensions -{ - public static class FindEntityExtensions - { - // Guilds - - public static async Task> FindUsersAsync(this IGuild guild, string name) - => (await guild.GetUsersAsync()).Where(x => distance(name, x.Username) < 5); - - public static IEnumerable FindRoles(this IGuild guild, string name) - => guild.Roles.Where(x => distance(name, x.Name) < 5); - - public static async Task> FindChannels(this IGuild guild, string name) - => (await guild.GetChannelsAsync()).Where(x => distance(name, x.Name) < 5); - - public static async Task> FindTextChannels(this IGuild guild, string name) - => (await guild.GetChannelsAsync()).Select(x => x as ITextChannel) - .Where(x => x != null).Where(x => distance(name, x.Name) < 5); - - public static async Task> FindVoiceChannels(this IGuild guild, string name) - => (await guild.GetChannelsAsync()).Select(x => x as IVoiceChannel) - .Where(x => x != null).Where(x => distance(name, x.Name) < 5); - - // Channels - - public static async Task> FindUsersAsync(this IChannel channel, string name) - => (await channel.GetUsersAsync()).Where(x => distance(name, x.Username) < 5); - - /// - /// Compute the distance between two strings. - /// Copied from DotNetPerls - /// - private static int distance(string s, string t) - { - int n = s.Length; - int m = t.Length; - int[,] d = new int[n + 1, m + 1]; - - if (n == 0) - return m; - - if (m == 0) - return n; - - for (int i = 0; i <= n; d[i, 0] = i++) { } - - for (int j = 0; j <= m; d[0, j] = j++) { } - - for (int i = 1; i <= n; i++) - { - for (int j = 1; j <= m; j++) - { - int cost = (t[j - 1] == s[i - 1]) ? 0 : 1; - - d[i, j] = Math.Min( - Math.Min(d[i - 1, j] + 1, d[i, j - 1] + 1), - d[i - 1, j - 1] + cost); - } - } - - return d[n, m]; - } - } -}