Esempio n. 1
0
 public bool FromJSON(JSONContainer json)
 {
     if (json.TryGetField(JSON_CHANNELID, out ChannelId))
     {
         if (json.TryGetArrayField(JSON_MODENTRIES, out JSONContainer jsonModEntries))
         {
             foreach (JSONField field in jsonModEntries.Array)
             {
                 if (field.IsObject)
                 {
                     ChannelModerationEntry entry = new ChannelModerationEntry(Parent.GuildId);
                     if (entry.FromJSON(field.Container))
                     {
                         moderationEntries.Add(entry);
                     }
                 }
             }
         }
         return(true);
     }
     return(false);
 }
Esempio n. 2
0
        private async Task InvokeChannelModeratedEvents(ChannelModerationEntry entry)
        {
            await TryInvokeChannelModeratedEvent(OnChannelModerated, entry);

            switch (entry.Type)
            {
            case ChannelModerationType.Locked:
                await TryInvokeChannelModeratedEvent(OnChannelLocked, entry);

                break;

            case ChannelModerationType.Unlocked:
                await TryInvokeChannelModeratedEvent(OnChannelUnlocked, entry);

                break;

            case ChannelModerationType.Purged:
                await TryInvokeChannelModeratedEvent(OnChannelPurged, entry);

                break;
            }
        }
Esempio n. 3
0
 private async Task TryInvokeChannelModeratedEvent(OnChannelModeratedDelegate eventDelegates, ChannelModerationEntry entry)
 {
     if (eventDelegates != null)
     {
         foreach (Delegate del in eventDelegates.GetInvocationList())
         {
             OnChannelModeratedDelegate deleg = del as OnChannelModeratedDelegate;
             if (deleg != null)
             {
                 try
                 {
                     await deleg(this, entry);
                 }
                 catch (Exception e)
                 {
                     await YNBBotCore.Logger(new LogMessage(LogSeverity.Error, "GML", "A channel moderated log handler threw an unhandled exception", e));
                 }
             }
         }
     }
 }