Пример #1
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);
        }
Пример #2
0
        public async Task OwnerInfoCommand()
        {
            NormalEmbed   Embed = new NormalEmbed();
            StringBuilder sb    = new StringBuilder();

            Embed.Title = "Owner Information";
            sb.AppendLine("Current token: " + Rem.RemCredentials["Connection_Token"]);
            Embed.Description = sb.ToString();
            await(await(Context.User.CreateDMChannelAsync())).SendEmbedAsync(Embed);
        }
Пример #3
0
        public async Task RandomUserCommand()
        {
            SocketGuild     TargetGuild = Context.Guild as SocketGuild;
            Random          Generator   = new Random();
            SocketGuildUser FoundUser   = TargetGuild.Users.ElementAt(Generator.Next(1, TargetGuild.Users.Count));
            NormalEmbed     RandomUser  = new NormalEmbed();

            RandomUser.Title       = "The wise Rem has picked...";
            RandomUser.Description = FoundUser.Username;
            await Context.Channel.SendEmbedAsync(RandomUser);
        }
Пример #4
0
        public async Task AvatarCommand(SocketGuildUser TargetUser = null)
        {
            if (TargetUser == null)
            {
                TargetUser = (Context.User as SocketGuildUser);
            }
            NormalEmbed AvatarEmbed = new NormalEmbed();

            AvatarEmbed.Title    = TargetUser.GetEffectiveName();
            AvatarEmbed.ImageUrl = TargetUser.AvatarUrl;
            await Context.Channel.SendEmbedAsync(AvatarEmbed);
        }
Пример #5
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;
            }
        }
Пример #6
0
        public async Task CommandHelp()
        {
            IEnumerable <IGrouping <string, CommandInfo> > CommandGroups = (await RemService.Commands.CheckConditions(Context, RemDeps))
                                                                           .Where(c => !c.Preconditions.Any(p => p is HiddenAttribute))
                                                                           .GroupBy(c => (c.Module.IsSubmodule ? c.Module.Parent.Name : c.Module.Name));

            NormalEmbed   HelpEmbed = new NormalEmbed();
            StringBuilder HEDesc    = new StringBuilder();

            HelpEmbed.Title        = "My Commands";
            HelpEmbed.ThumbnailUrl = Context.Client.CurrentUser.AvatarUrl;
            HEDesc.AppendLine("**You can use the following commands:**");

            foreach (IGrouping <string, CommandInfo> Group in CommandGroups)
            {
                if (Group.Key == "Reactions" || Group.Key == "Emojis")
                {
                    StringBuilder sbx       = new StringBuilder();
                    List <string> reactions = new List <string> {
                    };
                    foreach (CommandInfo Command in Group)
                    {
                        reactions.Add("`" + Command.Name + "` ");
                        sbx.Append($"`{Command.Name}` ");
                    }
                    HEDesc.AppendLine($"**{Group.Key}**: " + sbx.ToString());
                }
                else
                {
                    HEDesc.AppendLine($"**{Group.Key}**:");
                    foreach (CommandInfo Command in Group)
                    {
                        HEDesc.AppendLine($"• `{Command.Name}`: {Command.Summary}");
                    }
                }
            }
            HEDesc.AppendLine($"\nYou can use `{Rem.RemConfig["Command_Prefix"]}Help <command>` for more information on that command");

            HelpEmbed.Description = HEDesc.ToString();
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("**See my source code!** https://github.com/iloverem/Rem");
            await(Context.User.CreateDMChannelAsync().Result).SendMessageAsync(sb.ToString(), false, HelpEmbed);
            if (!Context.IsPrivate)
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention}, help sent to your Direct Messages!");
            }
        }
Пример #7
0
        public async Task CatCommand()
        {
            Uri            CatUri              = new Uri("http://random.cat/meow");
            HttpWebRequest CatRequest          = (HttpWebRequest)WebRequest.Create(CatUri);
            var            Response            = CatRequest.GetResponseAsync();
            var            ResponseStream      = (await Response).GetResponseStream();
            StreamReader   CatStream           = new StreamReader(ResponseStream);
            JsonTextReader Reader              = new JsonTextReader(CatStream);
            JObject        CatJ                = (JObject)JToken.ReadFrom(Reader);
            Dictionary <string, string> Result = JsonConvert.DeserializeObject <Dictionary <string, string> >(CatJ.ToString());
            NormalEmbed Cat = new NormalEmbed();

            Cat.Title    = "Cat.";
            Cat.ImageUrl = Result["file"];
            Cat.Footer   = new MEmbedFooter().WithText("Courtesy of http://random.cat");
            await Context.Channel.SendEmbedAsync(Cat);

            ResponseStream.Dispose();
            CatStream.Dispose();
        }
Пример #8
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);
        }
Пример #9
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);
        }