示例#1
0
        public async Task TwitchSearch([Remainder] string twitchStreamer)
        {
            var TwitchClient = SkuldApp.Services.GetRequiredService <ITwitchAPI>();

            var userMatches = await TwitchClient.V5.Users.GetUserByNameAsync(twitchStreamer).ConfigureAwait(false);

            if (userMatches.Matches.Any())
            {
                var user = userMatches.Matches.FirstOrDefault();

                var channel = await TwitchClient.V5.Channels.GetChannelByIDAsync(user.Id).ConfigureAwait(false);

                var streams = await TwitchClient.V5.Streams.GetStreamByUserAsync(user.Id).ConfigureAwait(false);

                await(user.GetEmbed(channel, streams.Stream)).QueueMessageAsync(Context).ConfigureAwait(false);
            }
            else
            {
                await
                EmbedExtensions
                .FromError($"Couldn't find user `{twitchStreamer}`. Check your spelling and try again", Context)
                .QueueMessageAsync(Context)
                .ConfigureAwait(false);
            }
        }
示例#2
0
        public async Task LewdKitsune()
        {
            var kitsu = await SysExClient.GetLewdKitsuneAsync().ConfigureAwait(false);

            StatsdClient.DogStatsd.Increment("web.get");
            await EmbedExtensions.FromMessage(Context).WithImageUrl(kitsu).QueueMessageAsync(Context).ConfigureAwait(false);
        }
示例#3
0
文件: Lewd.cs 项目: Multivax/Skuld
        public async Task Safebooru(params string[] tags)
        {
            tags
            .ContainsBlacklistedTags()
            .IsSuccessAsync(x => LewdModule.ContainsIllegalTags(x.Data, Context))
            .IsErrorAsync(async x =>
            {
                var posts = await SafebooruClient
                            .GetImagesAsync(tags)
                            .ConfigureAwait(false);

                DogStatsd.Increment("web.get");

                if (posts is null || !posts.Any())
                {
                    await EmbedExtensions
                    .FromError(
                        "Couldn't find an image.",
                        Context
                        )
                    .QueueMessageAsync(Context)
                    .ConfigureAwait(false);
                    return;
                }

                var post = posts.Where(x => !x.Tags.ContainsBlacklistedTags().Successful).Random();

                await post
                .GetMessage(Context)
                .QueueMessageAsync(Context)
                .ConfigureAwait(false);
            });
        }
示例#4
0
        public async Task KonaChan(params string[] tags)
        {
            if (tags.Count() > 6)
            {
                await $"Cannot process more than 6 tags at a time".QueueMessageAsync(Context).ConfigureAwait(false);
                return;
            }
            tags
            .ContainsBlacklistedTags()
            .IsSuccessAsync(x => containsIllegalTags(x.Data, tags, Context))
            .IsErrorAsync(async x =>
            {
                var posts = await KonaChanClient.GetImagesAsync(tags).ConfigureAwait(false);
                StatsdClient.DogStatsd.Increment("web.get");

                if (posts == null || !posts.Any())
                {
                    await EmbedExtensions.FromError("Couldn't find an image.", Context).QueueMessageAsync(Context).ConfigureAwait(false);
                    return;
                }

                var post = posts.Where(x => !x.Tags.ContainsBlacklistedTags().Successful).RandomValue();

                await post.GetMessage(Context).QueueMessageAsync(Context).ConfigureAwait(false);
            }
                          );
        }
示例#5
0
        public async Task Bean(IGuildUser user, [Remainder] string reason = null)
        {
            using var Database = new SkuldDbContextFactory().CreateDbContext();

            var usr = Database.Users.Find(user.Id);

            if (usr.Flags.IsBitSet(DiscordUtilities.Banned))
            {
                usr.Flags    -= DiscordUtilities.Banned;
                usr.BanReason = null;
                await
                EmbedExtensions.FromSuccess(SkuldAppContext.GetCaller(), $"Un-beaned {user.Mention}", Context)
                .QueueMessageAsync(Context).ConfigureAwait(false);
            }
            else
            {
                if (reason == null)
                {
                    await
                    EmbedExtensions.FromError($"{nameof(reason)} needs a value", Context)
                    .QueueMessageAsync(Context).ConfigureAwait(false);

                    return;
                }
                usr.Flags    += DiscordUtilities.Banned;
                usr.BanReason = reason;
                await
                EmbedExtensions.FromSuccess(SkuldAppContext.GetCaller(), $"Beaned {user.Mention} for reason: `{reason}`", Context)
                .QueueMessageAsync(Context).ConfigureAwait(false);
            }

            await Database.SaveChangesAsync().ConfigureAwait(false);
        }
