public async Task GuildInfo() { DateTime startTime = DateTime.Now; var orderedRoles = Context.Guild.Roles.Where(x => x.IsMentionable).ToList().OrderByDescending(x => x.Permissions.ToString()); EmbedBuilder embedBuilder = new EmbedBuilder(); EmbedService.BuildFeedbackEmbed(embedBuilder); embedBuilder.Title = $"{Context.Guild.Name.ToString()} Info"; embedBuilder.Description = $"{Context.Guild.DefaultChannel.Topic.SpliceText(50)}\n\n{"Roles:".Bold()} "; foreach (IRole role in orderedRoles) { embedBuilder.AppendEmbedDescription($"{role.Mention} ({Context.Guild.Users.Where(x => x.Roles.Contains(role)).Count().ToString().Bold()}), "); } using (BotDBContext DBContext = DBFactory.Create <BotDBContext>()) { embedBuilder.AddField(x => { x.Name = ":desktop: Default Channel"; x.Value = Context.Guild.DefaultChannel.Name; x.IsInline = true; }); embedBuilder.AddField(x => { x.Name = ":man: Users"; x.Value = Context.Guild.MemberCount; x.IsInline = true; }); embedBuilder.AddField(x => { x.Name = ":abc: Text Channels"; x.Value = Context.Guild.TextChannels.Count(); x.IsInline = true; }); embedBuilder.AddField(x => { x.Name = ":speaking_head: Voice Channels"; x.Value = Context.Guild.VoiceChannels.Count(); x.IsInline = true; }); embedBuilder.AddField(x => { x.Name = ":love_letter: Stored Messages"; x.Value = DBContext.Messages.FromSql("SELECT Messages.Id, Messages.ChannelId, TextChannels.GuildId FROM Messages INNER JOIN TextChannels ON TextChannels.Id = Messages.ChannelId WHERE TextChannels.GuildId = {0}", Context.Guild.Id.ToString()).AsNoTracking().Count().ToString(); x.IsInline = true; }); //embedBuilder.AddField(x => { x.Name = ":love_letter: Stored Messages"; x.Value = DBContext.Messages.Where(y => Context.Guild.Channels.FirstOrDefault(z => z.Id.ToString() == y.ChannelId) != null).Count().ToString(); x.IsInline = true; }); embedBuilder.AddField(x => { x.Name = ":camera_with_flash: Multifactor Authentication Level"; x.Value = Enum.GetName(typeof(MfaLevel), Context.Guild.MfaLevel); x.IsInline = true; }); embedBuilder.AddField(x => { x.Name = ":tools: Commands Executed"; x.Value = DBContext.CommandLogs.Where(y => y.GuildId == Context.Guild.Id.ToString()).Count().ToString().Number().Bold(); x.IsInline = true; }); } embedBuilder.WithThumbnailUrl(Context.Guild.IconUrl); embedBuilder.WithFooter(x => { x.Text = $"⏰ Generated in: {Math.Round((DateTime.Now.Subtract(startTime).TotalMilliseconds)).ToString()}ms"; }); await ReplyAsync("", embed : embedBuilder.Build()); }
public async Task Help() { EmbedBuilder embedBuilder = new EmbedBuilder(); embedBuilder.WithColor(new Color(100, 175, 45)); embedBuilder.WithTitle(":computer: Modules & Commands"); embedBuilder.Description = "Here's a list of the modules and their commands.\nFor more detailed help, **visit**: http://jeezy.click\nThis message will expire in a minute.\n\n"; var modules = Commands.Modules; int cmdCount = 0; foreach (var module in modules) { string moduleStr = $"{module.Name.Replace("Module", " Module").Bold()}: "; foreach (var cmd in module.Commands.GroupBy(x => x.Aliases[0]).Select(x => x.First())) { cmdCount++; moduleStr += $"{cmd.Name}, "; } moduleStr = moduleStr.Substring(0, moduleStr.Length - 2); moduleStr += "\n"; if (module.Name != "MisakaModuleBase") { embedBuilder.AppendEmbedDescription(moduleStr); } } embedBuilder.WithFooter(x => { x.Text = $"{Commands.Modules.Where(y => y.Name != "MisakaModuleBase").Count()} Modules, {cmdCount} Commands."; }); await ReplyAsync("", embed : embedBuilder.Build(), lifeTime : MathService.TimeUnitToMilli(TimeUnit.Minutes, 1)); }
private async Task TriggerBadArgEmbed(string commandExecuted, SocketCommandContext context, string finalPrefix) { EmbedService embedService = Provider.GetService <EmbedService>(); CommandInfo cmd = Commands.FindInfoByName(commandExecuted); if (cmd.Parameters.Count == 0) { await context.Channel.SendMessageAsync("", embed : Provider.GetService <EmbedService>().MakeFailFeedbackEmbed("That command takes no arguments."), lifeTime : Config.FeedbackMessageLifeTime); return; } EmbedBuilder badArgEmbed = new EmbedBuilder(); string errorString = $"You used the wrong amount of arguments.\nCheck below for the correct syntax.\n\n{finalPrefix}{cmd.Name.Bold()}\n"; embedService.BuildFailEmbed(badArgEmbed); badArgEmbed.AppendEmbedDescription(errorString); foreach (var arg in cmd.Parameters) { badArgEmbed.AddField(x => { x.Name = $"{arg.Name} - {arg.Type.ToString().Bold()}{(arg.IsOptional ? " - Optional" : "")}"; x.Value = arg.Summary; }); } await context.Channel.SendMessageAsync("", embed : badArgEmbed, lifeTime : Config.FeedbackMessageLifeTime); }