Ejemplo n.º 1
0
 private Dictionary <ulong, string> LoadAfkStatus()
 {
     try
     {
         return(SwissbotStateHandler.LoadObject <Dictionary <ulong, string> >("afk.json").GetAwaiter().GetResult());
     }
     catch
     {
         return(new Dictionary <ulong, string>());
     }
 }
Ejemplo n.º 2
0
 public static async Task <AltHandlerSettings> Load()
 {
     try
     {
         return(await SwissbotStateHandler.LoadObject <AltHandlerSettings>("AltHandlerSettings.json"));
     }
     catch (Exception x)
     {
         return(new AltHandlerSettings());
     }
 }
Ejemplo n.º 3
0
 public static async Task Init()
 {
     try
     {
         Users = await SwissbotStateHandler.LoadObject <List <DiscordUser> >("WebUsers.json");
     }
     catch
     {
         Users = new List <DiscordUser>();
     }
 }
Ejemplo n.º 4
0
 public Dictionary <ulong, DateTime> LoadAskTimes()
 {
     try
     {
         return(SwissbotStateHandler.LoadObject <Dictionary <ulong, DateTime> >("SuggestionTimes.json").GetAwaiter().GetResult());
     }
     catch
     {
         return(new Dictionary <ulong, DateTime>());
     }
 }
Ejemplo n.º 5
0
        public EventVCHandler(DiscordSocketClient c)
        {
            client = c;

            client.UserVoiceStateUpdated += HandleVoiceStateUpdate;
            client.GuildMemberUpdated    += GuildMemberUpdated;


            WebSocketServer.AddCustomEvent("event.user.mute", HandleUserActionEvent);
            WebSocketServer.AddCustomEvent("event.user.deafen", HandleUserActionEvent);
            WebSocketServer.AddCustomEvent("event.user.disconnect", HandleUserActionEvent);

            WebSocketServer.AddCustomEvent("event.user.permamute", HandlePermaMute);

            WebSocketServer.AddCustomEvent("event.channel.mute", HandleEntireChannelMute);
            WebSocketServer.AddCustomEvent("event.channel.unmute", HandleEntireChannelUnmute);

            WebSocketServer.AddCustomEvent("event.settings.update", HandleSettingsUpdate);

            // Load the event vc settings
            try
            {
                settings = SwissbotStateHandler.LoadObject <EventVcSettings>("EventSettings.json").GetAwaiter().GetResult();
            }
            catch (Exception x)
            {
                settings = default;
            }



            // Load the users
            var channel = client.GetGuild(Global.SwissGuildId).GetVoiceChannel(627906629047943238);

            foreach (var user in channel.Users)
            {
                if (!user.VoiceState.HasValue)
                {
                    continue;
                }

                users.Add(new EventVcUser(user, user.VoiceState.Value));
            }

            Timer t = new Timer()
            {
                AutoReset = true,
                Interval  = 1000,
                Enabled   = true
            };

            t.Elapsed += T_Elapsed;
        }
        public MessageCountHandler(DiscordSocketClient c)
        {
            this.client = c;

            client.MessageReceived += MessageCounter;

            timer.Elapsed += HandleCheck;
            timer.Interval = 1800000;
            timer.Start();

            VcTimer.Elapsed += HandleVcCheck;
            VcTimer.Interval = 60000;
            VcTimer.Start();

            try
            {
                client.Rest.CreateGuildCommand(new Discord.SlashCommandCreationProperties()
                {
                    Name        = "staff-activity",
                    Description = "Changes the count filer for staff messasges",
                    Options     = new List <Discord.ApplicationCommandOptionProperties>()
                    {
                        new Discord.ApplicationCommandOptionProperties()
                        {
                            Name        = "blacklist",
                            Description = "blacklists a channel from adding to message count",
                            //Required = true,
                            Type    = Discord.ApplicationCommandOptionType.SubCommandGroup,
                            Options = new List <Discord.ApplicationCommandOptionProperties>()
                            {
                                new Discord.ApplicationCommandOptionProperties()
                                {
                                    Name        = "add",
                                    Description = "adds a channel to the staff count blacklist",
                                    Type        = Discord.ApplicationCommandOptionType.SubCommand,
                                    Options     = new List <Discord.ApplicationCommandOptionProperties>()
                                    {
                                        new Discord.ApplicationCommandOptionProperties()
                                        {
                                            Name        = "Channel",
                                            Description = "The channel to blacklist",
                                            Type        = Discord.ApplicationCommandOptionType.Channel,
                                            Required    = true,
                                        }
                                    }
                                },
                                new Discord.ApplicationCommandOptionProperties()
                                {
                                    Name        = "remove",
                                    Description = "removes a channel to the staff count blacklist",
                                    Type        = Discord.ApplicationCommandOptionType.SubCommand,
                                    Options     = new List <Discord.ApplicationCommandOptionProperties>()
                                    {
                                        new Discord.ApplicationCommandOptionProperties()
                                        {
                                            Name        = "Channel",
                                            Description = "The channel to remove from the blacklist",
                                            Type        = Discord.ApplicationCommandOptionType.Channel,
                                            Required    = true,
                                        }
                                    }
                                },
                                new Discord.ApplicationCommandOptionProperties()
                                {
                                    Name        = "list",
                                    Description = "lists all channels in the staff count blacklist",
                                    Type        = Discord.ApplicationCommandOptionType.SubCommand,
                                }
                            }
                        },
                        new ApplicationCommandOptionProperties()
                        {
                            Name        = "check",
                            Description = "checks a staff members activity",
                            Type        = ApplicationCommandOptionType.SubCommand,
                            Options     = new List <ApplicationCommandOptionProperties>()
                            {
                                new ApplicationCommandOptionProperties()
                                {
                                    Name        = "user",
                                    Description = "The user to check the activity of",
                                    Type        = ApplicationCommandOptionType.User,
                                    Required    = true
                                }
                            }
                        },
                        new ApplicationCommandOptionProperties()
                        {
                            Name        = "settings",
                            Description = "Change the settings of the count filter",
                            Type        = ApplicationCommandOptionType.SubCommandGroup,
                            Options     = new List <ApplicationCommandOptionProperties>()
                            {
                                new ApplicationCommandOptionProperties()
                                {
                                    Name        = "minimum-messages",
                                    Description = "change the minimum amount of messages to trigger a infraction",
                                    Type        = ApplicationCommandOptionType.SubCommand,
                                    Options     = new List <ApplicationCommandOptionProperties>()
                                    {
                                        new ApplicationCommandOptionProperties()
                                        {
                                            Name        = "set",
                                            Type        = ApplicationCommandOptionType.Integer,
                                            Description = "sets the minimum messages to trigger a infraction",
                                        }
                                    }
                                }
                            }
                        }
                    }
                }, Global.SwissGuildId);
            }
            catch (Exception x)
            {
            }

            client.InteractionCreated += Client_InteractionCreated;

            Task.Run(async() =>
            {
                // Load the state
                try
                {
                    Records = await SwissbotStateHandler.LoadObject <List <StaffMember> >("StaffMessagesCount.json");
                }
                catch
                {
                    Records = new List <StaffMember>();
                }

                try
                {
                    ChannelBlacklists = await SwissbotStateHandler.LoadObject <List <ulong> >("StaffMessagesCountBlacklist.json");
                }
                catch
                {
                    ChannelBlacklists = new List <ulong>();
                }

                try
                {
                    Settings = await SwissbotStateHandler.LoadObject <Settings>("StaffMessagesSettings.json");
                }
                catch
                {
                    Settings = new Settings();
                }
            });
        }