示例#6
0
        public async Task Profile([Remainder] IGuildUser user = null)
        {
            using var Database = new SkuldDbContextFactory().CreateDbContext();

            if (user is not null && (user.IsBot || user.IsWebhook))
            {
                await EmbedExtensions.FromError(DiscordUtilities.NoBotsString, Context).QueueMessageAsync(Context).ConfigureAwait(false);

                return;
            }

            if (user is null)
            {
                user = Context.User as IGuildUser;
            }

            await Database.InsertOrGetUserAsync(user).ConfigureAwait(false);

            var profileImage = await ApiClient.GetProfileCardAsync(Context.User.Id, Context.Guild.Id);

            if (profileImage is not null)
            {
                await "".QueueMessageAsync(Context, filestream: profileImage, filename: "image.png").ConfigureAwait(false);
            }
        }
示例#7
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);
            }
        }
示例#8
0
        public async Task LMGTFY([Remainder] string query)
        {
            using var Database = new SkuldDbContextFactory().CreateDbContext();

            var prefix = (await Database.InsertOrGetGuildAsync(Context.Guild).ConfigureAwait(false)).Prefix ?? Configuration.Prefix;

            string url = "https://lmgtfy.com/";

            var firstPart = query.Split(" ")[0];

            url = (firstPart.ToLowerInvariant()) switch
            {
                "b" or "bing" => url + "?s=b&q=" + query.ReplaceFirst(firstPart, "").Replace(" ", "%20"),
                "y" or "yahoo" => url + "?s=y&q=" + query.ReplaceFirst(firstPart, "").Replace(" ", "%20"),
                "a" or "aol" => url + "?a=b&q=" + query.ReplaceFirst(firstPart, "").Replace(" ", "%20"),
                "k" or "ask" => url + "?k=b&q=" + query.ReplaceFirst(firstPart, "").Replace(" ", "%20"),
                "d" or "duckduckgo" or "ddg" => url + "?s=d&q=" + query.ReplaceFirst(firstPart, "").Replace(" ", "%20"),
                "g" or "google" => url + "?s=g&q=" + query.ReplaceFirst(firstPart, "").Replace(" ", "%20"),
                _ => url + "?q=" + query.Replace(" ", "%20"),
            };

            if (url != "https://lmgtfy.com/")
            {
                await url.QueueMessageAsync(Context).ConfigureAwait(false);
            }
            else
            {
                await EmbedExtensions.FromError($"Ensure your parameters are correct, example: `{prefix}lmgtfy g How to use lmgtfy`", Context).QueueMessageAsync(Context).ConfigureAwait(false);

                StatsdClient.DogStatsd.Increment("commands.errors", 1, 1, new[] { "generic" });
            }
        }
示例#9
0
        public async Task HelpRequest()
        {
            var embed = EmbedExtensions.CreateEmbed("Help request",
                                                    _localization.GetMessage("Help request title") + "\n\n" +
                                                    _localization.GetMessage("Help request", _prefix));

            await ReplyAsync("", false, embed);
        }
示例#10
0
        public async Task HelpAutoRole()
        {
            var embed = EmbedExtensions.CreateEmbed("Help dynamicrole",
                                                    _localization.GetMessage("Help dynamicrole title") + "\n\n" +
                                                    _localization.GetMessage("Help dynamicrole", _prefix));

            await ReplyAsync("", false, embed);
        }
示例#11
0
        public async Task HelpPermaChannel()
        {
            var embed = EmbedExtensions.CreateEmbed("Help permachannel",
                                                    _localization.GetMessage("Help permachannel title") + "\n\n" +
                                                    _localization.GetMessage("Help permachannel", _prefix));

            await ReplyAsync("", false, embed);
        }
