コード例 #1
0
        public async Task MechAddAsync(IGuildUser user = null, [Remainder] IRole rank = null)
        {
            if (BotConfig.Load().PoliceAdd)
            {
                Statistics.AddCommandRequests();

                var  author = Context.Message.Author as SocketGuildUser;
                bool isHigh = false;

                for (int i = 0; i <= RanksConfig.Load().MechHighRanks - 1; i++)
                {
                    var role = (author as IGuildUser).Guild.Roles.FirstOrDefault(x => x.Name == RanksConfig.Load().MechHighRanksArray[i]);
                    if (author.Roles.Contains(role))
                    {
                        isHigh = true;
                    }
                }

                if (isHigh)
                {
                    await Context.Message.DeleteAsync();

                    Errors errors = new Errors();



                    if (user == null)
                    {
                        await errors.sendErrorTempAsync(Context.Channel, "Please enter the user you would like to add.", Colours.errorCol);
                    }
                    if (rank == null)
                    {
                        await errors.sendErrorTempAsync(Context.Channel, "Please enter the rank you would like to add the user to.", Colours.errorCol);
                    }

                    Success success = new Success();
                    if (user != null && rank != null)
                    {
                        if (rank.Name.ToLower().Equals("probationary tech") || rank.Name.ToLower().Equals("technician") || rank.Name.ToLower().Equals("senior tech"))
                        {
                            await user.AddRoleAsync(rank);

                            await success.sendSuccessTempAsync(Context.Channel, "Successful!", "Successfully added " + user + " to " + rank + "!", Colours.adminCol);

                            var role = (author as IGuildUser).Guild.Roles.FirstOrDefault(x => x.Name == "Civilian");
                            if (user.Guild.Roles.Contains(role))
                            {
                                await user.RemoveRoleAsync(role);
                            }
                        }
                        else
                        {
                            await errors.sendErrorTempAsync(Context.Channel, "That isn't even a mechanic rank you fool!", Colours.errorCol);
                        }
                    }
                }
            }
        }
コード例 #2
0
        public async Task PoliceRemAsync(IGuildUser user = null, string squad = null, [Remainder] IRole rank = null)
        {
            if (BotConfig.Load().PoliceAdd)
            {
                Statistics.AddCommandRequests();

                var  author = Context.Message.Author as SocketGuildUser;
                bool isHigh = false;

                for (int i = 0; i <= RanksConfig.Load().PDHighRanks - 1; i++)
                {
                    var role = (author as IGuildUser).Guild.Roles.FirstOrDefault(x => x.Name == RanksConfig.Load().PDHighRanksArray[i]);
                    if (author.Roles.Contains(role))
                    {
                        isHigh = true;
                    }
                }

                if (isHigh)
                {
                    await Context.Message.DeleteAsync();

                    Errors errors  = new Errors();
                    var    alpha   = Context.Guild.Roles.FirstOrDefault(x => x.Name == "Alpha Squad");
                    var    bravo   = Context.Guild.Roles.FirstOrDefault(x => x.Name == "Bravo Squad");
                    var    charlie = Context.Guild.Roles.FirstOrDefault(x => x.Name == "Charlie Squad");
                    //var delta = Context.Guild.Roles.FirstOrDefault(x => x.Name == "Delta Squad");

                    if (user == null)
                    {
                        await errors.sendErrorTempAsync(Context.Channel, "Please enter the user you would like to remove.", Colours.errorCol);
                    }
                    if (user == null)
                    {
                        await errors.sendErrorTempAsync(Context.Channel, "Please enter the rank you would like to remove from the user to.", Colours.errorCol);
                    }
                    if (squad == null)
                    {
                        await errors.sendErrorTempAsync(Context.Channel, "Please enter the squad letter you would like to remove from the user to.", Colours.errorCol);
                    }
                    if (!squad.ToLower().Equals("a"))
                    {
                        await errors.sendErrorTempAsync(Context.Channel, "Please enter the squad letter you would like to remove the user from.", Colours.errorCol);
                    }
                    if (!squad.ToLower().Equals("b"))
                    {
                        await errors.sendErrorTempAsync(Context.Channel, "Please enter the squad letter you would like to remove the user from.", Colours.errorCol);
                    }
                    if (!squad.ToLower().Equals("c"))
                    {
                        await errors.sendErrorTempAsync(Context.Channel, "Please enter the squad letter you would like to remove the user from.", Colours.errorCol);
                    }
                    //if (!squad.ToLower().Equals("d")) await errors.sendErrorTempAsync(Context.Channel, "Please enter the squad letter you would like to remove the user from.", Colours.errorCol);
                    if (alpha == null)
                    {
                        await errors.sendErrorTempAsync(Context.Channel, "alpha == null", Colours.errorCol);
                    }
                    if (bravo == null)
                    {
                        await errors.sendErrorTempAsync(Context.Channel, "bravo == null", Colours.errorCol);
                    }
                    if (charlie == null)
                    {
                        await errors.sendErrorTempAsync(Context.Channel, "charlie == null", Colours.errorCol);
                    }
                    //if (delta == null) await errors.sendErrorTempAsync(Context.Channel, "delta == null", Colours.errorCol);

                    Success success = new Success();
                    if (user != null && rank != null)
                    {
                        if (rank.Name.ToLower().Equals("police officer") || rank.Name.ToLower().Equals("police sergeant"))
                        {
                            await user.RemoveRoleAsync(rank);

                            await user.AddRoleAsync(Context.Guild.Roles.FirstOrDefault(x => x.Name == "Civilian"));

                            if (squad.ToLower().Equals("a"))
                            {
                                await user.RemoveRoleAsync(alpha);
                            }
                            if (squad.ToLower().Equals("b"))
                            {
                                await user.RemoveRoleAsync(bravo);
                            }
                            if (squad.ToLower().Equals("c"))
                            {
                                await user.RemoveRoleAsync(charlie);
                            }
                            //if (squad.ToLower().Equals("d")) await user.RemoveRoleAsync(delta);
                            await success.sendSuccessTempAsync(Context.Channel, "Successful!", "Successfully removed " + user + " from " + rank + "!", Colours.adminCol);
                        }
                        else
                        {
                            await errors.sendErrorTempAsync(Context.Channel, "That isn't even a police rank you fool!", Colours.errorCol);
                        }
                    }
                }
            }
        }
