Example #1
0
        /// <summary>
        /// Initiates the GuildChannelHelpers stored configs and ids from a json object
        /// </summary>
        /// <param name="json">json data</param>
        public static void FromJSON(JSONContainer json)
        {
            channelConfigs.Clear();

            json.TryGetField(JSON_DEBUGCHANNELID, out DebugChannelId);
            json.TryGetField(JSON_WELCOMINGCHANNELID, out WelcomingChannelId);
            json.TryGetField(JSON_ADMINCOMMANDUSAGELOGCHANNELID, out AdminCommandUsageLogChannelId);
            json.TryGetField(JSON_ADMINNOTIFICATIONCHANNELID, out AdminNotificationChannelId);
            json.TryGetField(JSON_INTERACTIVEMESSAGECHANNELID, out InteractiveMessagesChannelId);
            json.TryGetField(JSON_GUILDCATEGORYID, out GuildCategoryId);

            if (json.TryGetField(JSON_CHANNELINFOS, out IReadOnlyList <JSONField> channelInfos))
            {
                foreach (JSONField channelInfo in channelInfos)
                {
                    if (channelInfo.IsObject)
                    {
                        GuildChannelConfiguration info = new GuildChannelConfiguration();
                        if (info.FromJSON(channelInfo.Container))
                        {
                            channelConfigs.Add(info.Id, info);
                        }
                    }
                }
            }
        }
Example #2
0
 /// <summary>
 /// Sets the channel config for a given channel
 /// </summary>
 /// <param name="channelConfig"></param>
 public static void SetChannelConfig(GuildChannelConfiguration channelConfig)
 {
     if (channelConfigs.ContainsKey(channelConfig.Id))
     {
         if (channelConfig.IsDefault)
         {
             channelConfigs.Remove(channelConfig.Id);
         }
         else
         {
             channelConfigs[channelConfig.Id] = channelConfig;
         }
     }
     else
     {
         if (!channelConfig.IsDefault)
         {
             channelConfigs.Add(channelConfig.Id, channelConfig);
         }
     }
 }
Example #3
0
 /// <summary>
 /// Attempts to retrieve specific channel info for a given channel id
 /// </summary>
 /// <param name="channelId">ulong id of the channel</param>
 /// <param name="channelConfig">the resulting channel info</param>
 /// <returns>True if specific channel info was found</returns>
 public static bool TryGetChannelConfig(ulong channelId, out GuildChannelConfiguration channelConfig)
 {
     return(channelConfigs.TryGetValue(channelId, out channelConfig));
 }