示例#12
0
        public async Task HelpCommand()
        {
            var embed = EmbedExtensions.CreateEmbed("Help command",
                                                    _localization.GetMessage("Help command title") + "\n\n" +
                                                    _localization.GetMessage("Help command", _prefix) + "\n" +
                                                    _localization.GetMessage("Help command admin", _prefix));

            await ReplyAsync("", false, embed);
        }
示例#13
0
        public async Task PickCommand([Remainder] string message)
        {
            var options = message.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            var embed   = EmbedExtensions.CreateEmbed(_localization.GetMessage("Pick default", Context.User.Username),
                                                      options.GetRandomItem(),
                                                      new Color(255, 255, 0));

            await ReplyAsync("", false, embed);
        }
示例#14
0
        public async Task SellKey(Guid key)
        {
            using var Database = new SkuldDbContextFactory().CreateDbContext();

            if (Database.DonatorKeys.ToList().Any(x => x.KeyCode == key))
            {
                var dbKey = Database.DonatorKeys.ToList().FirstOrDefault(x => x.KeyCode == key);
                if (dbKey.Redeemed)
                {
                    await
                    EmbedExtensions
                    .FromError("Donator Module",
                               "Can't sell a redeemed key",
                               Context)
                    .QueueMessageAsync(Context)
                    .ConfigureAwait(false);
                }
                else
                {
                    Database.DonatorKeys.Remove(dbKey);
                    await Database.SaveChangesAsync().ConfigureAwait(false);

                    var usr = await Database.InsertOrGetUserAsync(Context.User).ConfigureAwait(false);

                    TransactionService.DoTransaction(new TransactionStruct
                    {
                        Amount   = 25000,
                        Receiver = usr
                    });

                    await Database.SaveChangesAsync().ConfigureAwait(false);

                    await
                    EmbedExtensions
                    .FromSuccess("Donator Module",
                                 $"You just sold your donator key for {SkuldApp.MessageServiceConfig.MoneyIcon}{25000.ToFormattedString()}",
                                 Context)
                    .QueueMessageAsync(Context)
                    .ConfigureAwait(false);

                    DogStatsd.Increment("donatorkeys.sold");
                }
            }
            else
            {
                await
                EmbedExtensions
                .FromError("Donator Module",
                           "Key doesn't exist",
                           Context)
                .QueueMessageAsync(Context)
                .ConfigureAwait(false);
            }
        }
示例#15
0
        public async Task SubReddit(string subreddit)
        {
            var channel = (ITextChannel)Context.Channel;

            var subReddit = await Social.GetSubRedditAsync(subreddit).ConfigureAwait(false);

            await
            EmbedExtensions.FromMessage("https://reddit.com/" + subreddit, subReddit.Data.Posts.PaginatePosts(channel, 25)[0], Context)
            .WithColor(Color.Blue)
            .QueueMessageAsync(Context).ConfigureAwait(false);
        }
