Exemplo n.º 1
0
        public async Task updateJamesBondNames(MessageCreateEventArgs msgEvent)
        {
            DiscordGuild lhServer = msgEvent.Guild;
            await msgEvent.Message.Respond("I'm trying father");

            Task <List <DiscordMember> > taskMembersList = lhServer.GetAllMembers();
            List <DiscordMember>         membersList     = taskMembersList.Result.Where(x => x.Nickname != "James Bond").ToList <DiscordMember>();

            if (membersList.Count <= 0)
            {
                await msgEvent.Message.Respond("Everyone is already James Bond 🔫😎");
            }
            else
            {
                await msgEvent.Message.Respond("Updating those 007s");

                string andStr = "";
                foreach (DiscordMember member in membersList)
                {
                    if (member.User.ID != lhBotId)
                    {
                        try
                        {
                            await lhServer.ModifyMember(member.User.ID, "James Bond", member.Roles, member.IsMuted, member.IsDeafened, 0);

                            await msgEvent.Message.Respond(member.User.Mention + andStr + " you're a James Bond");

                            andStr = " and";
                        }
                        catch (Exception e)//I'm not sure what the issue is, but it fails on some users. Based on bad documentation, I think users need to be online or else it fails
                        {
                            await msgEvent.Message.Respond(member.User.Mention + " I couldn't make you a James Bond, sorry!");
                        }
                    }
                }
                await msgEvent.Message.Respond("Everyone is a James Bond 😎👍");
            }
            return;
        }