public static void AddMissingChannels(SocketGuild server)
        {
            if (hasChecked)
            {
                return;
            }

            foreach (SocketVoiceChannel channel in server.VoiceChannels)
            {
                if (!allVoiceChannels.ContainsKey(channel.Id))
                {
                    // Attempt to find a matching name from namelist.

                    List <string> toTest = new List <string> ();
                    toTest.Add(channel.Name.Substring(channel.Name.IndexOf(' ') + 1));
                    toTest.Add(channel.Name);

                    string withoutTags = channel.Name;
                    string found       = postRebootChannelName;
                    foreach (string x in extraChannelNames)
                    {
                        string []          possibilities = x.Split(';');
                        SoftStringComparer comparer      = new SoftStringComparer();

                        foreach (string name in toTest)
                        {
                            if (possibilities.Length > 0 ? comparer.Equals(possibilities [1], name) || possibilities[0] == name : possibilities [0] == name)
                            {
                                found = x;
                                break;
                            }
                        }
                    }

                    nameQueue [found] = true;
                    allVoiceChannels.Add(channel.Id, new VoiceChannel(channel.Id, found, allVoiceChannels.Count));
                }

                foreach (VoiceChannelTag tag in voiceChannelTags)
                {
                    if (channel.Name.Contains(tag.tagEmoji))
                    {
                        try {
                            tag.setTrue?.Invoke(allVoiceChannels [channel.Id]);
                        } catch (Exception e) {
                            Logging.Log(Logging.LogType.EXCEPTION, e.Message);
                            throw;
                        }
                    }
                }
            }

            hasChecked = true;
        }
Example #2
0
        public static Event StringToEvent(string input)
        {
            SoftStringComparer softie = new SoftStringComparer();

            for (int i = 0; i < (int)Event.Count; i++)
            {
                if (softie.Equals(((Event)i).ToString(), input))
                {
                    return((Event)i);
                }
            }
            return(Event.Null);
        }
Example #3
0
        public static bool RemoveChain(Event eve, string name)
        {
            SoftStringComparer  softie   = new SoftStringComparer();
            IEnumerable <Autoc> toRemove = autocEvents [eve].autocs.Where(x => softie.Equals(name, x.name));

            if (toRemove.Count() > 0)
            {
                autocEvents [eve].autocs.RemoveAll(x => toRemove.Contains(x));
                SaveData();
                return(true);
            }
            return(false);
        }
Example #4
0
 public static SocketGuildChannel SearchChannel(string name) {
     IEnumerable<SocketGuildChannel> channels = GetServer ().Channels;
     SoftStringComparer comparer = new SoftStringComparer ();
     foreach (SocketGuildChannel channel in channels) {
         try {
             if (comparer.Equals (name, channel.Name))
                 return channel;
         } catch (Exception e) {
             Logging.Log (e);
         }
     }
     return null;
 }
Example #5
0
            public Task <Result> Execute(SocketUserMessage e, ulong owner, string state)
            {
                SoftStringComparer softStringComparer = new SoftStringComparer();

                Permissions.State s = Permissions.State.Null;
                for (int i = 0; i < (int)Permissions.State.Count; i++)
                {
                    if (softStringComparer.Equals(((Permissions.State)i).ToString(), state))
                    {
                        s = (Permissions.State)i;
                    }
                }

                if (s == Permissions.State.Null)
                {
                    return(TaskResult(false, "Failed to set permission - Could not parse state."));
                }

                Permissions.SetPermissions(owner, type, s);
                return(TaskResult(true, $"Succesfully set permission {type} for {owner} to {s}."));
            }
        public static void Set(ulong ID, string name, object obj, bool allowReserved = false)
        {
            SoftStringComparer softie = new SoftStringComparer();

            if (!allowReserved && reservedNames.Any(x => softie.Equals(x, name)))
            {
                throw new ArgumentException($"Cannot use name {name}, as it is reserved.");
            }

            if (!variables.ContainsKey(ID))
            {
                variables.Add(ID, new Dictionary <string, object> ());
            }

            if (variables [ID].ContainsKey(name))
            {
                variables [ID] [name] = obj;
            }
            else
            {
                variables [ID].Add(name, obj);
            }
        }
                public Task <Result> Execute(SocketUserMessage e, string name)
                {
                    SoftStringComparer comparer = new SoftStringComparer();

                    return(TaskResult(Utility.GetServer().Channels.Where(x => comparer.Equals(x.Name, name)).FirstOrDefault(), ""));
                }