Exemple #1
0
        public async Task RemoveMember(CommandContext e, [Description("Member to be removed ")] DiscordMember user, [RemainingText, Description("Name of faction which the user will be removed from.")] string guildName)
        {
            try
            {
                var guild  = RPClass.Guilds.First(x => x.Name == guildName);
                var rpUser = RPClass.Users.First(x => x.UserData.UserID == user.Id);
                if (rpUser.UserData.FactionID != guild.Id)
                {
                    await e.RespondAsync("User not in faction.");

                    return;
                }

                rpUser.UserData.FactionID = guild.Id;
                await XPClass.UpdatePlayerRanking(e.Guild);

                await XPClass.UpdateGuildRanking(e.Guild);

                RPClass.SaveData(3);
                RPClass.SaveData(1);
                await e.RespondAsync("User removed from faction.");
            }
            catch
            {
                await e.RespondAsync("No faction found with that name. Are you sure you typed it in correctly?");
            }
        }
Exemple #2
0
        public async Task RemoveMember(CommandContext e, [Description("Member to be removed ")] DiscordMember user, [RemainingText, Description("Name of guild which the user will be removed from.")] string guildName)
        {
            try
            {
                RPClass.Guilds.First(x => x.Name == guildName).UserIDs.Remove(RPClass.Users.First(x => x.UserData.UserID == user.Id).UserData.UserID);
                RPClass.Users.First(x => x.UserData.UserID == user.Id).UserData.GuildID = 0;
                if (RPClass.Users.First(x => x.UserData.UserID == user.Id).UserData.Role == 1)
                {
                    await XPClass.UpdatePlayerRanking(e.Guild, 1);
                }
                else if (RPClass.Users.First(x => x.UserData.UserID == user.Id).UserData.Role == 2)
                {
                    await XPClass.UpdatePlayerRanking(e.Guild, 2);
                }
                else if (RPClass.Users.First(x => x.UserData.UserID == user.Id).UserData.Role == 3)
                {
                    await XPClass.UpdatePlayerRanking(e.Guild, 3);
                }
                else if (RPClass.Users.First(x => x.UserData.UserID == user.Id).UserData.Role == 4)
                {
                    await XPClass.UpdatePlayerRanking(e.Guild, 4);
                }

                await XPClass.UpdateGuildRanking(e.Guild);

                RPClass.SaveData(3);
                RPClass.SaveData(1);
                await e.RespondAsync("User removed from guild.");
            }
            catch
            {
                await e.RespondAsync("No guild found with that name. Are you sure you typed it in correctly?");
            }
        }
Exemple #3
0
        public async Task Destroy(CommandContext e, [RemainingText, Description("Name of guild to be destroyed.")] string guildName)
        {
            try
            {
                foreach (UserObject.RootObject user in RPClass.Users.FindAll(x => x.UserData.GuildID == RPClass.Guilds.First(y => y.Name == guildName).Id))
                {
                    user.UserData.GuildID = 0;
                }
                RPClass.Guilds.Remove(RPClass.Guilds.First(x => x.Name == guildName));
                await XPClass.UpdatePlayerRanking(e.Guild, 1);

                await XPClass.UpdatePlayerRanking(e.Guild, 2);

                await XPClass.UpdatePlayerRanking(e.Guild, 3);

                await XPClass.UpdatePlayerRanking(e.Guild, 4);

                await XPClass.UpdateGuildRanking(e.Guild);

                RPClass.SaveData(3);
                RPClass.SaveData(1);

                await e.RespondAsync("Guild deleted.");
            }
            catch
            {
                await e.RespondAsync("No guild found with that name. Are you sure you typed it in correctly?");
            }
        }
Exemple #4
0
        public async Task Create(CommandContext e, [RemainingText, Description("Name of new faction")] string guildName)
        {
            RPClass.Guilds.Add(new GuildObject.RootObject(1 + RPClass.Guilds.Count, guildName));
            await XPClass.UpdateGuildRanking(e.Guild);

            RPClass.SaveData(3);
            await e.RespondAsync("Guild created.");
        }
