Example #1
0
        public async Task GameRole1(string word1)
        {
            string GameNames = "";
            var    user      = Context.Guild.GetUser(Context.User.Id);
            var    roleName  = word1;
            var    role      = user.Guild.Roles.Where(has => has.Name.ToUpper() == roleName.ToUpper());
            var    test      = Context.Guild.Roles.ToArray();

            for (int i = 0; i < Datastorage.GetPairsCount(); i++)
            {
                string GameName = Datastorage.GetFormattedAlert($"Role{i}{Context.Guild.Id}");
                GameNames += GameName + "\n";
            }

            if (GameNames.Contains(roleName.ToUpper()))
            {
                await user.AddRolesAsync(role);

                await Context.Channel.SendMessageAsync($"Game: {roleName} added to your account :thumbsup: ");

                Console.WriteLine(String.Format("{0:G}", DateTime.Now) + $"Role: {roleName.ToUpper()} added to {user} || Server: {Context.Guild} || Channel: {Context.Channel} || User: {Context.User}");
            }
            else
            {
                await Context.Channel.SendMessageAsync($" :no_entry: Game: {roleName} is not added yet use `?gamehelp` for the list of games :no_entry:");
            }
        }
Example #2
0
        public async Task RemoveGame(string word1)
        {
            var    roleName  = word1;
            var    user      = Context.Guild.GetUser(Context.User.Id);
            var    role      = user.Guild.Roles.Where(has => has.Name.ToUpper() == roleName.ToUpper());
            string GameNames = "";

            for (int i = 0; i < Datastorage.GetPairsCount(); i++)
            {
                string GameName = Datastorage.GetFormattedAlert($"Role{i}{Context.Guild.Id}");
                GameNames += GameName + "\n";
            }

            if (GameNames.Contains(roleName.ToUpper()))
            {
                await user.RemoveRolesAsync(role);

                await Context.Channel.SendMessageAsync($"Game: {roleName} removed from your account :thumbsup:");

                Console.WriteLine(String.Format("{0:G}") + $"Role: {roleName.ToUpper()} removed from {user} || Server: {Context.Guild} || Channel: {Context.Channel} || User: {Context.User}");
            }
            else
            {
                await Context.Channel.SendMessageAsync($" :no_entry: Game: {roleName} doesn't exist. Use `?gamehelp` for the list of games :no_entry:");
            }
        }
Example #3
0
        public async Task GameRoleHelp()
        {
            var    embed     = new EmbedBuilder();
            string GameNames = "";

            rnd = new Random();
            string HelpMsg1   = Utilities.GetFormattedAlert("GameRoleHelp1");
            string HelpMsg2   = Utilities.GetFormattedAlert("GameRoleHelp2");
            string HelpMsg3   = Utilities.GetFormattedAlert("GameRoleHelp3");
            string RemoveGame = Utilities.GetFormattedAlert("RemoveGame");

            embed.WithTitle($"Info for {Context.User.Username}");
            embed.WithDescription(HelpMsg1 + HelpMsg2);
            embed.WithThumbnailUrl("https://i.gyazo.com/f29f36719c4aa76076aa8d764d35b96d.jpg");
            embed.WithColor(new Color(rnd.Next(255), rnd.Next(255), rnd.Next(255)));
            embed.WithCurrentTimestamp();
            for (int i = 0; i < Datastorage.GetPairsCount(); i++)
            {
                string GameName = Datastorage.GetFormattedAlert($"Role{i}{Context.Guild.Id}");
                GameNames += GameName + "\n";
            }
            embed.AddField("Available games:", GameNames);
            embed.AddField("My game is not in the list.", HelpMsg3);
            embed.AddField("How do i remove a game that i added?", RemoveGame);
            await Context.Channel.SendMessageAsync("", false, embed);

            Console.WriteLine(String.Format("{0:G}", DateTime.Now) + $"Server: {Context.Guild} || Channel: {Context.Channel} || User: {Context.User}");
        }