コード例 #1
0
        public async Task Info(string fromHash = null)
        {
            if (Permissions.IsAdministratorOrBotOwner(Context))
            {
                var buildInfo = await CheckForUpdates(false).ConfigureAwait(false);

                if (buildInfo.LocalHash != null && buildInfo.RemoteHash != null)
                {
                    var embedBuilder = new EmbedBuilder()
                                       .WithTitle($"\\{EmotesHelper.GetString(Emotes.HammerPick)} Build Info")
                                       .WithOkColour(Context.Guild)
                    ;

                    var updateList = await UpdateList(fromHash, false).ConfigureAwait(false);

                    if (updateList.Count() > 0)
                    {
                        embedBuilder.WithDescription($"You are {updateList.Count()} commits behind.").WithFields(
                            updateList.Select(x => new EmbedFieldBuilder().WithName(x.Name).WithValue(x.Value))
                            );
                    }
                    else
                    {
                        embedBuilder.WithDescription($"Ditto is running on the last available version \\{EmotesHelper.GetString(Emotes.HeavyCheckMark)}");
                    }

                    await Context.Channel.EmbedAsync(embedBuilder, options : new RequestOptions()
                    {
                        RetryMode = RetryMode.RetryRatelimit
                    }).ConfigureAwait(false);
                }
                else
                {
                    await Context.ApplyResultReaction(CommandResult.Failed).ConfigureAwait(false);
                }
            }
            else
            {
                await Context.ApplyResultReaction(CommandResult.FailedUserPermission).ConfigureAwait(false);
            }
        }