Exemple #5
0
        public async Task Bulk(CommandContext e)
        {
            await e.RespondAsync("Change stats by typing `<mention> <xp amount>.\nTo end this process and save, type `stop`.");

            var interactivity = e.Client.GetInteractivity();

AnotherMessage:

            var msg = await interactivity.WaitForMessageAsync(x => x.Author == e.Member, TimeSpan.FromSeconds(120));

            if (msg != null)
            {
                if (msg.Message.Content == "stop")
                {
                    await UpdateStats();

                    RPClass.SaveData(1);
                    await UpdatePlayerRanking(e.Guild);

                    await e.RespondAsync("Stats updated.");
                }
                else
                {
                    try
                    {
                        string[]      args   = msg.Message.Content.Split(" ");
                        DiscordMember member = await e.CommandsNext.ConvertArgument(args[0], e, typeof(DiscordMember)) as DiscordMember;

                        UserObject.RootObject userData = RPClass.Users.Find(x => x.UserData.UserID == member.Id);
                        userData.UserData.Xp += int.Parse(args[1]);
                        if (userData.UserData.Xp < 0)
                        {
                            userData.UserData.Xp = 0;
                        }
                        await e.RespondAsync("Stat changed. \nSend another, by typing `<mention> <xp amount>`.\nTo end this process, type `stop`.");
                    }
                    catch
                    {
                        await e.RespondAsync("No user found, or xp was in invalid format.");
                    }
                    goto AnotherMessage;
                }
            }
            else
            {
                await UpdateStats();

                await XPClass.UpdateGuildRanking(e.Guild);
                await UpdatePlayerRanking(e.Guild);

                RPClass.SaveData(1);

                await e.RespondAsync("Stats updated.");
            }
        }
Exemple #6
0
        public static async Task UpdateUserList(DiscordGuild e, bool update)
        {
            var members = await e.GetAllMembersAsync();

            foreach (var user in members)
            {
                if (!RPClass.Users.Any(x => x.UserData.UserID == user.Id))
                {
                    RPClass.Users.Add(new UserObject.RootObject(user.Id));
                }
            }

            if (update)
            {
                await XPClass.UpdateStats();

                await XPClass.UpdatePlayerRanking(e);

                await XPClass.UpdateGuildRanking(e);
            }
        }
Exemple #7
0
        public async Task Destroy(CommandContext e, [RemainingText, Description("Name of faction to be destroyed.")] string guildName)
        {
            try
            {
                foreach (var user in RPClass.Users.Where(x => x.UserData.FactionID == RPClass.Guilds.First(y => y.Name == guildName).Id))
                {
                    user.UserData.FactionID = 0;
                }
                RPClass.Guilds.Remove(RPClass.Guilds.First(x => x.Name == guildName));
                await XPClass.UpdateGuildRanking(e.Guild);

                await XPClass.UpdatePlayerRanking(e.Guild);

                RPClass.SaveData(3);
                RPClass.SaveData(1);

                await e.RespondAsync("Faction deleted.");
            }
            catch
            {
                await e.RespondAsync("No faction found with that name. Are you sure you typed it in correctly?");
            }
        }
Exemple #8
0
        public static async Task AddOrUpdateUsers(DiscordGuild guild, bool update)
        {
            List <DiscordMember> AllUsers = new List <DiscordMember>(await guild.GetAllMembersAsync());

            AllUsers.RemoveAll(x => x.IsBot);
            List <DiscordChannel> Channels = new List <DiscordChannel>(await guild.GetChannelsAsync());

            foreach (DiscordMember user in AllUsers)
            {
                int role = 0;

                /*312980663638818817 = Pro Hero
                 * 312981984790052866 = Sidekick
                 * 312980292086530048 = Academy Student
                 * 312982325908471808 = Villain
                 * 317915877775245312 = Rogue
                 *
                 */
                if (user.Roles.Any(x => x.Id == 312980663638818817))
                {
                    role = 1;
                }
                else if (user.Roles.Any(x => x.Id == 312982325908471808))
                {
                    role = 2;
                }
                else if (user.Roles.Any(x => x.Id == 317915877775245312))
                {
                    role = 3;
                }
                else if (user.Roles.Any(x => x.Id == 312981984790052866 || x.Id == 312980292086530048))
                {
                    role = 4;
                }
                if (!Users.Any(x => x.UserData.UserID == user.Id))
                {
                    Users.Add(new UserObject.RootObject(new UserObject.UserData(user.Id, user.DisplayName, role), new UserObject.InvData()));
                }
                if (Users.Find(x => x.UserData.UserID == user.Id).UserData.Username != user.DisplayName)
                {
                    Users.Find(x => x.UserData.UserID == user.Id).UserData.Username = user.DisplayName;
                }
                if (Users.Find(x => x.UserData.UserID == user.Id).UserData.Role != role)
                {
                    Users.Find(x => x.UserData.UserID == user.Id).UserData.Role = role;
                }
            }
            if (update)
            {
                await XPClass.UpdateStats(StatsChannel);

                await XPClass.UpdateGuildRanking(guild);

                await XPClass.UpdatePlayerRanking(guild, 1);

                await XPClass.UpdatePlayerRanking(guild, 2);

                await XPClass.UpdatePlayerRanking(guild, 3);

                await XPClass.UpdatePlayerRanking(guild, 4);
            }
            SaveData(-1);
        }