예제 #1
0
        public async Task Avatar(CommandContext ctx, [Description("User to get avatar")] DiscordUser target)
        {
            await ctx.Channel.TriggerTypingAsync();

            await new ModernEmbedBuilder()
            {
                Title    = (await ctx.Lang("avatar.title")).Replace("{target}", target.Name()),
                ImageUrl = target.AvatarUrl ?? target.DefaultAvatarUrl,
                Color    = Program.Config.EmbedColor,
            }.Send(ctx.Channel);
        }
예제 #2
0
 public async Task User(CommandContext ctx, DiscordUser target = null)
 {
     target ??= ctx.User;
     var embed = new ModernEmbedBuilder
     {
         Title  = await ctx.Lang("user.title"),
         Fields =
         {
             ("Discord tag",                                  target.Name(true),                           inline : true),
             ("ID",                                           target.Id.ToString(),                        inline : true),
             (await ctx.Lang("user.registration"),
              target.CreationTimestamp.DateTime.ToString("g", CultureInfo.CreateSpecificCulture("pl-PL")),
              inline : false),
         },
예제 #3
0
        private static async Task Log(string emoji, string message, KuvuGuild kuvuGuild, DiscordChannel discordChannel, DiscordUser user, List <DuckField> fields = null, string url = null)
        {
            var embed = new ModernEmbedBuilder
            {
                Url       = url,
                Title     = $"{emoji} | {message}",
                Color     = Program.Config.EmbedColor,
                Timestamp = DuckTimestamp.Now,
                Fields    = fields
            };

            if (user != null)
            {
                embed.Author = ($"{user.Name()} | {user.Id}", null, user.AvatarUrl ?? user.DefaultAvatarUrl);
            }
            await embed.Send(discordChannel);
        }
예제 #4
0
        public async Task Ship(CommandContext ctx, [Description("User to ship")] DiscordUser target)
        {
            await ctx.Channel.TriggerTypingAsync();

            var randomMember = ctx.Guild.Members.Values.ToList()[new Random().Next(ctx.Guild.Members.Count)];

            using var httpClient = new HttpClient();

            using var targetAvatar = SKBitmap.Decode(await httpClient.GetStreamAsync(target.AvatarUrl));
            using var randomAvatar = SKBitmap.Decode(await httpClient.GetStreamAsync(randomMember.AvatarUrl));

            var dimensions = new SKImageInfo(375, 135);

            using var surface = SKSurface.Create(dimensions);
            var canvas = surface.Canvas;

            canvas.Clear(SKColors.Transparent);

            // Text styling
            var paint = new SKPaint
            {
                Color       = SKColors.White,
                IsAntialias = true,
                Style       = SKPaintStyle.Fill,
                TextSize    = 22,
                TextAlign   = SKTextAlign.Center,
                Typeface    = SKTypeface.FromFamilyName("Roboto")
            };

            // Draw text and images
            canvas.DrawBitmap(targetAvatar, SKRect.Create(37.5f, 0, 96, 96));
            canvas.DrawText($"{target.Name()}", 96f / 2f + 37.5f, 96 + 24, paint);

            canvas.DrawBitmap(HeartEmoji, SKRect.Create(37.5f + 96f + 30f, 27F, 48f, 48f));

            canvas.DrawBitmap(randomAvatar, SKRect.Create(37.5f + 96f + 30 + 48 + 28.5f, 0, 96, 96));
            canvas.DrawText($"{randomMember.Name()}", 96f / 2f + 37.5f + 96f + 30 + 48 + 28.5f, 96 + 24, paint);

            // Generate and send the image
            using var image = surface.Snapshot();
            using var data  = image.Encode(SKEncodedImageFormat.Webp, 100);
            await ctx.RespondWithFileAsync(fileData : data.AsStream(), fileName : "ship.webp");
        }