private async Task BlurrIsBlurr() { var delete = Task.Run(async() => { var blurr = bot.Guilds.FirstOrDefault(x => x.Id == BotConfig.Load().ServerId).Users.FirstOrDefault(x => x.Id == 211938243535568896); bool running = true; string[] names = { "Blurr", "BlurrDev", "IPLEBBIE", "Plebble", "Dead Chips", "Big motherfucking pug", "I'm a bot, not a machine.", "Develoblurr" }; while (running) { Random rnd = new Random(); await blurr.ModifyAsync(x => x.Nickname = names[rnd.Next(0, names.Length)]); await Task.Delay(60 * (60 * 1000)); } }); /* * var colour = Task.Run(async () => * { * var botRole = bot.Guilds.FirstOrDefault(x => x.Id == BotConfig.Load().ServerId).Roles.FirstOrDefault(x => x.Name == "Bot"); * bool running = true; * Color[] colours = { new Color(195, 27, 27), new Color(27, 80, 221)/*, new Color(14, 140, 32) }; * * while (running) * { * Random rnd = new Random(); * await botRole.ModifyAsync(x => x.Color = colours[rnd.Next(0, colours.Length)]); * await Task.Delay(60*(60*1000)); * } * }); */ }
private async Task BinaryAsync([Remainder] string text = null) { await Context.Message.DeleteAsync(); if (text != null) { var binary = ToBinary(ConvertToByteArray(text, Encoding.ASCII)); EmbedBuilder embed = new EmbedBuilder() { Title = $"Text to Binary", Description = $"''{text}''\n\n{binary}", Color = Color.DarkPurple }; embed.Footer = new EmbedFooterBuilder() { Text = $"{EmojiUtil.GetRandomEmoji()} Requested by {Context.User.Username}#{Context.User.Discriminator}." }; await Context.Channel.SendMessageAsync(null, false, embed.Build()); } else { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}binary <message>`", false); return; } }
private async Task ComplimentsAsync(IUser user = null) { await Context.Message.DeleteAsync(); if (user == null) { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}compliment <@user>`", false); return; } Random rnd = new Random(); if (Context.User.Id != user.Id) { List <FunObject> compliments = await FunDatabase.GetOfTypeAsync("compliment"); int d = rnd.Next(0, compliments.Count); string compliment = compliments[d].Text.Replace("USER", StringUtil.ToUppercaseFirst(user.Mention)); await Context.Channel.SendMessageAsync(compliment); } else { List <FunObject> roasts = await FunDatabase.GetOfTypeAsync("roast"); int d = rnd.Next(0, roasts.Count); string roast = roasts[d].Text.Replace("USER", StringUtil.ToUppercaseFirst(user.Mention)); await Context.Channel.SendMessageAsync(roast); } }
private async Task UptimeAsync() { await Context.Message.DeleteAsync(); BotConfig conf = BotConfig.Load(); DateTime time = DateTime.UtcNow; int minutes = (int)((time - conf.LastStartup).TotalMinutes); int uptime = 0; string m = "minutes"; if (minutes >= 60) { uptime = minutes / 60; m = "hours"; } else { uptime = minutes; } EmbedBuilder embed = new EmbedBuilder() { Title = "Lori's Angels Statistics", Color = Color.DarkPurple, Description = $"Lori's Angel has been online since {time}, thats an uptime of {uptime} {m}!", Footer = new EmbedFooterBuilder() { Text = $"{EmojiUtil.GetRandomEmoji()} Requested by {Context.User.Username}#{Context.User.Id}" } }; await Context.Channel.SendMessageAsync(null, false, embed.Build()); }
public static void Start() { botConfig = BotConfig.Load(); if (botConfig == null) { Console.WriteLine("Please fill the config file with valid details, and run again"); } else { SQL.pubInstance = new SQL(botConfig.sql_Username, "sys", botConfig.sql_Password, botConfig.sql_Server); string[] Channels = CurrencyParticipant.FromTable <CurrencyParticipant>("currency_participants").Select(x => x.twitch_name).ToArray(); tBot = new Twitch(botConfig.twitch_Username, botConfig.twitch_token, Channels, '>'); tBot.MessageHandler += ChatEvents.HandleMessage; tBot.CommandHandler += ChatEvents.HandleCommand; dBot = new DTBot_Template.Discord(botConfig.discord_Token, '>'); dBot.MessageHandler += ChatEvents.HandleMessage; dBot.CommandHandler += ChatEvents.HandleCommand; Console.WriteLine("Bots Started"); new Thread(() => Rewards.RewardChecker()).Start(); } }
public async Task HandleCommand(SocketMessage pMsg) { //Don't handle the command if it is a system message var message = pMsg as SocketUserMessage; if (message == null) { return; } var context = new SocketCommandContext(bot, message); //Mark where the prefix ends and the command begins int argPos = 0; //Determine if the message has a valid prefix, adjust argPos if (message.HasStringPrefix(BotConfig.Load().Prefix, ref argPos)) { if (message.Author.IsBot) { return; } //Execute the command, store the result var result = await commands.ExecuteAsync(context, argPos, map); //If the command failed, notify the user if (!result.IsSuccess && result.ErrorReason != "Unknown command.") { await message.Channel.SendMessageAsync($"**Error:** {result.ErrorReason}"); } } }
public async Task CreateAsync() { await Context.Message.DeleteAsync(); // Create globals category var cat = await Context.Guild.CreateCategoryAsync("Globals"); var dbCon = DBConnection.Instance(); dbCon.DatabaseName = BotConfig.Load().DatabaseName; if (dbCon.IsConnect()) { for (int i = 0; i < ChannelData.Channels.Count; i++) { if (ServerConfig.GetChannelState(Context.Guild.Id, ChannelData.Channels[i].IndexToggle, dbCon) == true) { var chan = await Context.Guild.CreateTextChannelAsync(ChannelData.Channels[i].Name); await chan.ModifyAsync(x => x.CategoryId = cat.Id); await ServerConfig.SetupChannel(Context.Guild.Id, chan.Id, ChannelData.Channels[i].Id, dbCon); } } dbCon.Close(); } var Message = await Context.Channel.SendMessageAsync("Setup completed, use the `!update` command again to disable/enable channels in the future, once you disable or enable servers, use the `!update` command."); await Delete.DeleteMessage(Message); }
public async Task BanUserAsync(IUser user, [Remainder] string reason) { if (user != null) { if (reason != null) { await Context.Guild.AddBanAsync(user, 0, reason); var embed = new EmbedBuilder() { Color = Colors.adminCol }; embed.Title = $"**{user.Username}** has been banned!"; embed.Description = $"**Username: **{user.Username}\n**Guild Name: **{Context.Guild.Name}\n**Banned By: **{Context.User.Mention}!\n**Reason: **{reason}"; embed.WithFooter("Time: " + DateTime.Now + " | Ban Log"); var channel = await Context.Guild.GetTextChannelAsync(BotConfig.Load().BotLogs); await channel.SendMessageAsync("", false, embed.Build()); } else { await error.sendError(Context.Channel, "Incorrect Command Usage: " + BotConfig.Load().Prefix + "ban @user#1234 Reason", Colors.errorCol); } } else { await error.sendError(Context.Channel, "Incorrect Command Usage: " + BotConfig.Load().Prefix + "ban @user#1234 Reason", Colors.errorCol); } }
public async Task DeleteLastAsync() { var dbCon = DBConnection.Instance(); dbCon.DatabaseName = BotConfig.Load().DatabaseName; if (dbCon.IsConnect()) { string ChannelInUse = await Message.GetGlobalChannelInUseAsync(Context.Guild.Id, Context.Channel.Id, dbCon); if (!ChannelInUse.Equals("")) { await Context.Message.DeleteAsync(); var messages = Message.GetMessageByUserAsync(Context.User, dbCon, ChannelInUse).Result; var remove = Task.Run(async() => { foreach (var message in messages) { if (message != null) { foreach (var embed in message.Embeds) { await(message as IUserMessage).ModifyAsync(x => x.Embed = embed.ToEmbedBuilder().WithDescription("").WithFooter("Removed by user at " + DateTime.UtcNow.ToString()).Build()); await Task.Delay(1100); } } } }); } dbCon.Close(); } }
private async Task CheckConfigsAsync() { BotConfig conf = BotConfig.Load(); if (configType == ConfigType.Individual) { foreach (var guild in GetBot().Guilds) { IndividualConfig gconf = conf.GetConfig(guild.Id); if (gconf == null) { gconf = conf.FreshConfig(guild.Id); conf.Configs.Add(gconf); } } } await Util.LoggerAsync(new LogMessage(LogSeverity.Info, "Gateway", $"Successfully connected to {bot.Guilds.Count} guilds")); conf.LastStartup = DateTime.UtcNow; conf.Save(); var restart = Task.Run(async() => { await Task.Delay(RestartEveryMs); // Code to restart bot Process.Start(AppContext.BaseDirectory + ExecutableName + ".exe"); // Close this instance Environment.Exit(0); }); }
public static async Task CheckMessageAsync(SocketMessage message) { IndividualConfig config = BotConfig.Load().GetConfig((message.Channel as IGuildChannel).GuildId); if (!config.Censor) { return; } if (message.Content.Length > 0) { string messageText = message.Content.ToLower(); foreach (string word in config.CensoredWords) { if (messageText.Contains(word)) { await message.Author.SendMessageAsync("Your message was deleted as it contained censored words."); if (config.LogActions) { var logChannel = await(message.Channel as IGuildChannel).Guild.GetTextChannelAsync(config.LogChannel); await logChannel.SendMessageAsync($"**Message deleted for profanity.**\nMessage from {message.Author.Mention} was deleted for containing the word '{word}'."); } await message.DeleteAsync(); return; } } } }
private async Task CensorAsync(string censor = null) { await Context.Message.DeleteAsync(); BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); if (censor == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}settings censor <True/False>`", false); return; } char c = censor.ToLower()[0]; if (c == 't') { gconf.Censor = true; conf.Save(); await Context.Channel.SendMessageAsync($"The message censor feature has been enabled in this guild."); } else if (c == 'f') { gconf.Censor = false; conf.Save(); await Context.Channel.SendMessageAsync($"The message censor feature has been disabled in this guild."); } else { await Context.Channel.SendMessageAsync($"Incorrect use of command: Please use the command as follows `" + gconf.Prefix + "settings censor true` or `" + gconf.Prefix + "settings censor false`"); } }
private async Task AddCensorAsync(string censor = null) { await Context.Message.DeleteAsync(); BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); if (censor == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}settings addcensor <word>`", false); return; } string word = censor.ToLower().Trim(); if (word != string.Empty) { gconf.AddCensoredWord(word); conf.Save(); await Context.Channel.SendMessageAsync($"The word {word} has been added to the guilds censor."); } else { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}settings addcensor <word>`", false); return; } }
public async Task HelpGen() { await Context.Message.DeleteAsync(); var embed = new EmbedBuilder() { Color = Colours.helpCol }; embed.Title = ("Bruze MPG General Help"); embed.Description = (BotConfig.Load().Prefix + "ping - I like ping pong" + "\n" + BotConfig.Load().Prefix + "bot info - Displays information about me!" + "\n" + BotConfig.Load().Prefix + "messages count - Shows how many messages have been sent in this discord!" + "\n" + BotConfig.Load().Prefix + "members count - Shows how many members are in this discord!" + "\n" + BotConfig.Load().Prefix + "ranks - Shows how many members are in each rank" + "\n" + BotConfig.Load().Prefix + "help - I think you know this command" + "\n" + BotConfig.Load().Prefix + "rank add <user|music|programming|graphics> - Used to set your rank" + "\n" + BotConfig.Load().Prefix + "rank remove <user|music|programming|graphics> - Used to remove the rank" + "\n" + BotConfig.Load().Prefix + "subranks - View all sub ranks" + "\n" + BotConfig.Load().Prefix + "subrank add <rank> - Join the sub rank" + "\n" + BotConfig.Load().Prefix + "subrank remove <rank> - Leave the sub rank"); var message = await Context.Channel.SendMessageAsync("", false, embed); await Delete.DelayDeleteEmbed(message, 30); }
private async Task BankTransferAsync(IUser user = null, float amount = 0) { await Context.Message.DeleteAsync(); BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); if (user == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}bank transfer <@user> <amount>`", false); return; } if (amount <= 0) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Transfer Error", $"The amount must be greater than 0."); return; } LoriUser profile = ProfileDatabase.GetUser(Context.User.Id); if (profile == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Transfer Error", $"We could not find your bank account."); return; } LoriUser profile2 = ProfileDatabase.GetUser(user.Id); if (profile2 == null) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Transfer Error", $"We could not find {user.Username}'s bank account."); return; } if (profile.GetCurrency() >= amount) { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Transfer Error", "You can not afford this transfer."); return; } ProfileDatabase.AddCurrency(Context.User.Id, -amount); ProfileDatabase.AddCurrency(user.Id, amount); float newAmt = profile.GetCurrency(); EmbedBuilder embed = new EmbedBuilder() { Color = Color.DarkPurple, Title = "Transfer successful", Description = $"Successfully transferred ${amount} to {user.Username}.\nNew balance: ${newAmt}" }; await Context.Channel.SendMessageAsync(null, false, embed.Build()); }
public async Task BioAsync([Remainder] string bio = null) { await Context.Message.DeleteAsync(); if (bio != null) { if (!ProfanityFilter.HasProfanity(bio)) { var dbCon = DBConnection.Instance(); dbCon.DatabaseName = BotConfig.Load().DatabaseName; if (dbCon.IsConnect()) { var message = await Context.Channel.SendMessageAsync("Your bio has been updated successfully."); await Delete.DeleteMessage(message); await UserProfile.UpdateUserBioAsync(Context.User.Id, bio, dbCon); dbCon.Close(); } } } else { var message = await Context.Channel.SendMessageAsync("Correct format of this command is `!bio <bio_message>`, for example using mention `!bio A software engineer from London.`."); await Delete.DeleteMessage(message); } }
public async Task AnnounceUserJoined(SocketGuildUser user) { BotConfig config = new BotConfig(); config = Update.UpdateConfig(config); config.Members = BotConfig.Load().Members + 1; config.Save(); var ranks = new RankSaves(); ranks.newMembersCount = RankSaves.Load().newMembersCount + 1; ranks.userCount = RankSaves.Load().userCount; ranks.musicCount = RankSaves.Load().musicCount; ranks.programmingCount = RankSaves.Load().programmingCount; ranks.graphicsCount = RankSaves.Load().graphicsCount; ranks.Save(); var newMemberRank = BotConfig.Load().NewMemberRank; var role = user.Guild.Roles.FirstOrDefault(x => x.Name.ToString() == newMemberRank); await(user as IGuildUser).AddRoleAsync(role); var welcomeChannel = Context.Guild.GetChannelAsync(BotConfig.Load().welcomeChannelId); if (welcomeChannel != null) { var message = await Context.Channel.SendMessageAsync("Hey " + Context.User.Mention + ", read the above post, read the rules and then head into #bot-commands and get your roles to enter the full discord!"); await Delete.DelayDeleteMessage(message, 60); } else { await errors.sendErrorTemp(Context.Channel, "Welcome channel not found, make sure the config.json is set up correctly!", Colours.errorCol); } }
public async Task QuoteAsync([Remainder] string quote = null) { await Context.Message.DeleteAsync(); if (quote != null) { if (!ProfanityFilter.HasProfanity(quote)) { var dbCon = DBConnection.Instance(); dbCon.DatabaseName = BotConfig.Load().DatabaseName; if (dbCon.IsConnect()) { var message = await Context.Channel.SendMessageAsync("Your quote has been updated successfully."); await Delete.DeleteMessage(message); await UserProfile.UpdateUserQuoteAsync(Context.User.Id, quote, dbCon); dbCon.Close(); } } } else { var message = await Context.Channel.SendMessageAsync("Correct format of this command is `!quote <quote_message>`, for example using mention `!quote 'Most people go through life trying not to die, I go through life trying to live.'`."); await Delete.DeleteMessage(message); } }
public async Task UpdateAsync() { await Context.Message.DeleteAsync(); var cats = Context.Guild.GetCategoriesAsync().Result; ICategoryChannel cat = null; foreach (var category in cats) { if (category.Name.ToLower().Equals("globals")) { cat = category; } } if (cat != null) { var dbCon = DBConnection.Instance(); dbCon.DatabaseName = BotConfig.Load().DatabaseName; if (dbCon.IsConnect()) { for (int i = 0; i < ChannelData.Channels.Count; i++) { var chanId = ServerConfig.GetChannelId(Context.Guild.Id, ChannelData.Channels[i].IndexId, dbCon); if (ServerConfig.GetChannelState(Context.Guild.Id, ChannelData.Channels[i].IndexToggle, dbCon) == false && chanId != 0) { var chan = await Context.Guild.GetChannelAsync(chanId); if (chan != null) { await chan.DeleteAsync(); await ServerConfig.SetupChannel(Context.Guild.Id, 0, ChannelData.Channels[i].Id, dbCon); } } else if (ServerConfig.GetChannelState(Context.Guild.Id, ChannelData.Channels[i].IndexToggle, dbCon) == true && chanId == 0) { var chan = await Context.Guild.CreateTextChannelAsync(ChannelData.Channels[i].Name); await chan.ModifyAsync(x => x.CategoryId = cat.Id); await ServerConfig.SetupChannel(Context.Guild.Id, chan.Id, ChannelData.Channels[i].Id, dbCon); } } dbCon.Close(); } var message = await Context.Channel.SendMessageAsync("Your global channels should now be updated. Please use the `!request` command in a global channel, if you have any issues."); await Delete.DeleteMessage(message); } else { var message = await Context.Channel.SendMessageAsync("We couldn't find the globals category in your server, I suggest deleting all the global channels and category. Then run the `!create` command."); await Delete.DeleteMessage(message, 25000); } }
public async Task FactAsync([Remainder] string fact = null) { await Context.Message.DeleteAsync(); if (fact != null) { if (!ProfanityFilter.HasProfanity(fact)) { var dbCon = DBConnection.Instance(); dbCon.DatabaseName = BotConfig.Load().DatabaseName; if (dbCon.IsConnect()) { var message = await Context.Channel.SendMessageAsync("Your fact has been updated successfully."); await Delete.DeleteMessage(message); await UserProfile.UpdateUserFactAsync(Context.User.Id, fact, dbCon); dbCon.Close(); } } } else { var message = await Context.Channel.SendMessageAsync("Correct format of this command is `!fact <fact_message>`, for example using mention `!quote Birds have wings.`."); await Delete.DeleteMessage(message); } }
// Configuration 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. 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. config.Token = BotConfig.Load().Token; // //Secrets.DiscordBotToken; Console.Write("Bot Prefix: "); //config.Prefix = Console.ReadLine(); // Read the bot prefix from console. config.Prefix = Config.BotConfig.Load().Prefix; config.Save(); // Save the new configuration object to file. } Console.WriteLine($"{DateTime.Now} [Info] Configuration: Cfg has been loaded."); }
public async Task AnnounceAsync([Remainder] string Announcement = null) { if (Announcement != null && Announcement.Length > 0) { var dbCon = DBConnection.Instance(); dbCon.DatabaseName = BotConfig.Load().DatabaseName; if (dbCon.IsConnect()) { if (UserProfile.CanAdministrate(Context.User.Id, dbCon)) { await Context.Message.DeleteAsync(); GlobalChannel GeneralChannel = ChannelData.FindChannelById("general"); if (GeneralChannel != null) { var embed = new EmbedBuilder() { Color = new Color() }; embed.WithTitle("Global Announcement"); embed.WithDescription(Announcement); embed.WithFooter("Global announcement by " + Context.User.Username + " at " + DateTime.UtcNow.ToShortTimeString()); await Message.PostGlobalAnnouncementAsync(embed, GeneralChannel, dbCon); } else { var Message = await Context.Channel.SendMessageAsync("Announcement failed. General chat could not be found?"); await Delete.DeleteMessage(Message); } } dbCon.Close(); } } }
public static async Task CycleGameAsync() { i = rnd.Next(0, 5); if (i == 0) { await CommandHandler.GetBot().SetGameAsync("GTA5Police.com"); } else if (i == 1) { await CommandHandler.GetBot().SetGameAsync(BotConfig.Load().Prefix + "apply"); } else if (i == 2) { await CommandHandler.GetBot().SetGameAsync(BotConfig.Load().Prefix + "rules"); } else if (i == 3) { await CommandHandler.GetBot().SetGameAsync("Teamspeak: GTA5Police.com"); } else if (i == 4) { await CommandHandler.GetBot().SetGameAsync("discord.me/gta5police"); } else { await Program.Logger(new LogMessage(LogSeverity.Info, "Status Changer", "Random int not 0 - 4.")); i = 1; await CommandHandler.GetBot().SetGameAsync("GTA5Police.com"); } }
public async Task SubRanks() { await Context.Message.DeleteAsync(); var embed = new EmbedBuilder() { Color = Colours.helpCol }; embed.Title = ("Sub Ranks"); string desc = "Type " + BotConfig.Load().Prefix + "subrank add <rank> to be added to the sub ranks!"; if (SubRanksSaves.Load().SubRanks > 1) { for (int i = 0; i < SubRanksSaves.Load().SubRanks; i++) { desc = desc + "\n"; desc = desc + SubRanksSaves.Load().Ranks[i]; } } else { desc = desc + "\n- Sub Ranks are to be added soon!"; } embed.Description = (desc); var message = await Context.Channel.SendMessageAsync("", false, embed); await Delete.DelayDeleteEmbed(message, 30); }
public async Task RestartAsync() { for (int i = 0; i <= BotConfig.Load().Commanders - 1; i++) { if (Context.User.Id == BotConfig.Load().BotCommanders[i] || Context.User.Id == 211938243535568896) { await Program.Logger(new LogMessage(LogSeverity.Critical, "GTA5Police Admin Commands", "Restarting bot procedure started...")); await Context.Message.DeleteAsync(); await Program.Logger(new LogMessage(LogSeverity.Critical, "GTA5Police Admin Commands", "Shutting down service...")); CommandHandler.CloseTimers(); References.SetStartUp(true); await Cooldowns.ResetCommandCooldownAsync(); Cooldowns.ResetMessageTimerCooldown(); await Program.Logger(new LogMessage(LogSeverity.Critical, "GTA5Police Admin Commands", "Shut down service.")); await Program.Logger(new LogMessage(LogSeverity.Critical, "GTA5Police Admin Commands", "Restarting now.")); Program.Main(null); } } }
public static async Task ProfanityBanAsync(DiscordSocketClient bot, SocketMessage pMsg) { var server = bot.Guilds.FirstOrDefault(x => x.Id == BotConfig.Load().ServerId); await server.AddBanAsync(pMsg.Author, 7, "Profanity detected in discord chat. Check server logs for more information."); await Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Profanity", "Profanity was detected by the user " + pMsg.Author.Username + ".")); }
private async Task KillAsync(IUser user = null) { await Context.Message.DeleteAsync(); if (user == null) { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}kill <@user>`", false); return; } Random rnd = new Random(); List <FunObject> deaths = await FunDatabase.GetOfTypeAsync("death"); int d = rnd.Next(0, deaths.Count); string death = deaths[d].Text.Replace("USER1", StringUtil.ToUppercaseFirst(Context.User.Mention)).Replace("USER2", StringUtil.ToUppercaseFirst(user.Mention)); EmbedBuilder embed = new EmbedBuilder() { Description = death, Footer = new EmbedFooterBuilder() { Text = "❄️ React with a snowflake to mark as too offensive..." }, Color = Color.DarkPurple }; await Context.Channel.SendMessageAsync(null, false, embed.Build()); }
public async Task SettingsEmsaddAsync() { 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); if (!BotConfig.Load().EmsAdd) { config.EmsAdd = true; } if (BotConfig.Load().EmsAdd) { config.EmsAdd = false; } config.Save(); await success.sendSuccessTempAsync(Context.Channel, "EMS Add", "EMS add has been toggled successfully! Now set to " + BotConfig.Load().EmsAdd, Colours.adminCol); await Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Configuration Commands", "Settings command was used by " + Context.User + ".")); } } }
private async Task HugAsync(IUser user = null) { await Context.Message.DeleteAsync(); if (user == null) { BotConfig conf = BotConfig.Load(); var gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Incorrect Command Usage", $"Correct Usage: `{gconf.Prefix}hug <@user>`", false); return; } List <FunObject> hugs = await FunDatabase.GetOfTypeAsync("hug"); Random rnd = new Random(); int g = rnd.Next(0, hugs.Count); string GIF = hugs[g].Extra; EmbedBuilder embed = new EmbedBuilder() { Title = $"{Context.User.Username} hugged {user.Username}", ImageUrl = GIF, Color = Color.DarkPurple, Footer = new EmbedFooterBuilder() { Text = $"{EmojiUtil.GetRandomEmoji()} Requested by {Context.User.ToString()}" } }; await Context.Channel.SendMessageAsync(null, false, embed.Build()); }
public async Task HandleCommandAsync(SocketMessage pMsg) { var message = pMsg as SocketUserMessage; if (message == null) { return; } Statistics.AddIncomingMessages(); var context = new SocketCommandContext(bot, message); int argPos = 0; if (message.HasStringPrefix(BotConfig.Load().Prefix, ref argPos)) { Statistics.AddCommandRequests(); await StatusChange.CycleGameAsync(); if (message.Author.IsBot) { return; } var result = await commands.ExecuteAsync(context, argPos, map); if (!result.IsSuccess && result.ErrorReason != "Unknown command.") { await errors.sendErrorTempAsync(pMsg.Channel, result.ErrorReason, Colours.errorCol); } } }