/// <summary> Send an embed with current server information. </summary> public async Task ServerInfoAsync(SocketCommandContext context) { //Get guilds custom prefix. //Sets prefix to - if the guild doesn't have a custom prefix var prefix = _botContext.GetGuildPrefix(context.Guild.Id); var memberCount = context.Guild.MemberCount; var serverId = context.Guild.Id; var serverName = context.Guild.Name; var serverOwner = context.Guild.Owner; var serverRegion = context.Guild.VoiceRegionId; EmbedFieldBuilder[] fields = { new EmbedFieldBuilder().WithName("Bot prefix:").WithValue($"`{prefix}`").WithIsInline(true), new EmbedFieldBuilder().WithName("Help command:").WithValue($"`{prefix}help`").WithIsInline(true), new EmbedFieldBuilder().WithName("Server name:").WithValue(serverName), new EmbedFieldBuilder().WithName("Server owner:").WithValue(serverOwner).WithIsInline(true), new EmbedFieldBuilder().WithName("Member count:").WithValue(memberCount).WithIsInline(true), new EmbedFieldBuilder().WithName("Server ID:").WithValue(serverId), new EmbedFieldBuilder().WithName("Server region:").WithValue(serverRegion).WithIsInline(true) }; await context.Channel.SendMessageAsync( embed : CustomFormats.CreateInfoEmbed($"{serverName} info", context.Guild.Description, new EmbedFooterBuilder().WithIconUrl(context.User.GetAvatarUrl()) .WithText($"Requested by: {context.User}"), context.Guild.IconUrl, fields)); }
/// <summary> Send an embed with the bot uptime. </summary> public static async Task GetBotInfoAsync(SocketCommandContext context) { var uptime = DateTime.Now.Subtract(Process.GetCurrentProcess().StartTime); var uptimeString = $"{uptime.Days} days, {uptime.Hours} hours and {uptime.Minutes} minutes"; var heapSize = Math.Round(GC.GetTotalMemory(true) / (1024.0 * 1024.0), 2) .ToString(CultureInfo.CurrentCulture); EmbedFieldBuilder[] fields = { new EmbedFieldBuilder().WithName("Uptime").WithValue(uptimeString), new EmbedFieldBuilder().WithName("Discord.NET version") .WithValue(DiscordConfig.Version), new EmbedFieldBuilder().WithName("Heap size").WithValue($"{heapSize} MB").WithIsInline(true), new EmbedFieldBuilder().WithName("Environment") .WithValue($"{RuntimeInformation.FrameworkDescription} {RuntimeInformation.OSArchitecture}") .WithIsInline(true), new EmbedFieldBuilder().WithName("Guilds").WithValue(context.Client.Guilds.Count), new EmbedFieldBuilder().WithName("Users").WithValue(context.Client.Guilds.Sum(x => x.MemberCount)) .WithIsInline(true), new EmbedFieldBuilder().WithName("Vote") .WithValue("[Top.gg](https://top.gg/bot/389534436099883008/vote)\n[Discord Bot List](https://discordbotlist.com/bots/cobra/upvote)") }; await context.Channel.SendMessageAsync(embed : CustomFormats.CreateInfoEmbed( $"Cobra v{Assembly.GetEntryAssembly()?.GetName().Version?.ToString(2)}", "", new EmbedFooterBuilder().WithText("Developed by Matcher#0183"), context.Client.CurrentUser.GetAvatarUrl(), fields)); }