示例#16
0
        public async Task GetSearch(string platform, [Remainder] string query)
        {
            platform = platform.ToLowerInvariant();
            if (platform == "google" || platform == "g")
            {
                await $"🔍 Searching Google for: {query}".QueueMessageAsync(Context).ConfigureAwait(false);
                var result = await SearchClient.SearchGoogleAsync(query).ConfigureAwait(false);

                if (result == null)
                {
                    await EmbedExtensions.FromError($"I couldn't find anything matching: `{query}`, please try again.", Context).QueueMessageAsync(Context).ConfigureAwait(false);

                    return;
                }

                var item1 = result.FirstOrDefault();
                var item2 = result.ElementAt(1);
                var item3 = result.LastOrDefault();

                string desc = "I found this:\n" +
                              $"**{item1.Title}**\n" +
                              $"<{item1.Link}>\n\n" +
                              "__**Also Relevant**__\n" +
                              $"**{item2.Title}**\n<{item2.Link}>\n\n" +
                              $"**{item3.Title}**\n<{item3.Link}>\n\n" +
                              "If I didn't find what you're looking for, use this link:\n" +
                              $"https://google.com/search?q={query.Replace(" ", "%20")}";

                await
                new EmbedBuilder()
                .WithAuthor(new EmbedAuthorBuilder()
                            .WithName($"Google search for: {query}")
                            .WithIconUrl("https://upload.wikimedia.org/wikipedia/commons/0/09/IOS_Google_icon.png")
                            .WithUrl($"https://google.com/search?q={query.Replace(" ", "%20")}")
                            )
                .AddFooter(Context)
                .WithDescription(desc)
                .QueueMessageAsync(Context).ConfigureAwait(false);
            }
            if (platform == "youtube" || platform == "yt")
            {
                await $"🔍 Searching Youtube for: {query}".QueueMessageAsync(Context).ConfigureAwait(false);
                var result = await SearchClient.SearchYoutubeAsync(query).ConfigureAwait(false);

                await result.QueueMessageAsync(Context).ConfigureAwait(false);
            }
            if (platform == "imgur")
            {
                await "🔍 Searching Imgur for: {query}".QueueMessageAsync(Context).ConfigureAwait(false);
                var result = await SearchClient.SearchImgurAsync(query).ConfigureAwait(false);

                await result.QueueMessageAsync(Context).ConfigureAwait(false);
            }
        }
示例#17
0
        public async Task RedeemKey(Guid key)
        {
            using var Database = new SkuldDbContextFactory().CreateDbContext();

            if (Database.DonatorKeys.ToList().Any(x => x.KeyCode == key))
            {
                var dbKey = Database.DonatorKeys.ToList().FirstOrDefault(x => x.KeyCode == key);
                if (dbKey.Redeemed)
                {
                    await
                    EmbedExtensions
                    .FromError("Donator Module",
                               "Key already redeemed",
                               Context)
                    .QueueMessageAsync(Context)
                    .ConfigureAwait(false);
                }
                else
                {
                    dbKey.Redeemed     = true;
                    dbKey.Redeemer     = Context.User.Id;
                    dbKey.RedeemedWhen = DateTime.UtcNow.ToEpoch();

                    await Database.SaveChangesAsync().ConfigureAwait(false);

                    var usr = await Database.InsertOrGetUserAsync(Context.User).ConfigureAwait(false);

                    usr.Flags += DiscordUtilities.BotDonator;

                    await Database.SaveChangesAsync().ConfigureAwait(false);

                    await
                    EmbedExtensions
                    .FromSuccess("Donator Module",
                                 "You are now a donator",
                                 Context)
                    .QueueMessageAsync(Context)
                    .ConfigureAwait(false);

                    DogStatsd.Increment("donatorkeys.redeemed");
                }
            }
            else
            {
                await
                EmbedExtensions
                .FromError("Donator Module",
                           "Key doesn't exist",
                           Context)
                .QueueMessageAsync(Context)
                .ConfigureAwait(false);
            }
        }
示例#18
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());
        }
示例#19
0
        public async Task Prestige()
        {
            using var Database = new SkuldDbContextFactory().CreateDbContext();

            var usr = await Database.InsertOrGetUserAsync(Context.User).ConfigureAwait(false);

            var nextPrestige = usr.PrestigeLevel + 1;

            var xp = Database.UserXp.ToList().Where(x => x.UserId == usr.Id);

            ulong globalLevel = 0;

            xp.ToList().ForEach(x =>
            {
                globalLevel += x.Level;
            });

            if (globalLevel > PrestigeRequirement * nextPrestige)
            {
                await
                EmbedExtensions.FromInfo("Prestige Corner", "Please respond with y/n to confirm you want to prestige\n\n**__PLEASE NOTE__**\nThis will remove **ALL** experience gotten in every server with experience enabled", Context)
                .QueueMessageAsync(Context)
                .ConfigureAwait(false);

                var next = await NextMessageAsync().ConfigureAwait(false);

                try
                {
                    if (next.Content.ToBool())
                    {
                        Database.UserXp.RemoveRange(Database.UserXp.ToList().Where(x => x.UserId == Context.User.Id));
                        await Database.SaveChangesAsync().ConfigureAwait(false);

                        usr.PrestigeLevel = usr.PrestigeLevel.Add(1);

                        await Database.SaveChangesAsync().ConfigureAwait(false);
                    }
                }
                catch
                {
                    DogStatsd.Increment("commands.errors", 1, 1, new[] { "err:parse-fail" });
                }
            }
            else
            {
                await
                EmbedExtensions.FromInfo("Prestige Corner", $"You lack the amount of levels required to prestige. For your prestige level ({usr.PrestigeLevel}), it is: {PrestigeRequirement * nextPrestige}", Context)
                .QueueMessageAsync(Context)
                .ConfigureAwait(false);
            }
        }
