Пример #1
0
        public async Task SpecificHelp(string cmdname)
        {
            StringBuilder             sb       = new StringBuilder();
            NormalEmbed               e        = new NormalEmbed();
            IEnumerable <CommandInfo> Commands = (await RemService.Commands.CheckConditions(Context, RemDeps))
                                                 .Where(c => (c.Aliases.FirstOrDefault().Equals(cmdname, StringComparison.OrdinalIgnoreCase) ||
                                                              (c.Module.IsSubmodule ? c.Module.Aliases.FirstOrDefault().Equals(cmdname, StringComparison.OrdinalIgnoreCase) : false)) &&
                                                        !c.Preconditions.Any(p => p is HiddenAttribute));

            if (Commands.Any())
            {
                await ReplyAsync($"{Commands.Count()} {(Commands.Count() > 1 ? $"entries" : "entry")} for `{cmdname}`");

                foreach (CommandInfo Command in Commands)
                {
                    NormalEmbed x = new NormalEmbed();
                    x.Title       = $"{Command.Name}";
                    x.Description = (Command.Summary ?? "No summary.");
                    x.AddField(a =>
                    {
                        a.Name     = "Usage";
                        a.IsInline = true;
                        a.Value    = $"{Rem.RemConfig["Command_Prefix"]}{(Command.Module.IsSubmodule ? $"{Command.Module.Name} " : "")}{Command.Name} " + string.Join(" ", Command.Parameters.Select(p => formatParam(p))).Replace("`", "") + " ";
                    });
                    x.AddField(a =>
                    {
                        a.Name          = "Aliases";
                        a.IsInline      = true;
                        StringBuilder s = new StringBuilder();
                        if (Command.Aliases.Any())
                        {
                            foreach (string Alias in Command.Aliases)
                            {
                                s.Append(Alias + " ");
                            }
                        }
                        a.Value = $"{(Command.Aliases.Any() ? s.ToString() : "No aliases.")}";
                    });
                    await Context.Channel.SendEmbedAsync(x);
                }
            }
            else
            {
                await ReplyAsync($":warning: I couldn't find any command matching `{cmdname}`.");

                return;
            }
        }
Пример #2
0
        public async Task BotInfoCommand()
        {
            NormalEmbed Info = new NormalEmbed();

            Info.Title        = "Bot Information";
            Info.Description  = Rem.GetDescription();
            Info.ThumbnailUrl = Context.Client.CurrentUser.AvatarUrl;
            Info.AddField(MD =>
            {
                MD.Name     = "Bot Version";
                MD.Value    = Rem.Version;
                MD.IsInline = true;
            });
            Info.AddField(MD =>
            {
                MD.Name     = "Owner";
                MD.Value    = Context.Client.GetUserAsync(Context.Client.GetApplicationInfoAsync().GetAwaiter().GetResult().Owner.Id).GetAwaiter().GetResult().Username;
                MD.IsInline = true;
            });
            Info.AddField(x =>
            {
                x.Name     = "Discriminator";
                x.Value    = Context.Client.CurrentUser.Discriminator;
                x.IsInline = true;
            });
            Info.AddField(x =>
            {
                x.Name = "Game";
                if (Context.Client.CurrentUser.Game.HasValue)
                {
                    x.Value = "Playing " + Context.Client.CurrentUser.Game.Value;
                }
                else
                {
                    x.Value = "Not playing anything.";
                }
                x.IsInline = true;
            });
            Info.AddField(x =>
            {
                x.Name     = "Status";
                x.Value    = "Happy serving commands!";
                x.IsInline = true;
            });
            Info.AddField(x =>
            {
                x.Name     = "Language";
                x.Value    = "C#, proudly using .NET Core.";
                x.IsInline = true;
            });
            Info.AddField(x =>
            {
                x.Name     = "Total Servers";
                x.Value    = Context.Client.GetGuildsAsync().GetAwaiter().GetResult().Count.ToString();
                x.IsInline = true;
            });

            Info.Footer = (new MEmbedFooter()).WithText("Bot Information");
            await Context.Channel.SendEmbedAsync(Info);
        }
