Ejemplo n.º 1
0
        public static object GetMessage(this E621Image image, ICommandContext context, bool forceString = false)
        {
            string message = $"`Score: 👍 {image.Score.Up} 👎 {image.Score.Down}` <{image.PostUrl}>";

            if (!image.ImageUrl.IsVideoFile())
            {
                if (forceString)
                {
                    message += $"\n{image.ImageUrl}";
                }
            }
            else
            {
                message += $"\n{image.ImageUrl} (Video)";
            }

            if (!image.ImageUrl.IsVideoFile() && !forceString)
            {
                return
                    (EmbedExtensions.FromImage(image.ImageUrl, EmbedExtensions.RandomEmbedColor(), context)
                     .WithDescription(message));
            }
            else
            {
                return(message);
            }
        }
Ejemplo n.º 2
0
        public static async Task <Embed> GetSummaryAsync(this IGuild guild, DiscordShardedClient client, ICommandContext context, Guild skuldguild = null)
        {
            using var Database = new SkuldDbContextFactory().CreateDbContext();
            var config = Database.Configurations.Find(SkuldAppContext.ConfigurationId);

            var botusers = await guild.RobotMembersAsync().ConfigureAwait(false);

            var humanusers = await guild.HumanMembersAsync().ConfigureAwait(false);

            var ratio = await guild.GetBotUserRatioAsync().ConfigureAwait(false);

            var afkchan = await guild.GetAFKChannelAsync().ConfigureAwait(false);

            var owner = await guild.GetOwnerAsync().ConfigureAwait(false);

            var userratio = await guild.GetBotUserRatioAsync().ConfigureAwait(false);

            var channels = await guild.GetChannelsAsync().ConfigureAwait(false);

            var afktimeout = guild.AFKTimeout % 3600 / 60;

            var embed =
                new EmbedBuilder()
                .AddFooter(context)
                .WithTitle(guild.Name)
                .AddAuthor(context.Client)
                .WithColor(EmbedExtensions.RandomEmbedColor())
                .AddInlineField("Users", $"Users: {humanusers.ToFormattedString()}\nBots: {botusers.ToFormattedString()}\nRatio: {ratio}%")
                .AddInlineField("Shard", client?.GetShardIdFor(guild))
                .AddInlineField("Verification Level", guild.VerificationLevel)
                .AddInlineField("Voice Region", guild.VoiceRegionId)
                .AddInlineField("Owner", $"{owner.Mention}")
                .AddInlineField("Text Channels", channels.Count(x => x.GetType() == typeof(SocketTextChannel)))
                .AddInlineField("Voice Channels", channels.Count(x => x.GetType() == typeof(SocketVoiceChannel)))
                .AddInlineField("AFK Timeout", afktimeout + " minutes")
                .AddInlineField("Default Notifications", guild.DefaultMessageNotifications)
                .AddInlineField("Created", guild.CreatedAt.ToDMYString() + "\t(DD/MM/YYYY)")
                .AddInlineField($"Emotes [{guild.Emotes.Count}]", $" Use `{skuldguild?.Prefix ?? config.Prefix}server-emojis` to view them")
                .AddInlineField($"Roles [{guild.Roles.Count}]", $" Use `{skuldguild?.Prefix ?? config.Prefix}server-roles` to view them");

            if (!string.IsNullOrEmpty(afkchan?.Name))
            {
                embed.AddInlineField("AFK Channel", $"[#{afkchan.Name}]({afkchan.JumpLink()})");
            }

            if (!string.IsNullOrEmpty(guild.IconUrl))
            {
                embed.WithThumbnailUrl(guild.IconUrl);
            }

            return(embed.Build());
        }
Ejemplo n.º 3
0
        public async Task WeebGif()
        {
            var gif = await Imghoard.GetImagesAsync();

            await
            EmbedExtensions
            .FromImage(
                gif.Images.Random().Url,
                EmbedExtensions.RandomEmbedColor(),
                Context
                )
            .QueueMessageAsync(Context)
            .ConfigureAwait(false);
        }
Ejemplo n.º 4
0
        public async Task WeebGif()
        {
            var gif = await SysExClient
                      .GetWeebReactionGifAsync()
                      .ConfigureAwait(false);

            await
            EmbedExtensions
            .FromImage(
                gif,
                EmbedExtensions.RandomEmbedColor(),
                Context
                )
            .QueueMessageAsync(Context)
            .ConfigureAwait(false);
        }
Ejemplo n.º 5
0
        public async Task APOD()
        {
            NASAClient NASAClient = SkuldApp.Services.GetRequiredService <NASAClient>();
            var        aPOD       = await NASAClient.GetAPODAsync().ConfigureAwait(false);

            DogStatsd.Increment("web.get");

            if (aPOD.HD is not null && (!aPOD.HD.IsVideoFile() || (!aPOD.Url.OriginalString.Contains("youtube") || !aPOD.Url.OriginalString.Contains("youtu.be"))))
            {
                await new EmbedBuilder()
                .WithColor(EmbedExtensions.RandomEmbedColor())
                .WithTitle(aPOD.Title)
                .WithUrl("https://apod.nasa.gov/")
                .WithImageUrl(aPOD.HD.OriginalString)
                .WithTimestamp(Convert.ToDateTime(aPOD.Date, CultureInfo.InvariantCulture))
                .WithAuthor(aPOD.CopyRight)
                .QueueMessageAsync(Context).ConfigureAwait(false);
            }
Ejemplo n.º 6
0
        public async Task ShardInfo(int shardid)
        {
            var shard = Context.Client.GetShard(shardid);
            var embed = new EmbedBuilder
            {
                Author = new EmbedAuthorBuilder
                {
                    Name    = $"Shard ID: {shardid}",
                    IconUrl = shard.CurrentUser.GetAvatarUrl()
                },
                Footer = new EmbedFooterBuilder
                {
                    Text = "Generated at"
                },
                Timestamp = DateTime.Now,
                Color     = EmbedExtensions.RandomEmbedColor()
            };

            embed.AddInlineField("Guilds", shard.Guilds.Count.ToString());
            embed.AddInlineField("Status", shard.ConnectionState);
            embed.AddInlineField("Latency", shard.Latency + "ms");
            embed.AddField("Game", shard.Activity.Name);
            await embed.Build().QueueMessageAsync(Context).ConfigureAwait(false);
        }