コード例 #3
0
        public async Task SettingsCommandAsync()
        {
            for (int i = 0; i <= BotConfig.Load().Commanders - 1; i++)
            {
                if (BotConfig.Load().BotCommanders[i] == Context.User.Id)
                {
                    var embed = new EmbedBuilder()
                    {
                        Color = Colours.adminCol
                    };
                    var blankField = new EmbedFieldBuilder()
                    {
                        Name = "\u200b", Value = "\u200b"
                    };

                    embed.WithAuthor("GTA5PoliceV2 Settings", References.GetGta5policeLogo());
                    embed.WithThumbnailUrl(References.GetGta5policeLogo());

                    string filtered = null;
                    for (int j = 0; j <= BotConfig.Load().Filters - 1; j++)
                    {
                        var filter = BotConfig.Load().FilteredWords[j].ToString();
                        if (filtered != null)
                        {
                            filtered = filtered + ", " + filter;
                        }
                        if (filtered == null)
                        {
                            filtered = filter;
                        }
                    }
                    if (filtered != null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "Filtered Words", Value = filtered, IsInline = true
                        });
                    }
                    if (filtered == null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "Filtered Words", Value = "No filtered words.", IsInline = true
                        });
                    }

                    string commanders = null;
                    for (int j = 0; j <= BotConfig.Load().Commanders - 1; j++)
                    {
                        var commander = Context.Client.GetUserAsync(BotConfig.Load().BotCommanders[j]).Result.ToString();
                        if (commanders != null)
                        {
                            commanders = commanders + ", " + commander;
                        }
                        if (commanders == null)
                        {
                            commanders = commander;
                        }
                    }
                    if (commanders != null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "Bot commanders", Value = commanders, IsInline = true
                        });
                    }
                    if (commanders == null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "Bot commanders", Value = "No commanders.", IsInline = true
                        });
                    }


                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Server Id", Value = BotConfig.Load().ServerId, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Logs Id", Value = BotConfig.Load().LogsId, IsInline = true
                    });
                    embed.AddField(blankField);
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Timer Channel Id", Value = BotConfig.Load().TimerChannelId, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Status Timer Interval (Minutes)", Value = BotConfig.Load().StatusTimerInterval, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Message Timer Interval (Minutes)", Value = BotConfig.Load().MessageTimerInterval, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Message Timer Cooldown (Messages)", Value = BotConfig.Load().MessageTimerCooldown, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Command Cooldown (Seconds)", Value = BotConfig.Load().CommandCooldown, IsInline = true
                    });
                    embed.AddField(blankField);
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Server IP", Value = ConnectionsConfig.Load().ServerIp, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "NY Port", Value = ConnectionsConfig.Load().NyPort, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "LA Port", Value = ConnectionsConfig.Load().LaPort, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "NY WL Port", Value = ConnectionsConfig.Load().NyWlPort, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "LA WL Port", Value = ConnectionsConfig.Load().LaWlPort, IsInline = true
                    });

                    embed.AddField(blankField);
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "EMS Add/Remove", Value = BotConfig.Load().EmsAdd, IsInline = true
                    });
                    string emsHighUps = null;
                    for (int j = 0; j <= RanksConfig.Load().EMSHighRanks - 1; j++)
                    {
                        var emsHighUp = RanksConfig.Load().EMSHighRanksArray[j];
                        if (emsHighUps != null)
                        {
                            emsHighUps = emsHighUps + ", " + emsHighUp;
                        }
                        if (emsHighUps == null)
                        {
                            emsHighUps = emsHighUp;
                        }
                    }
                    if (commanders != null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "EMS Highup Ranks", Value = emsHighUps, IsInline = true
                        });
                    }
                    if (commanders == null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "EMS Highup Ranks", Value = "No high up ranks?", IsInline = true
                        });
                    }

                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Cop Add/Remove", Value = BotConfig.Load().PoliceAdd, IsInline = true
                    });
                    string copHighUps = null;
                    for (int j = 0; j <= RanksConfig.Load().PDHighRanks - 1; j++)
                    {
                        var copHighUp = RanksConfig.Load().PDHighRanksArray[j];
                        if (copHighUps != null)
                        {
                            copHighUps = copHighUps + ", " + copHighUp;
                        }
                        if (copHighUps == null)
                        {
                            copHighUps = copHighUp;
                        }
                    }
                    if (commanders != null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "Police Highup Ranks", Value = copHighUps, IsInline = true
                        });
                    }
                    if (commanders == null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "Police Highup Ranks", Value = "No high up ranks?", IsInline = true
                        });
                    }

                    embed.AddField(blankField);
                    string devs = null;
                    for (int j = 0; j <= DevConfig.Load().Devs - 1; j++)
                    {
                        var dev = Context.Client.GetUserAsync(DevConfig.Load().Developers[j]).Result.ToString();
                        if (devs != null)
                        {
                            devs = devs + ", " + dev;
                        }
                        if (devs == null)
                        {
                            devs = dev;
                        }
                    }
                    if (devs != null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "Developers", Value = devs, IsInline = true
                        });
                    }
                    if (devs == null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "Developers", Value = "No developers added", IsInline = true
                        });
                    }

                    embed.WithFooter(new EmbedFooterBuilder()
                    {
                        Text = References.NAME + References.VERSION
                    });
                    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 Configuration Commands", "Settings command was used by " + Context.User + "."));

                    Statistics.AddOutgoingMessages();
                }
            }
        }