示例#20
0
文件: Weeb.cs 项目: Multivax/Skuld
        public async Task WeebGif()
        {
            var gif = await Imghoard.GetImagesAsync();

            await
            EmbedExtensions
            .FromImage(
                gif.Images.Random().Url,
                EmbedExtensions.RandomEmbedColor(),
                Context
                )
            .QueueMessageAsync(Context)
            .ConfigureAwait(false);
        }
示例#21
0
        public async Task LewdNeko()
        {
            var neko = await NekosLifeClient.GetAsync(NekoImageType.LewdNeko).ConfigureAwait(false);

            StatsdClient.DogStatsd.Increment("web.get");
            if (neko != null)
            {
                await EmbedExtensions.FromImage(neko, Color.Purple, Context).QueueMessageAsync(Context).ConfigureAwait(false);
            }
            else
            {
                await EmbedExtensions.FromError("Hmmm <:Thunk:350673785923567616> I got an empty response. Try again.", Context).QueueMessageAsync(Context).ConfigureAwait(false);
            }
        }
示例#22
0
        public async Task SendPokemonAsync(PokemonSpecies pokemon, string group)
        {
            if (pokemon is null)
            {
                StatsdClient.DogStatsd.Increment("commands.errors", 1, 1, new string[] { "generic" });

                await
                EmbedExtensions.FromError("This pokemon doesn't exist. Please try again.", Context)
                .QueueMessageAsync(Context)
                .ConfigureAwait(false);
            }
            else
            {
                switch (group.ToLowerInvariant())
                {
                case "stat":
                case "stats":
                    await(await pokemon.GetEmbedAsync(PokemonDataGroup.Stats).ConfigureAwait(false)).QueueMessageAsync(Context).ConfigureAwait(false);
                    break;

                case "abilities":
                case "ability":
                    await(await pokemon.GetEmbedAsync(PokemonDataGroup.Abilities).ConfigureAwait(false)).QueueMessageAsync(Context).ConfigureAwait(false);
                    break;

                case "helditems":
                case "hitems":
                case "hitem":
                case "items":
                    await(await pokemon.GetEmbedAsync(PokemonDataGroup.HeldItems).ConfigureAwait(false)).QueueMessageAsync(Context).ConfigureAwait(false);
                    break;

                case "move":
                case "moves":
                    await(await pokemon.GetEmbedAsync(PokemonDataGroup.Moves).ConfigureAwait(false)).QueueMessageAsync(Context).ConfigureAwait(false);
                    break;

                case "games":
                case "game":
                    await(await pokemon.GetEmbedAsync(PokemonDataGroup.Games).ConfigureAwait(false)).QueueMessageAsync(Context).ConfigureAwait(false);
                    break;

                case "default":
                default:
                    await(await pokemon.GetEmbedAsync(PokemonDataGroup.Default).ConfigureAwait(false)).QueueMessageAsync(Context).ConfigureAwait(false);
                    break;
                }
            }
        }
示例#23
0
        public async Task SetMoney(IGuildUser user, ulong amount)
        {
            using var Database = new SkuldDbContextFactory().CreateDbContext();

            var usr = await Database.InsertOrGetUserAsync(user).ConfigureAwait(false);

            usr.Money = amount;

            await Database.SaveChangesAsync().ConfigureAwait(false);

            await EmbedExtensions.FromSuccess(
                $"Set money of {user.Mention} to {usr.Money}",
                Context).QueueMessageAsync(Context)
            .ConfigureAwait(false);
        }
