public static async Task WarningMessageAsync(SocketMessage pMsg, string word) { var message = pMsg as SocketUserMessage; await message.DeleteAsync(); var user = pMsg.Author; var warningEmbed = new EmbedBuilder() { Color = Colours.errorCol }; warningEmbed.WithAuthor("Profanity Detected!", References.GetGta5policeLogo()); warningEmbed.Description = user + " | Do not use that profanity, your message has been deleted."; var msg = await pMsg.Channel.SendMessageAsync("", false, warningEmbed); await Delete.DelayDeleteEmbedAsync(msg, 10); Statistics.AddOutgoingMessages(); }
public async Task RulesAsync() { var channel = Context.Channel; var user = Context.User; await Context.Message.DeleteAsync(); TimeSpan last = Cooldowns.GetRulesLast(); TimeSpan current = DateTime.Now.TimeOfDay; double difference = current.TotalSeconds - last.TotalSeconds; if (difference >= Cooldowns.GetCommandCooldown() || difference < 0) { var embed = new EmbedBuilder() { Color = Colours.generalCol }; embed.WithAuthor("GTA5Police Rules", References.GetGta5policeLogo()); embed.Title = "Click to view all GTA5Police rules."; embed.Description = "**Teamspeak IP: gta5police.com**"; embed.WithUrl(References.GetRulesURL()); embed.WithThumbnailUrl(References.GetGta5policeLogo()); embed.WithImageUrl(References.GetHowBanURL()); embed.WithFooter("Requested by " + Context.User); embed.WithCurrentTimestamp(); var message = await Context.Channel.SendMessageAsync("", false, embed); await Delete.DelayDeleteEmbedAsync(message, (int)Cooldowns.GetCommandCooldown()); await Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Commands", "Rules command was used by " + user + ".")); Cooldowns.SetRulesLast(current); Statistics.AddOutgoingMessages(); } else { await errors.sendErrorTempAsync(channel, user + errorMessage + "\nCooldown " + difference + "/" + Cooldowns.GetCommandCooldown() + " seconds", Colours.errorCol); } }
public async Task DevAddCommandAsync(IUser developer) { for (int i = 0; i <= BotConfig.Load().Commanders - 1; i++) { if (Context.User.Id == BotConfig.Load().BotCommanders[i]) { var dev = developer.Id; DevConfig devConfig = new DevConfig(); devConfig = Update.UpdateDevConfig(devConfig); devConfig.Developers[DevConfig.Load().Devs] = dev; devConfig.Devs = DevConfig.Load().Devs + 1; devConfig.Save(); var embed = new EmbedBuilder() { Color = Colours.adminCol }; embed.WithAuthor("Successfully Added", References.GetGta5policeLogo()); embed.WithThumbnailUrl(References.GetGta5policeLogo()); embed.Description = "The developer " + developer + " was successfully added."; 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", "Dev add command was used by " + Context.User + ".")); Statistics.AddOutgoingMessages(); } } }
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(); } } }
/** Display the status of the servers in the text channel. **/ public async Task DisplayStatusAsync(IMessageChannel channel, IUser user) { if (mainStatus) { String newyork, losangeles, newyorkWhitelist, losangelesWhitelist; if (isNyLive) { newyork = "Online using Port: " + nyPort; } else { newyork = "Offline"; } if (isLaLive) { losangeles = "Online using Port: " + laPort; } else { losangeles = "Offline"; } if (isNyWlLive) { newyorkWhitelist = "Online using Port: " + nyWlPort; } else { newyorkWhitelist = "Offline"; } if (isLaWlLive) { losangelesWhitelist = "Online using Port: " + laWlPort; } else { losangelesWhitelist = "Offline"; } var embed = new EmbedBuilder() { Color = Colours.generalCol }; embed.WithAuthor("Current Server Status", References.GetGta5policeLogo()); embed.WithDescription("IP: " + g5pIP + ":PORT"); embed.WithThumbnailUrl(References.GetGta5policeLogo()); embed.WithUrl("https://gta5police.com/panel/index.php"); var nyField = new EmbedFieldBuilder() { Name = "New York", Value = newyork }; var laField = new EmbedFieldBuilder() { Name = "Los Angeles", Value = losangeles }; var nyWlField = new EmbedFieldBuilder() { Name = "New York Whitelist", Value = newyorkWhitelist }; var laWlField = new EmbedFieldBuilder() { Name = "Los Angeles Whitelist", Value = losangelesWhitelist }; embed.AddField(nyField); embed.AddField(laField); embed.AddField(nyWlField); embed.AddField(laWlField); embed.WithFooter(new EmbedFooterBuilder() { Text = "Requested by " + user }); embed.WithCurrentTimestamp(); var message = await channel.SendMessageAsync("", false, embed); await Delete.DelayDeleteEmbedAsync(message, (int)Cooldowns.GetCommandCooldown()); } else { var embed = new EmbedBuilder() { Color = Colours.errorCol }; embed.WithAuthor("Current Server Status", References.GetGta5policeLogo()); embed.WithThumbnailUrl(References.GetGta5policeLogo()); embed.WithUrl("https://gta5police.com/panel/index.php"); embed.AddField(new EmbedFieldBuilder() { Name = "OFFLINE", Value = "GTA5Police servers are currently down, check back later for an update!" }); embed.WithFooter(new EmbedFooterBuilder() { Text = "Requested by " + user }); embed.WithCurrentTimestamp(); var message = await channel.SendMessageAsync("", false, embed); await Delete.DelayDeleteEmbedAsync(message, (int)Cooldowns.GetCommandCooldown()); } }
public async Task UptimeAsync() { var channel = Context.Channel; var user = Context.User; await Context.Message.DeleteAsync(); TimeSpan last = Cooldowns.GetUptimeLast(); TimeSpan current = DateTime.Now.TimeOfDay; double difference = current.TotalSeconds - last.TotalSeconds; TimeSpan uptimeTime = DateTime.Now.TimeOfDay - Cooldowns.GetStartupTime(); int startHours = uptimeTime.Hours; if (startHours < 0) { startHours = startHours + 24; } int startMinutes = uptimeTime.Minutes; int startSeconds = uptimeTime.Seconds; int startDays = DateTime.Now.Date.Day - Cooldowns.GetStartupDate().Day; if (startDays < 0) { startDays = ((startDays - startDays) - startDays); int startMonth = Cooldowns.GetStartupDate().Month; int startYear = Cooldowns.GetStartupDate().Year; int maxDaysInMonth = DateTime.DaysInMonth(startYear, startMonth); int extraDays = maxDaysInMonth - Cooldowns.GetStartupDate().Day; startDays = startDays + extraDays; } if (difference >= Cooldowns.GetCommandCooldown() || difference < 0) { var embed = new EmbedBuilder() { Color = Colours.generalCol }; var blankField = new EmbedFieldBuilder() { Name = "\u200b", Value = "\u200b" }; embed.WithAuthor("Bot Uptime and Statistics", References.GetGta5policeLogo()); embed.WithDescription("Here are all the statistics since last startup.\n**Teamspeak IP: gta5police.com**"); embed.WithThumbnailUrl(References.GetGta5policeLogo()); embed.WithUrl("http://www.blurrdev.com/gta5police.html"); //embed.AddField(new EmbedFieldBuilder() { Name = "Bot Uptime", Value = DateTime.Now.TimeOfDay - Cooldowns.GetStartupTime() }); embed.AddField(new EmbedFieldBuilder() { Name = "Bot Uptime", Value = "Days: " + startDays + " | Hours: " + startHours + " | Minutes: " + startMinutes + " | Seconds: " + startSeconds }); embed.AddField(new EmbedFieldBuilder() { Name = "Incoming Messages", Value = Statistics.GetIncomingMessages(), IsInline = true }); embed.AddField(new EmbedFieldBuilder() { Name = "Outgoing Messages", Value = Statistics.GetOutgoingMessages(), IsInline = true }); embed.AddField(new EmbedFieldBuilder() { Name = "Command Requests", Value = Statistics.GetCommandRequests(), IsInline = true }); embed.AddField(new EmbedFieldBuilder() { Name = "Admen Requests", Value = Statistics.GetAdmenRequests(), IsInline = true }); embed.AddField(new EmbedFieldBuilder() { Name = "Oofers", Value = Statistics.GetOofMessages(), IsInline = true }); embed.AddField(new EmbedFieldBuilder() { Name = "Meta Messages", Value = Statistics.GetMetaMessages(), IsInline = true }); embed.AddField(blankField); embed.AddField(new EmbedFieldBuilder() { Name = "Profanity Detected", Value = Statistics.GetProfanityDetected(), IsInline = true }); embed.AddField(new EmbedFieldBuilder() { Name = "Errors Detected", Value = Statistics.GetErrorsDetected(), IsInline = true }); embed.AddField(new EmbedFieldBuilder() { Name = "Timer Messages", Value = Statistics.GetTimerMessages(), IsInline = true }); embed.AddField(new EmbedFieldBuilder() { Name = "Status Changes", Value = Statistics.GetStatusChanges(), IsInline = true }); embed.WithFooter("Requested by " + Context.User); embed.WithCurrentTimestamp(); var message = await Context.Channel.SendMessageAsync("", false, embed); await Delete.DelayDeleteEmbedAsync(message, (int)Cooldowns.GetCommandCooldown()); await Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Commands", "Uptime command was used by " + user + ".")); Cooldowns.SetUptimeLast(current); Statistics.AddOutgoingMessages(); } else { await errors.sendErrorTempAsync(channel, user + errorMessage + "\nCooldown " + difference + "/" + Cooldowns.GetCommandCooldown() + " seconds", Colours.errorCol); } }
public async Task ApplyAsync() { var channel = Context.Channel; var user = Context.User; await Context.Message.DeleteAsync(); TimeSpan last = Cooldowns.GetApplyLast(); TimeSpan current = DateTime.Now.TimeOfDay; double difference = current.TotalSeconds - last.TotalSeconds; if (difference >= Cooldowns.GetCommandCooldown() || difference < 0) { var embed = new EmbedBuilder() { Color = Colours.generalCol }; embed.WithAuthor("GTA5Police Applications", References.GetGta5policeLogo()); embed.WithUrl(References.GetApplicationsURL()); embed.Description = "Whitelist jobs and server applications.\n**Teamspeak IP: gta5police.com**"; embed.WithThumbnailUrl(References.GetGta5policeLogo()); embed.AddField(new EmbedFieldBuilder() { Name = "Whitelist Servers", Value = References.GetWhitelistURL() }); embed.AddField(new EmbedFieldBuilder() { Name = "Police", Value = References.GetPoliceURL() }); embed.AddField(new EmbedFieldBuilder() { Name = "EMS", Value = References.GetEmsURL() }); embed.AddField(new EmbedFieldBuilder() { Name = "Mechanic", Value = References.GetMechanicURL() }); embed.AddField(new EmbedFieldBuilder() { Name = "Taxi", Value = References.GetTaxiURL() }); embed.AddField(new EmbedFieldBuilder() { Name = "Stream Verification", Value = References.GetStreamURL() }); embed.WithFooter("Requested by " + Context.User); embed.WithCurrentTimestamp(); var message = await Context.Channel.SendMessageAsync("", false, embed); await Delete.DelayDeleteEmbedAsync(message, (int)Cooldowns.GetCommandCooldown()); await Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Commands", "Apply command was used by " + user + ".")); Cooldowns.SetApplyLast(current); Statistics.AddOutgoingMessages(); } else { await errors.sendErrorTempAsync(channel, user + errorMessage + "\nCooldown " + difference + "/" + Cooldowns.GetCommandCooldown() + " seconds", Colours.errorCol); } }
public async Task LinksAsync() { var channel = Context.Channel; var user = Context.User; await Context.Message.DeleteAsync(); TimeSpan last = Cooldowns.GetLinksLast(); TimeSpan current = DateTime.Now.TimeOfDay; double difference = current.TotalSeconds - last.TotalSeconds; if (difference >= Cooldowns.GetCommandCooldown() || difference < 0) { var embed = new EmbedBuilder() { Color = Colours.generalCol }; embed.WithAuthor("GTA5Police Links", References.GetGta5policeLogo()); embed.Description = "Useful GTA5Police links for you.\n**Teamspeak IP: gta5police.com**"; embed.WithThumbnailUrl(References.GetGta5policeLogo()); embed.AddField(new EmbedFieldBuilder() { Name = "Website", Value = References.GetWebsiteURL() }); embed.AddField(new EmbedFieldBuilder() { Name = "Dashboard", Value = References.GetDashboardURL() }); embed.AddField(new EmbedFieldBuilder() { Name = "Forums", Value = References.GetForumsURL() }); embed.AddField(new EmbedFieldBuilder() { Name = "Support", Value = References.GetSupportURL() }); embed.AddField(new EmbedFieldBuilder() { Name = "Suggestions", Value = References.GetSuggestionsURL() }); embed.AddField(new EmbedFieldBuilder() { Name = "Donations", Value = References.GetDonateURL() }); embed.AddField(new EmbedFieldBuilder() { Name = "Vacbanned - For Steam Hex", Value = References.GetVacbannedURL() }); embed.AddField(new EmbedFieldBuilder() { Name = "Greggs", Value = "https://www.greggs.co.uk/" }); embed.WithFooter("Requested by " + Context.User); embed.WithCurrentTimestamp(); var message = await Context.Channel.SendMessageAsync("", false, embed); await Delete.DelayDeleteEmbedAsync(message, (int)Cooldowns.GetCommandCooldown()); await Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Commands", "Links command was used by " + user + ".")); Cooldowns.SetLinksLast(current); Statistics.AddOutgoingMessages(); } else { await errors.sendErrorTempAsync(channel, user + errorMessage + "\nCooldown " + difference + "/" + Cooldowns.GetCommandCooldown() + " seconds", Colours.errorCol); } }
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(); } } }