示例#1
0
        public async Task BotInfoAsync(ICommandContext ctx)
        {
            var embed = new EmbedBuilder
            {
                Title = "Status",
                Color = Color.Purple
            };

            embed.AddField("Latest version", Utils.ToDiscordTimestamp(new FileInfo(Assembly.GetEntryAssembly().Location).LastWriteTimeUtc, Utils.TimestampInfo.None), true);
            embed.AddField("Last command received", Utils.ToDiscordTimestamp(StaticObjects.LastMessage, Utils.TimestampInfo.TimeAgo), true);
            embed.AddField("Uptime", Utils.ToDiscordTimestamp(StaticObjects.Started, Utils.TimestampInfo.TimeAgo), true);
            embed.AddField("Guild count", StaticObjects.Client.Guilds.Count, true);

            var options = new ComponentBuilder();

            if (StaticObjects.IsBotOwner(ctx.User))
            {
                options.WithSelectMenu("delCache", StaticObjects.AllGameNames.Select(x => new SelectMenuOptionBuilder(x, StaticObjects.Db.GetCacheName(x))).ToList(), placeholder: "Select a game cache to delete (require bot restart)");
            }
            options.WithButton("Show Global Stats", "globalStats");

            await ctx.ReplyAsync(embed : embed.Build(), components : options.Build(), ephemeral : true);

            embed.AddField("Useful links",
#if NSFW_BUILD
                           " - [Source Code](https://github.com/Xwilarg/Sanara)\n" +
                           " - [Website](https://sanara.zirk.eu/)\n" +
#endif
                           " - [Invitation Link](https://discord.com/api/oauth2/authorize?client_id=" + StaticObjects.ClientId + "&scope=bot%20applications.commands)\n"
#if NSFW_BUILD
                           +
                           " - [Support Server](https://discordapp.com/invite/H6wMRYV)\n" +
                           " - [Top.gg](https://discordbots.org/bot/329664361016721408)"
#endif
                           );
            embed.AddField("Credits",
                           "Programming: [Zirk#0001](https://zirk.eu/)\n" +
                           "With the help of [TheIndra](https://theindra.eu/)\n"
#if NSFW_BUILD
                           +
                           "Profile Picture: [Uikoui](https://www.pixiv.net/en/users/11608780)"
#endif // TODO: Can prob use current pfp for SFW version
                           );

#if NSFW_BUILD
            // Get latests commits
            StringBuilder str  = new();
            var           json = JsonConvert.DeserializeObject <JArray>(await StaticObjects.HttpClient.GetStringAsync("https://api.github.com/repos/Xwilarg/Sanara/commits?per_page=5"));
            foreach (var elem in json)
            {
                var time = Utils.ToDiscordTimestamp(DateTime.ParseExact(elem["commit"]["author"]["date"].Value <string>(), "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture), Utils.TimestampInfo.None);
                str.AppendLine($"{time}: [{elem["commit"]["message"].Value<string>()}](https://github.com/Xwilarg/Sanara/commit/{elem["sha"].Value<string>()})");
            }
            embed.AddField("Latest changes", str.ToString());

            await ctx.ReplyAsync(embed : embed.Build(), components : options.Build());
#endif
        }