public static int Main(string[] args) { if (HelpCommandHelper.CheckForHelpParam(args)) { Console.Write(HelpCommandHelper.GetHelpText()); return(0); } Uri inputDir = InputOutputDirectoriesCommandHelper.GetInputUriFromConsoleArgs(args); Uri outputDir = InputOutputDirectoriesCommandHelper.GetOutputUriFromConsoleArgs(args); if (!Directory.Exists(inputDir.LocalPath)) { Console.WriteLine("Wrong inputDir"); return(1); } if (!Directory.Exists(outputDir.LocalPath)) { Directory.CreateDirectory(outputDir.LocalPath); } List <string> fileNames = Directory.GetFiles(inputDir.LocalPath, "*_*", SearchOption.TopDirectoryOnly) .Select(Path.GetFileName).ToList(); Directory.SetCurrentDirectory(inputDir.LocalPath); List <string> exceptions = new List <string>(); int numberOfFiles = fileNames.Count; int currentNumber = 0; foreach (string name in fileNames) { try { string newName; using (Id3.Mp3 mp3 = new Id3.Mp3(name)) { Id3.Id3Tag tag = mp3.GetAllTags().First(); newName = Normalize($"{tag.Artists} - {tag.Title}.mp3"); } File.Copy(name, newName); string outPath = Path.Combine(outputDir.LocalPath, newName); if (File.Exists(outPath)) { outPath = Path.Combine(outputDir.LocalPath, $"{name}.mp3"); } Directory.Move(Path.Combine(inputDir.LocalPath, newName), outPath); Console.Clear(); Console.WriteLine($"{++currentNumber} / {numberOfFiles}"); } catch (Exception e) { exceptions.Add($"{name} - {e.Message}"); } } if (exceptions.Any()) { StringBuilder builder = new StringBuilder("Errors, which has occurred during the work"); foreach (string exception in exceptions) { builder.AppendLine(exception); } Console.WriteLine(builder.ToString()); } Console.WriteLine("Done."); return(0); }
public async Task Help(CommandContext ctx) { var interactivity = ctx.Client.GetInteractivity(); int i = 0; List <string> Cmds = new List <string>(); List <List <string> > c = new List <List <string> >(); var Commands = ctx.Client.GetCommandsNext(); foreach (KeyValuePair <string, Command> cmd in Commands.RegisteredCommands) { if (!cmd.Value.IsHidden) { Cmds.Add(cmd.Key); } } for (int j = 0; j < Cmds.Count; j += 5) { c.Add(Cmds.Skip(j).Take(j + 5).ToList()); } var Pages = Math.Ceiling(Cmds.Count / 5.0); var embed = new DiscordEmbedBuilder { Title = "Official server", Url = "https://discord.gg/kwcd9dq", Color = new DiscordColor(9043849) }.WithAuthor($"Page {i + 1}/{Pages}", null, ctx.Client.CurrentUser.AvatarUrl) .WithFooter($"PennyBot | Lilwiggy {DateTime.UtcNow.Year}"); foreach (string s in c[i]) { // Console.WriteLine(s); // Console.WriteLine(c[i]); embed.AddField(s, Commands.RegisteredCommands.Values.ToList().Find(x => x.Name == s).Description); } var m = await ctx.Channel.SendMessageAsync("", embed : embed); await m.CreateReactionAsync(DiscordEmoji.FromUnicode("⬅")); await m.CreateReactionAsync(DiscordEmoji.FromUnicode("➡")); var help = new HelpCommandHelper(); while (true) { var em = await interactivity.WaitForReactionAsync(e => e == DiscordEmoji.FromUnicode("➡") || e == DiscordEmoji.FromUnicode("⬅"), ctx.User, TimeSpan.FromMinutes(3)); if (em == null) { break; } if (em.Emoji == DiscordEmoji.FromUnicode("➡")) { if (i == Pages - 1) { i = 0; } else { i++; } } else if (em.Emoji == DiscordEmoji.FromUnicode("⬅")) { if (i == 0) { i = Convert.ToInt32(Pages) - 1; } else { i--; } } Console.WriteLine("hi"); await m.DeleteReactionAsync(em.Emoji, ctx.User); var emb = help.GetCommandsEmbed(ctx, i, m); Console.WriteLine(emb.Fields[0].Value); await m.ModifyAsync("", emb); } ; }