Пример #3
0
        public async Task MangaCommand([Remainder, Summary("Manga to search for.")] string MangaTarget)
        {
            string ModifiedMangaTarget = MangaTarget.Replace(' ', '+');
            Uri    uri = new Uri($"https://myanimelist.net/api/manga/search.xml?q={ModifiedMangaTarget}");

            HttpWebRequest objRegistration = (HttpWebRequest)WebRequest.Create(uri);

            CredentialCache credentials = new CredentialCache();

            NetworkCredential netCredential = new NetworkCredential((string)Rem.RemCredentials["MalUsername"], (string)Rem.RemCredentials["MalPassword"]);

            credentials.Add(uri, "Basic", netCredential);

            objRegistration.Credentials = credentials;

            var response = await objRegistration.GetResponseAsync();

            XmlDocument XMLResponse = new XmlDocument();

            try
            {
                XMLResponse.Load(response.GetResponseStream());
            }
            catch
            {
                await ReplyAsync(":warning: I couldn't find that manga.");

                return;
            }

            /*NormalEmbed AnimeEmbed = new NormalEmbed();
             * AnimeEmbed.Title = $"{GetInnerText(XMLResponse.GetElementsByTagName("title"))}{(GetInnerText(XMLResponse.GetElementsByTagName("english")) != null ? " (" + GetInnerText(XMLResponse.GetElementsByTagName("title")) + ")" : "")}";
             * AnimeEmbed.Url = $"http://myanimelist.net/anime/{GetInnerText(XMLResponse.GetElementsByTagName("id"))}";
             * AnimeEmbed.Description = FormatDescription(GetInnerText(XMLResponse.GetElementsByTagName("synopsis")));
             * AnimeEmbed.ThumbnailUrl = GetInnerText(XMLResponse.GetElementsByTagName("image"));
             * if (GetInnerText(XMLResponse.GetElementsByTagName("episodes")) != "0")
             * {
             *  AnimeEmbed.AddField(x =>
             *  {
             *      x.Name = "Episodes";
             *      x.Value = GetInnerText(XMLResponse.GetElementsByTagName("episodes"));
             *      x.IsInline = true;
             *  });
             * }
             * AnimeEmbed.AddField(a =>
             * {
             *  a.Name = "Type";
             *  a.Value = GetInnerText(XMLResponse.GetElementsByTagName("type"));
             *  a.IsInline = true;
             * });
             * AnimeEmbed.AddField(a =>
             * {
             *  a.Name = "Status";
             *  a.Value = GetInnerText(XMLResponse.GetElementsByTagName("status"));
             *  a.IsInline = true;
             * });
             * AnimeEmbed.AddField(a =>
             * {
             *  a.Name = "Start Date / End Date";
             *  a.Value = $"{GetInnerText(XMLResponse.GetElementsByTagName("start_date"))}{(GetInnerText(XMLResponse.GetElementsByTagName("end_date")) != "0000-00-00" ? " / " + GetInnerText(XMLResponse.GetElementsByTagName("end_date")) : "")}";
             *  a.IsInline = true;
             * });
             * AnimeEmbed.Footer = (new MEmbedFooter(Context.Client)).WithText($"All information from the MyAnimeList API").WithIconUrl("http://i.imgur.com/vEy5Zaq.png");
             * await Context.Channel.SendEmbedAsync(AnimeEmbed);
             */
            NormalEmbed Manga = new NormalEmbed();

            Manga.Title        = $"{GetInnerText(XMLResponse.GetElementsByTagName("title"))} {((GetInnerText(XMLResponse.GetElementsByTagName("english"))) != null ? $" {GetInnerText(XMLResponse.GetElementsByTagName("english"))}" : "")}";
            Manga.Description  = FormatDescription(GetInnerText(XMLResponse.GetElementsByTagName("synopsis")));
            Manga.ThumbnailUrl = GetInnerText(XMLResponse.GetElementsByTagName("image"));
            if (GetInnerText(XMLResponse.GetElementsByTagName("chapters")) != "0")
            {
                Manga.AddField(f =>
                {
                    f.Name     = "Chapters";
                    f.Value    = GetInnerText(XMLResponse.GetElementsByTagName("chapters"));
                    f.IsInline = true;
                });
            }
            if (GetInnerText(XMLResponse.GetElementsByTagName("volumes")) != "0")
            {
                Manga.AddField(f =>
                {
                    f.Name     = "Volumes";
                    f.Value    = GetInnerText(XMLResponse.GetElementsByTagName("volumes"));
                    f.IsInline = true;
                });
            }
            Manga.AddField(f =>
            {
                f.Name     = "Score";
                f.Value    = GetInnerText(XMLResponse.GetElementsByTagName("score"));
                f.IsInline = true;
            });
            Manga.AddField(f =>
            {
                f.Name     = "Type";
                f.Value    = GetInnerText(XMLResponse.GetElementsByTagName("type"));
                f.IsInline = true;
            });
            Manga.AddField(f =>
            {
                f.Name     = "Status";
                f.Value    = GetInnerText(XMLResponse.GetElementsByTagName("status"));
                f.IsInline = true;
            });
            Manga.AddField(f =>
            {
                f.Name     = "Start Date / End Date";
                f.Value    = $"{GetInnerText(XMLResponse.GetElementsByTagName("start_date"))} {((GetInnerText(XMLResponse.GetElementsByTagName("end_date"))) != "0000-00-00" ? " / " + GetInnerText(XMLResponse.GetElementsByTagName("end_date")) : "")}";
                f.IsInline = true;
            });
            await Context.Channel.SendEmbedAsync(Manga);
        }
