Beispiel #1
0
        public async Task SettingsCommandcooldownAsync(int seconds)
        {
            for (int i = 0; i <= BotConfig.Load().Commanders - 1; i++)
            {
                if (BotConfig.Load().BotCommanders[i] == Context.User.Id)
                {
                    await Context.Message.DeleteAsync();

                    BotConfig config = new BotConfig();
                    config = Update.UpdateConfig(config);
                    config.CommandCooldown = seconds;
                    config.Save();

                    await success.sendSuccessTempAsync(Context.Channel, "Command Cooldown Set", "Command cooldown set to `" + seconds + " seconds` successfully!", Colours.adminCol);

                    await Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Configuration Commands", "Settings command was used by " + Context.User + "."));
                }
            }
        }
Beispiel #2
0
        public async Task SettingsTimersAsync([Remainder] IChannel channel)
        {
            for (int i = 0; i <= BotConfig.Load().Commanders - 1; i++)
            {
                if (BotConfig.Load().BotCommanders[i] == Context.User.Id)
                {
                    await Context.Message.DeleteAsync();

                    BotConfig config = new BotConfig();
                    config = Update.UpdateConfig(config);
                    config.TimerChannelId = channel.Id;
                    config.Save();

                    await success.sendSuccessTempAsync(Context.Channel, "Timers Channel Set", "Channel set to `" + channel.Name + "` successfully!", Colours.adminCol);

                    await Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Configuration Commands", "Settings command was used by " + Context.User + "."));
                }
            }
        }
