public async Task Help(params string[] args) { string avatarUrl = Context.Client.CurrentUser.GetAvatarUrl(); var helpEmbed = new HelpEmbed(avatarUrl); await Context.Channel.SendMessageAsync(embed : helpEmbed.Build()); }
public async Task HelpCommandAsync() { bool isAdmin = ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN); bool isMod = ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.MODERATOR) || isAdmin; HelpEmbed he = new HelpEmbed(Context, isMod, isAdmin); await he.Display(Context.User.GetOrCreateDMChannelAsync().Result); }
public async Task Help(string category = "") { await Context.Message.DeleteAsync(); HelpEmbed helpEmbeds = new HelpEmbed(_commandService.Modules); switch (category.ToLower()) { case "général": helpEmbeds.CurrentPage = 2; break; case "personnages": helpEmbeds.CurrentPage = 3; break; case "anima": helpEmbeds.CurrentPage = 4; break; case "l5r": helpEmbeds.CurrentPage = 5; break; case "audio": helpEmbeds.CurrentPage = 6; break; } var msg = await Context.Channel.SendMessageAsync(embed : helpEmbeds.GetCurrentPage().Build()); CommandHandlingService.HelpMessages.Add(msg.Id, helpEmbeds); await msg.AddReactionAsync(new Emoji("\U000025c0")); await msg.AddReactionAsync(new Emoji("\U000025b6")); }
public async Task RunAsync([Remainder] string Code = null) { if (Code == null) { var he = HelpEmbed.Build("run", MongoHelper.GetPrefix(Context.Guild.Id)); await ReplyAsync("", embed : he, messageReference : new MessageReference(Context.Message.Id), allowedMentions : new AllowedMentions(AllowedMentionTypes.None)); return; } string input = null; if (Code.Contains(",")) { await ReplyAsync("Please send a message containing the ASCII inputs for your code", messageReference : new MessageReference(Context.Message.Id), allowedMentions : new AllowedMentions(AllowedMentionTypes.None)); var msg = await NextMessageAsync(); if (msg == null) { await ReplyAsync("**Timeout**, please send the run command again to retry", messageReference : new MessageReference(Context.Message.Id), allowedMentions : new AllowedMentions(AllowedMentionTypes.None)); return; } input = msg.Content; } Interpreter.ConsoleOutput = false; int steps = 0; double time = 0; string output = ""; try { var t = Task.Run(() => Interpreter.Execute(Code, input)); if (!t.Wait(10000)) { await ReplyAsync("**TIMEOUT**\nExecution took too long", messageReference : new MessageReference(Context.Message.Id), allowedMentions : new AllowedMentions(AllowedMentionTypes.None)); return; } (steps, time, output) = t.Result; } catch (Exception ex) { await ReplyAsync(ex.Message, messageReference : new MessageReference(Context.Message.Id), allowedMentions : new AllowedMentions(AllowedMentionTypes.None)); return; } EmbedBuilder e = new EmbedBuilder() .WithColor(Config.EmbedColor) .WithCurrentTimestamp() .WithAuthor($"Steps: {steps} | Execution Time: {time}ms") .WithTitle("Finished Execution"); if (output.Length > 1500 && output.Length <= 1_000_000) { e.AddField("Output", "Output exceeded 1500 characters, so it will be included as an attachment"); await ReplyAsync(embed : e.Build(), messageReference : new MessageReference(Context.Message.Id), allowedMentions : new AllowedMentions(AllowedMentionTypes.None)); await Context.Channel.SendFileAsync(GenerateStreamFromString(output), "output.txt"); } else if (output.Length > 1_000_000) { e.AddField("Output", "Output exceeded 1MB and will not be sent"); await ReplyAsync(embed : e.Build(), messageReference : new MessageReference(Context.Message.Id), allowedMentions : new AllowedMentions(AllowedMentionTypes.None)); } if (output == "") { e.AddField("Output", "Your code didn't produce any output"); } else { e.AddField("Output", "```\n" + output.Replace("`", "`\u200b") + "```"); } await ReplyAsync(embed : e.Build(), messageReference : new MessageReference(Context.Message.Id), allowedMentions : new AllowedMentions(AllowedMentionTypes.None)); }
/*private async Task UpdateTrack(ControlPanel controlPanel, RestUserMessage message)//not used right now * { * Timer _timer = new Timer(async _ => * { * if(message == null) return; * try * { * await controlPanel.ModifyMessage(message); * } * catch (Exception ex) * { * Console.WriteLine(ex); * return; * } * }, * null, * TimeSpan.FromMilliseconds(5000), * TimeSpan.FromMilliseconds(5000)); * * }*/ private async Task ClientReadyAsync() { await _lavaNode.ConnectAsync(); helpEmbed = new HelpEmbed(_client.CurrentUser); }