예제 #1
0
        public async Task Command_GetAvatar(
            [Name("User")][Description("The user who you wish to get the avatar for.")]
            CachedMember target = null)
        {
            target ??= Context.Member;

            if (!Context.BotMember.GetPermissionsFor(Context.Channel as CachedTextChannel).SendMessages)
            {
                return;
            }

            await ReplyAsync(embed : new LocalEmbedBuilder()
                             .WithAuthor(target)
                             .WithColor(Context.Color)
                             .WithImageUrl(target.GetAvatarUrl())
                             .WithDescription($"{UrlHelper.CreateMarkdownUrl("128", target.GetAvatarUrl(size: 128))} | " +
                                              $"{UrlHelper.CreateMarkdownUrl("256", target.GetAvatarUrl(size: 256))} | " +
                                              $"{UrlHelper.CreateMarkdownUrl("1024", target.GetAvatarUrl(size: 1024))} | " +
                                              $"{UrlHelper.CreateMarkdownUrl("2048", target.GetAvatarUrl(size: 2048))}")
                             .Build());
        }
            private async Task SendMessageAsync(CachedMember member, string moderationType, string fromWhere, string?reason)
            {
                var embed = new LocalEmbedBuilder
                {
                    Color        = RiasUtilities.ErrorColor,
                    Title        = GetText(moderationType),
                    ThumbnailUrl = member.GetAvatarUrl()
                }.AddField(GetText(Localization.CommonUser), member, true)
                .AddField(GetText(Localization.CommonId), member.Id, true)
                .AddField(GetText(Localization.AdministrationModerator), Context.User, true);

                if (!string.IsNullOrEmpty(reason))
                {
                    embed.AddField(GetText(Localization.CommonReason), reason, true);
                }

                var channel = Context.Channel;
                var guildDb = await DbContext.GetOrAddAsync(x => x.GuildId == Context.Guild !.Id, () => new GuildsEntity { GuildId = Context.Guild !.Id });