Beispiel #3
0
        private async Task PrefixAsync(string prefix = null)
        {
            await Context.Message.DeleteAsync();

            BotConfig conf  = BotConfig.Load();
            var       gconf = conf.GetConfig(Context.Guild.Id);

            if (prefix == null)
            {
                await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}settings prefix <prefix>`", false);

                return;
            }

            gconf.Prefix = prefix;
            conf.Save();

            await Context.Channel.SendMessageAsync($"The prefix for the bot in this server has been successfully changed to ''{prefix}''.");
        }
Beispiel #4
0
        public async Task SettingsStatustimersAsync(int minutes)
        {
            for (int i = 0; i <= BotConfig.Load().Commanders - 1; i++)
            {
                if (BotConfig.Load().BotCommanders[i] == Context.User.Id)
                {
                    await Context.Message.DeleteAsync();

                    BotConfig config = new BotConfig();
                    config = Update.UpdateConfig(config);
                    config.StatusTimerInterval = minutes;
                    config.Save();

                    await success.sendSuccessTempAsync(Context.Channel, "Status Timer Interval Set", "Status timer interval set to `" + minutes + " minutes` successfully!", Colours.adminCol);

                    await Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Configuration Commands", "Settings command was used by " + Context.User + "."));
                }
            }
        }
Beispiel #5
0
        public static void EnsureBotConfigExists()
        {
            if (!Directory.Exists(Path.Combine(AppContext.BaseDirectory, "configuration")))
            {
                Directory.CreateDirectory(Path.Combine(AppContext.BaseDirectory, "configuration"));
            }

            string loc = Path.Combine(AppContext.BaseDirectory, "configuration/config.json");

            if (!File.Exists(loc))                          // Check if the configuration file exists.
            {
                var config = new BotConfig();               // Create a new configuration object.

                var newserv = new ServerConfig();

                Console.WriteLine("Please enter the following information to save into your configuration/config.json file");

                Console.Write("Bot Token: ");
                config.Token = Console.ReadLine();              // Read the bot token from console.

                Console.Write("Bot Prefix: ");
                config.Prefix = Console.ReadLine();              // Read the bot prefix from console.

                Console.Write("New Member Role: ");
                config.NewMemberRank = Console.ReadLine();

                Console.Write("Money Role: ");
                config.MoneyRole = Console.ReadLine();

                Console.Write("Second Money Role: ");
                config.MoneyRole1 = Console.ReadLine();

                Console.Write("Third Money Role: ");
                config.MoneyRole2 = Console.ReadLine();

                Console.Write("NSFW Role: ");
                config.NSFWRole = Console.ReadLine();

                config.Save();                                  // Save the new configuration object to file.
            }
            Console.WriteLine("Configuration has been loaded");
        }
Beispiel #6
0
        public void SetUp(IServiceProvider provider, ConfigType ctype)
        {
            configType = ctype;

            map      = provider;
            bot      = map.GetService <DiscordSocketClient>();
            commands = map.GetService <CommandService>();

            bot.Ready           += CheckConfigsAsync;
            bot.JoinedGuild     += JoinGuildAsync;
            bot.MessageReceived += HandleCommandAsync;
            bot.MessageUpdated  += HandleEditCommandAsync;
            //bot.MessagesBulkDeleted += BulkDeleteAsync;
            SetupHandlers(bot);

            BotConfig conf = BotConfig.Load();

            RegisterCommands(conf.Commands);
            conf.Save();
        }
Beispiel #7
0
        public static void ToggleCommandLogs(ulong guild = 0L, ulong channel = 0L)
        {
            BotConfig conf = BotConfig.Load();

            if (conf.Type == ConfigType.Solo || guild == 0L)
            {
                conf.SoloConfig.LogCommands = !conf.SoloConfig.LogCommands;
                if (conf.SoloConfig.LogCommands && channel != 0L)
                {
                    conf.SoloConfig.LogChannel = channel;
                }
            }
            else
            {
                IndividualConfig gconf = conf.GetConfig(guild);
                gconf.LogCommands = !gconf.LogCommands;
                if (gconf.LogCommands && channel != 0L)
                {
                    gconf.LogChannel = channel;
                }
            }
            conf.Save();
        }
        public async Task FilterAddCommandAsync(string word = null)
        {
            for (int i = 0; i <= BotConfig.Load().Commanders - 1; i++)
            {
                if (Context.User.Id == BotConfig.Load().BotCommanders[i])
                {
                    BotConfig config = new BotConfig();
                    config = Update.UpdateConfig(config);
                    config.FilteredWords[BotConfig.Load().Filters] = word;
                    config.Filters = BotConfig.Load().Filters + 1;
                    config.Save();

                    var embed = new EmbedBuilder()
                    {
                        Color = Colours.adminCol
                    };
                    embed.WithAuthor("Successfully Added", References.GetGta5policeLogo());
                    embed.WithThumbnailUrl(References.GetGta5policeLogo());
                    embed.Description = "The word " + word + " was successfully blacklisted.";
                    embed.WithFooter(new EmbedFooterBuilder()
                    {
                        Text = "Requested by " + Context.User
                    });
                    embed.WithCurrentTimestamp();

                    await Context.Message.DeleteAsync();

                    var message = await Context.Channel.SendMessageAsync("", false, embed);

                    await Delete.DelayDeleteEmbedAsync(message, 120);

                    await Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Admin Commands", "Filter add command was used by " + Context.User + "."));

                    Statistics.AddOutgoingMessages();
                }
            }
        }
Beispiel #9
0
        public async Task SettingsPrefix(String prefix = null)
        {
            if (prefix != null)
            {
                BotConfig config = new BotConfig();
                config        = Update.UpdateConfig(config);
                config.Prefix = prefix;
                config.Save();

                await bot.SetGameAsync(BotConfig.Load().Prefix + "help");

                var embed = new EmbedBuilder()
                {
                    Color = Colours.adminCol
                };
                embed.Title       = ("Settings Prefix");
                embed.Description = ("Prefix has been set to " + prefix + " successfully!");
                await ReplyAsync("", false, embed.Build());
            }
            else
            {
                await errors.sendErrorTemp(Context.Channel, "You must specify a prefix!", Colours.errorCol);
            }
        }
Beispiel #10
0
        public static void EnsureBotConfigExists()
        {
            Logger(new LogMessage(LogSeverity.Info, "GTA5Police Start Up", "Searching for existing configurations."));
            if (!Directory.Exists(Path.Combine(AppContext.BaseDirectory, "configuration")))
            {
                Directory.CreateDirectory(Path.Combine(AppContext.BaseDirectory, "configuration"));
            }

            string configLoc      = Path.Combine(AppContext.BaseDirectory, "configuration/config.json");
            string connectionsLoc = Path.Combine(AppContext.BaseDirectory, "configuration/connections_config.json");
            string urlsLoc        = Path.Combine(AppContext.BaseDirectory, "configuration/url_config.json");
            string devConfigLoc   = Path.Combine(AppContext.BaseDirectory, "configuration/dev_config.json");
            string ranksConfigLoc = Path.Combine(AppContext.BaseDirectory, "configuration/ranks_config.json");
            string autoBansLoc    = Path.Combine(AppContext.BaseDirectory, "configuration/auto_bans.json");

            if (!File.Exists(configLoc))
            {
                var config = new BotConfig();

                Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Enter the following info for the configuration."));
                Console.Write("Bot Prefix: ");
                config.Token = Console.ReadLine();
                Console.Write("Bot Token: ");
                config.Token                = Console.ReadLine();
                config.ServerId             = 0;
                config.LogsId               = 0;
                config.TimerChannelId       = 0;
                config.StatusTimerInterval  = 1;
                config.MessageTimerInterval = 30;
                config.MessageTimerCooldown = 5;
                config.CommandCooldown      = 120.0d;
                config.Commanders           = 1;
                config.BotCommanders[0]     = 211938243535568896;
                config.Filters              = 0;
                config.PoliceAdd            = false;
                config.EmsAdd               = false;
                config.Save();
                Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Main configuration generated"));
            }
            Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Main configuration has been loaded"));

            if (!File.Exists(connectionsLoc))
            {
                var connections = new ConnectionsConfig();

                connections.ServerIp = "66.150.121.131";
                connections.NyPort   = 30150;
                connections.LaPort   = 30141;
                connections.NyWlPort = 30151;
                connections.LaWlPort = 30142;
                connections.Save();
                Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Connections configuration generated"));
            }
            Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Connections configuration has been loaded"));

            if (!File.Exists(urlsLoc))
            {
                var url = new UrlConfig();
                url.Website     = "https://www.gta5police.com";
                url.Dashboard   = "https://gta5police.com/panel/index.php";
                url.Forums      = "https://gta5police.com/forums/";
                url.Support     = "http://gta5police.com/forums/index.php?/support/";
                url.Suggestions = "https://gta5police.com/forums/index.php?/forum/5-suggestions/";
                url.Donate      = "http://gta5police.com/forums/index.php?/donate/";
                url.Vacbanned   = "http://www.vacbanned.com";

                url.Applications = "https://goo.gl/DpTEyH";
                url.Whitelist    = "https://goo.gl/TLSGdf";
                url.Police       = "https://goo.gl/RYNDBA";
                url.EMS          = "https://goo.gl/vNzGvr";
                url.Mechanic     = "https://goo.gl/rChgek";
                url.Taxi         = "https://goo.gl/DbThWg";
                url.Stream       = "https://goo.gl/EPZpNR";

                url.Logo       = "https://cdn.discordapp.com/attachments/336338554424918017/353934612503855115/GTA5Police_Main.png";
                url.Rules      = "http://goo.gl/7app1D";
                url.HowWeBan   = "https://puu.sh/yG7Nv.png";
                url.ClearCache = "https://gta5police.com/forums/index.php?/topic/921-how-to-clear-fivem-cache/";

                url.Save();
                Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "URL configuration generated"));
            }
            Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "URL configuration has been loaded"));

            if (!File.Exists(devConfigLoc))
            {
                var config = new DevConfig();

                config.DevReports  = 394177874657148940;
                config.Devs        = 0;
                config.Suggestions = 366955141771034625;
                config.Save();
                Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Dev config generated"));
            }
            Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Developer configuration has been loaded"));

            if (!File.Exists(ranksConfigLoc))
            {
                var config = new RanksConfig();
                config.EMSHighRanks = 4;
                config.PDHighRanks  = 5;
                config.Save();
                Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Ranks configuration generated"));
            }
            Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Ranks configuration has been loaded"));

            if (!File.Exists(autoBansLoc))
            {
                var config = new AutoBans();

                config.Bans = 0;
                config.Save();
                Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Auto bans generated"));
            }
            Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Auto bans has been loaded"));
        }
Beispiel #11
0
        public static void EnsureBotConfigExists()
        {
            if (!Directory.Exists(Path.Combine(AppContext.BaseDirectory, "configuration")))
            {
                Directory.CreateDirectory(Path.Combine(AppContext.BaseDirectory, "configuration"));
            }

            string configLoc   = Path.Combine(AppContext.BaseDirectory, "configuration/config.json");
            string ranksLoc    = Path.Combine(AppContext.BaseDirectory, "configuration/ranks.json");
            string subRanksLoc = Path.Combine(AppContext.BaseDirectory, "configuration/sub_ranks.json");

            if (!File.Exists(configLoc))
            {
                var config = new BotConfig();

                Console.WriteLine("Please enter the following information to save into your configuration/config.json file");
                Console.Write("Bot Token: ");
                config.Token = Console.ReadLine();
                Console.Write("Bot Prefix: ");
                config.Prefix = Console.ReadLine();
                Console.WriteLine("New Member Rank: ");
                config.NewMemberRank = Console.ReadLine();
                Console.WriteLine("User Rank: ");
                config.UserRank = Console.ReadLine();
                Console.WriteLine("Music Rank: ");
                config.MusicRank = Console.ReadLine();
                Console.WriteLine("Programming Rank: ");
                config.ProgrammingRank = Console.ReadLine();
                Console.WriteLine("Graphics Rank: ");
                config.GraphicsRank     = Console.ReadLine();
                config.welcomeChannelId = 0;
                config.Messages         = 1;
                config.Members          = 1;
                Console.WriteLine("You will have to enter the config file to manually set welcomeChannelId, Messages and Members. (configuration/config.json)");
                config.Save();
            }
            Console.WriteLine("Configuration has been loaded");

            if (!File.Exists(ranksLoc))
            {
                var ranks = new RankSaves();
                ranks.newMembersCount  = 0;
                ranks.userCount        = 0;
                ranks.musicCount       = 0;
                ranks.programmingCount = 0;
                ranks.graphicsCount    = 0;
                Console.WriteLine("You will have to enter the ranks save file to manually set the beginning statistics. (configuration/ranks.json)");
                ranks.Save();
            }
            Console.WriteLine("Ranks have been loaded");

            if (!File.Exists(subRanksLoc))
            {
                var subRanks = new SubRanksSaves();
                subRanks.MaxRanks = 20;
                subRanks.SubRanks = 1;
                Console.WriteLine("You will have to enter the sub ranks save file to manually set the beginning statistics. (configuration/sub_ranks.json)");
                subRanks.Save();
            }
            Console.WriteLine("Sub ranks have been loaded");
        }