示例#24
0
        private async Task SendDM(IUser user, string message, string title = "")
        {
            try
            {
                var channel = await user.GetOrCreateDMChannelAsync();

                await channel.SendMessageAsync("", false, EmbedExtensions.CreateEmbed(title, message));

                await _logs.Write("Announcement", $"{user.Username}({user.Id}) - {message}");
            }
            catch (HttpException)
            {
                await _logs.Write("Announcement", $"Could not send announcement to {user.Username}({user.Id}).");
            }
        }
示例#25
0
        public async Task GrantExp(ulong amount, [Remainder] IGuildUser user = null)
        {
            if (user == null)
            {
                user = Context.Guild.GetUser(Context.User.Id);
            }

            using var Database = new SkuldDbContextFactory().CreateDbContext();

            var usr = await Database.InsertOrGetUserAsync(user).ConfigureAwait(false);

            await usr.GrantExperienceAsync(amount, Context, ExperienceService.DefaultAction, true).ConfigureAwait(false);

            await EmbedExtensions.FromSuccess($"Gave {user.Mention} {amount.ToFormattedString()}xp", Context).QueueMessageAsync(Context).ConfigureAwait(false);
        }
示例#26
0
        public async Task WeebGif()
        {
            var gif = await SysExClient
                      .GetWeebReactionGifAsync()
                      .ConfigureAwait(false);

            await
            EmbedExtensions
            .FromImage(
                gif,
                EmbedExtensions.RandomEmbedColor(),
                Context
                )
            .QueueMessageAsync(Context)
            .ConfigureAwait(false);
        }
示例#27
0
        public static EmbedBuilder GetModuleHelp(this CommandService commandService, ICommandContext context, string modulename)
        {
            var  module        = commandService.Modules.FirstOrDefault(x => x.Name.ToLowerInvariant() == modulename.ToLowerInvariant());
            bool didLevenstein = false;

            if (module is null)
            {
                didLevenstein = true;
                module        = commandService.Modules.OrderByDescending(x => x.Name.Like(modulename)).FirstOrDefault();
            }

            if (module is null)
            {
                return(null);
            }
            if (module.Commands.Count == 0)
            {
                return(null);
            }

            string prefix = "";

            if (didLevenstein && module.Name.PercentageSimilarity(modulename) != 100)
            {
                prefix += "I assume you mean this module\n\n";
            }

            prefix += $"{module.Remarks}\n";

            if (!module.Group.IsNullOrWhiteSpace())
            {
                prefix += $"Prefix: {module.Group}\n\n";
            }

            var embed = EmbedExtensions.FromMessage(
                $"Help - {module.GetModulePath()}",
                $"{prefix}`{string.Join(", ", module.Commands.Select(cmd => cmd.Name))}`",
                Color.Teal,
                context);

            if (module.Submodules.Count > 0)
            {
                embed.AddField("Submodules:", $"`{string.Join(", ", module.Submodules.Select(mod => mod.Name))}`");
            }

            return(embed);
        }
示例#28
0
        public static async Task <EmbedBuilder> GetCommandHelpAsync(this CommandService commandService, ICommandContext context, string commandname, string prefix)
        {
            var search = commandService.Search(context, commandname).Commands;

            var summ = await search.GetSummaryAsync(context, prefix).ConfigureAwait(false);

            if (summ is null)
            {
                return(null);
            }

            var embed = EmbedExtensions.FromMessage("Help", $"Here is a command with the name **{commandname}**", Color.Teal, context);

            embed.AddField("Attributes", summ);

            return(embed);
        }
示例#29
0
文件: Space.cs 项目: Multivax/Skuld
        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);
            }
示例#30
0
        public async Task SetStreak(ushort streak, [Remainder] IUser user = null)
        {
            if (user == null)
            {
                user = Context.User;
            }

            using var Database = new SkuldDbContextFactory().CreateDbContext();

            var usr = await Database.InsertOrGetUserAsync(user)
                      .ConfigureAwait(false);

            usr.Streak = streak;

            await Database.SaveChangesAsync().ConfigureAwait(false);

            await
            EmbedExtensions.FromSuccess(Context).QueueMessageAsync(Context)
            .ConfigureAwait(false);
        }