コード例 #4
0
        public async Task EmsRemAsync(IGuildUser user = null, int station = 0, [Remainder] IRole rank = null)
        {
            if (BotConfig.Load().EmsAdd)
            {
                Statistics.AddCommandRequests();

                var  author = Context.Message.Author as SocketGuildUser;
                bool isHigh = false;

                for (int i = 0; i <= RanksConfig.Load().EMSHighRanks - 1; i++)
                {
                    var role = (author as IGuildUser).Guild.Roles.FirstOrDefault(x => x.Name == RanksConfig.Load().EMSHighRanksArray[i]);
                    if (author.Roles.Contains(role))
                    {
                        isHigh = true;
                    }
                }

                if (isHigh)
                {
                    await Context.Message.DeleteAsync();

                    Errors errors   = new Errors();
                    var    station1 = Context.Guild.Roles.FirstOrDefault(x => x.Name == "EMS Station 1");
                    var    station2 = Context.Guild.Roles.FirstOrDefault(x => x.Name == "EMS Station 2");

                    if (user == null)
                    {
                        await errors.sendErrorTempAsync(Context.Channel, "Please enter the user you would like to remove.", Colours.errorCol);
                    }
                    if (user == null)
                    {
                        await errors.sendErrorTempAsync(Context.Channel, "Please enter the rank you would like to remove the user to.", Colours.errorCol);
                    }
                    if (station <= 0 || station >= 3)
                    {
                        await errors.sendErrorTempAsync(Context.Channel, "Please enter the station you would like to remove the user from.", Colours.errorCol);
                    }
                    if (station1 == null)
                    {
                        await errors.sendErrorTempAsync(Context.Channel, "Station1 == null", Colours.errorCol);
                    }
                    if (station2 == null)
                    {
                        await errors.sendErrorTempAsync(Context.Channel, "Station2 == null", Colours.errorCol);
                    }

                    Success success = new Success();
                    if (user != null && rank != null)
                    {
                        if (rank.Name.ToLower().Equals("emr") || rank.Name.ToLower().Equals("emt") || rank.Name.ToLower().Equals("ems paramedic"))
                        {
                            await user.RemoveRoleAsync(rank);

                            await user.AddRoleAsync(Context.Guild.Roles.FirstOrDefault(x => x.Name == "Civilian"));

                            if (station == 1)
                            {
                                await user.RemoveRoleAsync(station1);
                            }
                            if (station == 2)
                            {
                                await user.RemoveRoleAsync(station2);
                            }
                            await success.sendSuccessTempAsync(Context.Channel, "Successful!", "Successfully removed " + user + " from " + rank + "!", Colours.adminCol);
                        }
                        else
                        {
                            await errors.sendErrorTempAsync(Context.Channel, "That isn't even a ems rank you fool!", Colours.errorCol);
                        }
                    }
                }
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: CourtneyKitty/GTA5PoliceV2
        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"));
        }