Пример #4
0
        public async Task ServerInfoCommand()
        {
            SocketGuild Guild = Context.Guild as SocketGuild;
            NormalEmbed Embed = new NormalEmbed();

            Embed.Title        = Guild.Name;
            Embed.ThumbnailUrl = Guild.IconUrl;
            int    TotalRoles        = Guild.Roles.Count;
            string VoiceRegion       = (await(Context.Client.GetVoiceRegionAsync(Guild.VoiceRegionId))).Name;
            string VerificationLevel = Guild.VerificationLevel.ToString();
            int    VoiceChannels     = (await(Guild.GetVoiceChannelsAsync())).Count();
            int    TextChannels      = (await Guild.GetTextChannelsAsync()).Count();
            string Members           = $"{(Guild.Users.Where(User => (User.Status == UserStatus.Online))).Count()} Online / {Guild.Users.Count.ToString()} Total";
            string Owner             = (await Context.Client.GetUserAsync(Guild.OwnerId)).Username;

            Embed.AddField(x =>
            {
                x.Name     = "Roles";
                x.Value    = TotalRoles.ToString();
                x.IsInline = true;
            });
            Embed.AddField(x =>
            {
                x.Name     = "Voice Region";
                x.IsInline = true;
                x.Value    = VoiceRegion;
            });
            Embed.AddField(x =>
            {
                x.Name     = "Verification Level";
                x.Value    = VerificationLevel;
                x.IsInline = true;
            });
            Embed.AddField(x =>
            {
                x.Value    = VoiceChannels.ToString();
                x.IsInline = true;
                x.Name     = "Voice Channels";
            });
            Embed.AddField(x =>
            {
                x.Name     = "Text Channels";
                x.Value    = TextChannels.ToString();
                x.IsInline = true;
            });
            Embed.AddField(x =>
            {
                x.Value    = Members;
                x.Name     = "Total Members";
                x.IsInline = true;
            });
            Embed.AddField(x =>
            {
                x.Name     = "Owner";
                x.Value    = Owner;
                x.IsInline = true;
            });
            Embed.Description = $"{Guild.Name} is a Discord server with {Guild.Users.Count} {(Guild.Users.Count > 1 ? "members" : "member")}, with {(Guild.Users.Where(User => (User.Status == UserStatus.Online))).Count()} online. It has {VoiceChannels} voice {(VoiceChannels > 1 ? "channels": "channel")}, {TextChannels} text channels, a voice region of {VoiceRegion} and {TotalRoles} {(TotalRoles > 1 ? "roles" : "role")}. It is being operated by {Owner}. If you want to chat here, you're going to need Verification Level {VerificationLevel}.";
            Embed.Footer      = (new MEmbedFooter()).WithText($"Server ID: {Guild.Id}");
            await Context.Channel.SendEmbedAsync(Embed);
        }