public static async System.Threading.Tasks.Task <bool> MusicCommands(SocketMessage message, CommandContext context, DiscordSocketClient client, LavaNode lava) { if (Validation.CheckCommand(message, "play")) { if ((message.Author as IVoiceState).VoiceChannel == null) { DiscordFunctions.EmbedThis("Music", "You must first join a voice channel!", "red", context); return(true); } var temp = client.GetGuild(context.Guild.Id).CurrentUser.VoiceState; if (temp != null && client.GetGuild(context.Guild.Id).CurrentUser.VoiceChannel != (message.Author as IVoiceState).VoiceChannel) { DiscordFunctions.EmbedThis("Music", "I can't join another voice channel until I'm disconnected from another channel.", "red", context); return(true); } SearchResponse search = new SearchResponse(); var videoId = string.Empty; var timestamp = string.Empty; string query = message.Content.ToLower().Replace("!play ", ""); if (query.ToLower().Contains("www.youtube.com/watch?v=")) { var uri = new Uri(@query); var queryid = HttpUtility.ParseQueryString(uri.Query); if (queryid.AllKeys.Contains("v")) { videoId = queryid["v"]; } else { videoId = uri.Segments.Last(); } if (queryid.AllKeys.Contains("t")) { timestamp = queryid["t"]; } if (timestamp != string.Empty) { videoId = videoId.Replace("&t=" + timestamp, ""); } search = await lava.SearchYouTubeAsync(query.Replace("&t=" + timestamp, "")); } else { search = await lava.SearchYouTubeAsync(query); } LavaTrack track = new LavaTrack(); if (query.ToLower().Contains("www.youtube.com/watch?v=")) { bool found = false; foreach (var vid in search.Tracks) { if (vid.Id.ToLower() == videoId) { track = vid; found = true; break; } } if (found == false) { track = search.Tracks.FirstOrDefault(); } } else { track = search.Tracks.FirstOrDefault(); } var player = lava.HasPlayer(context.Guild) ? lava.GetPlayer(context.Guild) : await lava.JoinAsync((context.User as IVoiceState).VoiceChannel, (ITextChannel)message.Channel); if (player.PlayerState == PlayerState.Playing) { player.Queue.Enqueue(track); DiscordFunctions.EmbedThis("Music", "Enqeued " + track.Title, "orange", context); } else { await player.PlayAsync(track); try { if (timestamp != string.Empty) { if (timestamp.ToLower().Contains("s")) { timestamp = timestamp.ToLower().Replace("s", ""); } await player.SeekAsync(TimeSpan.FromSeconds(Convert.ToDouble(timestamp))); } } catch { } DiscordFunctions.EmbedThis("Music", "Playing " + track.Title, "green", context); } return(true); } else if (Validation.CheckCommand(message, "skip")) { var _player = lava.GetPlayer(context.Guild); if (_player is null || _player.Queue.Count is 0) { DiscordFunctions.EmbedThis("Music", "Nothing in the queue", "orange", context); return(true); } var oldTrack = _player.Track; await _player.SkipAsync(); DiscordFunctions.EmbedThis("Music", "Skipped: " + oldTrack.Title + "\nNow Playing: " + _player.Track.Title, "orange", context); return(true); } else if (Validation.CheckCommand(message, "stop")) { var _player = lava.GetPlayer(context.Guild); if (_player == null) { return(true); } await _player.StopAsync(); DiscordFunctions.EmbedThis("Music", "Stopped player", "orange", context); return(true); } else if (Validation.CheckCommand(message, "volume")) { LavaPlayer _player; try { _player = lava.GetPlayer(context.Guild); } catch { DiscordFunctions.EmbedThis("Music", "Nothing is playing", "orange", context); return(true); } if (string.IsNullOrWhiteSpace(message.Content.Replace("!volume", ""))) { DiscordFunctions.EmbedThis("Music", "Please use a number between 2- 150", "orange", context); return(true); } var vol = Convert.ToUInt16(message.Content.Replace("!volume", "").Trim()); if (vol > 150 || vol <= 2) { DiscordFunctions.EmbedThis("Music", "Please use a number between 2- 150", "orange", context); return(true); } await _player.UpdateVolumeAsync(vol); DiscordFunctions.EmbedThis("Music", "Volume set to: " + vol.ToString(), "green", context); return(true); } else if (Validation.CheckCommand(message, "pause")) { LavaPlayer _player; try { _player = lava.GetPlayer(context.Guild); } catch { DiscordFunctions.EmbedThis("Music", "Nothing is playing", "orange", context); return(true); } if (_player.PlayerState != PlayerState.Paused) { await _player.PauseAsync(); DiscordFunctions.EmbedThis("Music", "Player is Paused", "orange", context); return(true); } else { await _player.ResumeAsync(); DiscordFunctions.EmbedThis("Music", "Playback Resumed", "green", context); return(true); } } else if (Validation.CheckCommand(message, "resume")) { LavaPlayer _player; try { _player = lava.GetPlayer(context.Guild); } catch { DiscordFunctions.EmbedThis("Music", "Nothing is playing", "orange", context); return(true); } if (_player.PlayerState != PlayerState.Paused) { await _player.ResumeAsync(); DiscordFunctions.EmbedThis("Music", "Playback Resumed", "green", context); return(true); } else { DiscordFunctions.EmbedThis("Music", "Playback is not paused", "orange", context); return(true); } } else if (Validation.CheckCommand(message, "join")) { var user = context.User as SocketGuildUser; if (user.VoiceChannel is null) { DiscordFunctions.EmbedThis("Music", "You need to connect to a voice channel", "red", context); return(true); } else { LavaPlayer _player; try { _player = lava.GetPlayer(context.Guild); DiscordFunctions.EmbedThis("Music", "Bot is already in a channel", "red", context); return(true); } catch { await lava.JoinAsync((context.User as IVoiceState).VoiceChannel, (ITextChannel)message.Channel); return(true); } } } else if (Validation.CheckCommand(message, "leave")) { var user = context.User as SocketGuildUser; if (user.VoiceChannel is null) { DiscordFunctions.EmbedThis("Music", "Please join the channel the bot is in to make it leave", "red", context); return(true); } else { LavaPlayer _player; try { _player = lava.GetPlayer(context.Guild); } catch { DiscordFunctions.EmbedThis("Music", "Please join the channel the bot is in to make it leave", "red", context); return(true); } if (_player.VoiceChannel == user.VoiceChannel) { await lava.LeaveAsync((context.User as IVoiceState).VoiceChannel); } else { DiscordFunctions.EmbedThis("Music", "Please join the channel the bot is in to make it leave", "red", context); return(true); } } } return(false); }
public static async Task <bool> AdminCommands(SocketMessage message, CommandContext context, DiscordSocketClient client) { if (Validation.CheckCommand(message, "sweep")) { if (Validation.WordCountEqual(message, 2)) { try { int loops = 1; try { loops = System.Convert.ToInt32(DiscordFunctions.GetWord(message, 1)); } catch (FormatException) { } await DiscordFunctions.DeleteLastMessage(context, message.Channel.ToString()); for (int i = 0; i < loops; i++) { await DiscordFunctions.DeleteLastMessage(context, message.Channel.ToString()); await Task.Delay(1000); } DiscordFunctions.EmbedThisImage("Sweep Sweep", "", "https://i.imgur.com/UH1MPDz.gif", "green", context); } catch { } } else { // Warn the user it was a bad command DiscordFunctions.EmbedThis("Incomplete Command", "!sweep #", "red", context); } return(true); } else if (Validation.CheckCommand(message, "impersonate")) { // Make sure we have all parts if (Validation.WordCountGreater(message, 3)) { foreach (IGuildChannel channel in client.GetGuild(405513567681642517).TextChannels) { if (channel.Name == DiscordFunctions.GetWord(message, 1).Replace("#", "")) { string rebuiltstring = message.Content.Replace(DiscordFunctions.GetWord(message, 0) + " ", "").Replace(DiscordFunctions.GetWord(message, 1) + " ", ""); await client.GetGuild(405513567681642517).GetTextChannel(channel.Id).SendMessageAsync(rebuiltstring); break; } } } else { // Warn the user it was a bad command DiscordFunctions.EmbedThis("Incomplete Command", "!impersonate #channel message", "red", context); } return(true); } else if (Validation.CheckCommand(message, "deleteevent")) { // Make sure we have all parts if (Validation.WordCountEqual(message, 3)) { using (var db = new LiteDatabase(@"Events.db")) { try { var Events = db.GetCollection <Events>("Events"); var Event = Events.FindOne(x => x.Event.StartsWith(DiscordFunctions.GetWord(message, 1) + "-" + DiscordFunctions.GetWord(message, 2))); Events.Delete(Event.Id); } catch { } } // Send a message saying we sre starting DiscordFunctions.EmbedThis("Event being deleted", message.Author.Mention + " deleting event " + DiscordFunctions.GetWord(message, 1) + "-" + DiscordFunctions.GetWord(message, 2), "orange", context); await DiscordFunctions.CleanupEvent(context, message); DiscordFunctions.EmbedThis("Deletion Complete", "Event Deleted " + DiscordFunctions.GetWord(message, 1) + "-" + DiscordFunctions.GetWord(message, 2), "green", context); } else { // Warn the user it was a bad command DiscordFunctions.EmbedThis("Incomplete Command", "!deleteevent EVENT YEAR", "red", context); } return(true); } else if (Validation.CheckCommand(message, "updaterules")) { foreach (IGuildChannel channel in client.GetGuild(486327167035244554).TextChannels) { if (channel.Name == "rules") { bool loop = true; while (loop) { try { IEnumerable <IMessage> messages = await client.GetGuild(486327167035244554).GetTextChannel(channel.Id).GetMessagesAsync().FlattenAsync(); foreach (var messagefound in messages) { await messagefound.DeleteAsync(); await Task.Delay(1000); } if (messages.Count() == 0) { loop = false; } } catch { loop = false; } } foreach (var stringmes in GoogleData.ReadRules()) { if (stringmes == "\n") { // None } else { await client.GetGuild(486327167035244554).GetTextChannel(channel.Id).SendMessageAsync(stringmes); } await Task.Delay(500); } break; } } return(true); } else if (Validation.CheckCommand(message, "giant")) { DiscordFunctions.EmbedThisImage("Better watch out!", "", "https://pbs.twimg.com/media/EHnQ_CcWoAAMhqG?format=png&name=360x360", "red", context); return(true); } else if (Validation.CheckCommand(message, "everyone")) { // Make sure we have all parts if (Validation.WordCountEqual(message, 2)) { using (var db = new LiteDatabase(@"Config.db")) { var DatabaseConfig = db.GetCollection <DatabaseConfig>("DatabaseConfig"); var Config = DatabaseConfig.FindOne(x => x.Id.Equals(1)); if (DatabaseConfig.Count() == 0) { Config.Everyonetag = false; Config.TweetChannel = "announcements"; DatabaseConfig.Insert(Config); } if (DiscordFunctions.GetWord(message, 1).ToLower() == "true") { Config.Everyonetag = true; DatabaseConfig.Update(Config); DiscordFunctions.EmbedThis("Value Updated", message.Author.Mention + " Value is now true", "green", context); } else if (DiscordFunctions.GetWord(message, 1).ToLower() == "false") { Config.Everyonetag = false; DatabaseConfig.Update(Config); DiscordFunctions.EmbedThis("Value Updated", message.Author.Mention + " Value is now false", "green", context); } else { DiscordFunctions.EmbedThis("Error", message.Author.Mention + " Value must be true or false", "red", context); } } } else { DiscordFunctions.EmbedThis("Incomplete Command", "!everyone true", "", context); } return(true); } else if (Validation.CheckCommand(message, "tweetchannel")) { // Make sure we have all parts if (Validation.WordCountEqual(message, 2)) { using (var db = new LiteDatabase(@"Config.db")) { var DatabaseConfig = db.GetCollection <DatabaseConfig>("DatabaseConfig"); var Config = DatabaseConfig.FindOne(x => x.Id.Equals(1)); if (DatabaseConfig.Count() == 0) { Config.Everyonetag = false; Config.TweetChannel = "announcements"; DatabaseConfig.Insert(Config); } Config.TweetChannel = DiscordFunctions.GetWord(message, 1).ToLower().Replace("#", ""); DatabaseConfig.Update(Config); DiscordFunctions.EmbedThis("Tweet Channel Update", "New tweet channel is" + DiscordFunctions.GetWord(message, 1), "green", context); } } else { DiscordFunctions.EmbedThis("Incomplete Command", "!tweetchannel #channel", "red", context); } return(true); } else if (Validation.CheckCommand(message, "debuglist")) { using (var db = new LiteDatabase(@"Guardians.db")) { var Guardians = db.GetCollection <UserData>("Guardians"); var results = Guardians.FindAll(); Console.WriteLine("-----------------Guardians-------------------"); foreach (UserData user in results) { Console.WriteLine(user.Id + " " + user.DiscordUsername + " " + user.Team + " " + user.Event + " " + user.GroupMeGroup + " " + user.GroupMeTime); } } using (var db = new LiteDatabase(@"Events.db")) { var Events = db.GetCollection <Events>("Events"); var results = Events.FindAll(); Console.WriteLine("-----------------Events-------------------"); foreach (Events user in results) { Console.WriteLine(user.Id + " " + user.Event); } } return(true); } else if (Validation.CheckCommand(message, "reload")) { // Load the Database from google sheets List <UserData> users = GoogleData.ReadDB(); using (var db = new LiteDatabase(@"Guardians.db")) { var Guardians = db.GetCollection <UserData>("Guardians"); List <string> ErrorList = new List <string>(); foreach (UserData user in users) { UserData Guardian = null; foreach (var Guard in Guardians.FindAll()) { if (Guard.DiscordUsername.ToLower().Trim().Contains(user.DiscordUsername.ToLower().Trim())) { Guardian = Guard; break; } } if (Guardian != null) { Guardian.Team = user.Team; Guardians.Update(Guardian); } else { if (user.DiscordUsername.Contains("#")) { try { using (var eventdb = new LiteDatabase(@"Events.db")) { var Events = eventdb.GetCollection <Events>("Events"); var Event = Events.FindAll(); Guardian = new UserData { Event = Event.First().Event, DiscordUsername = user.DiscordUsername, Team = user.Team, Authenticated = false }; Guardians.Insert(Guardian); } } catch { ErrorList.Add(user.DiscordUsername); } } else { ErrorList.Add(user.DiscordUsername); } } } if (ErrorList.Count != 0) { string csv = String.Join(",\n", ErrorList.Select(x => x.ToString()).ToArray()); System.IO.File.WriteAllText("/opt/files/ErrorUsers.csv", csv); await message.Channel.SendFileAsync("/opt/files/ErrorUsers.csv", "Users with Errors"); System.IO.File.Delete("/opt/files/ErrorUsers.csv"); } // Index document using a document property Guardians.EnsureIndex(x => x.DiscordUsername); } // Notify the user the DB reload has completed DiscordFunctions.EmbedThis("The DB has been reloaded", "", "green", context); return(true); } else if (Validation.CheckCommand(message, "withdraw")) { // Make sure we have all parts if (Validation.WordCountEqual(message, 2)) { if (DiscordFunctions.GetWord(message, 1).Contains("#")) { using (var db = new LiteDatabase(@"Guardians.db")) { var Guardians = db.GetCollection <UserData>("Guardians"); UserData Guardian = Guardians.FindOne(x => x.DiscordUsername.ToLower().StartsWith(DiscordFunctions.GetWord(message, 1).ToLower())); if (Guardian != null) { bool found = false; Console.WriteLine(Guardian.DiscordUsername); foreach (var user in await context.Guild.GetUsersAsync()) { if (user.Username.ToLower() + "#" + user.Discriminator.ToString() == Guardian.DiscordUsername.ToLower()) { if (user.RoleIds.Count == 2) { foreach (var role in user.Guild.Roles) { if (user.Guild.EveryoneRole != role && user.RoleIds.Contains(role.Id)) { await user.RemoveRoleAsync(role); } } foreach (var role in user.Guild.Roles) { if (role.Name.ToLower() == "global entry") { await user.AddRoleAsync(role); } } } else { List <string> eventroles = new List <string>(); foreach (var role in user.Guild.Roles) { if (user.Guild.EveryoneRole != role && user.RoleIds.Contains(role.Id)) { if (role.Name.ToLower().Contains("guardian-austin-")) { eventroles.Add(role.Name); } } } List <int> eventnumber = new List <int>(); foreach (string role in eventroles) { eventnumber.Add(Int32.Parse(role.ToLower().Replace("guardian-austin-", ""))); } foreach (var role in user.Guild.Roles) { if (user.Guild.EveryoneRole != role && user.RoleIds.Contains(role.Id)) { if (role.Name.ToLower() == "guardian-austin-" + eventnumber.Max().ToString()) { await user.RemoveRoleAsync(role); } } } } DiscordFunctions.EmbedThis("Users Removed", "Please remember to remove the user from the sheet", "orange", context); found = true; break; } } Guardians.Delete(Guardian.Id); if (found == false) { DiscordFunctions.EmbedThis("Unable to locate user in Discord", "User Removed from Database", "green", context); } } else { DiscordFunctions.EmbedThis("Error", "User is not a guardian", "red", context); } } } else { DiscordFunctions.EmbedThis("Incomplete Command", "!withdraw user", "", context); } } return(true); } else if (Validation.CheckCommand(message, "newevent")) { // Make sure we have all parts if (Validation.WordCountEqual(message, 3)) { using (var db = new LiteDatabase(@"Events.db")) { var Events = db.GetCollection <Events>("Events"); Events Eventexists = Events.FindOne(x => x.Event.ToLower().StartsWith(DiscordFunctions.GetWord(message, 1).ToLower() + "-" + DiscordFunctions.GetWord(message, 2).ToLower())); if (Eventexists == null) { Events NewEvent = new Events { Event = DiscordFunctions.GetWord(message, 1) + "-" + DiscordFunctions.GetWord(message, 2) }; Events.Insert(NewEvent); } } // Send a message saying we sre starting DiscordFunctions.EmbedThisImage("New Event Generating", "Please give it a few minutes (5+) to complete", "https://i.imgur.com/Gyn3f3T.gifv", "orange", context); await NewEventBuilder.GenerateRolesAsync(context, DiscordFunctions.GetWord(message, 1), Convert.ToInt32(DiscordFunctions.GetWord(message, 2))); await NewEventBuilder.GenerateCategoriesAsync(context, DiscordFunctions.GetWord(message, 1), Convert.ToInt32(DiscordFunctions.GetWord(message, 2))); await NewEventBuilder.GenerateChannelsAsync(context, DiscordFunctions.GetWord(message, 1), Convert.ToInt32(DiscordFunctions.GetWord(message, 2))); DiscordFunctions.EmbedThisImage("New Event Generating Complete", "", "", "green", context); } else { // Warn the user it was a bad command DiscordFunctions.EmbedThis("Incomplete Command", "!newevent EVENT YEAR", "", context); } return(true); } else if (Validation.CheckCommand(message, "cleardb")) { using (var db = new LiteDatabase(@"Guardians.db")) { var Guardians = db.GetCollection <UserData>("Guardians"); foreach (var Guardian in Guardians.FindAll()) { if (Guardian.Authenticated == false) { Guardians.Delete(Guardian.Id); } } } DiscordFunctions.EmbedThis("Users Removed", "", "orange", context); return(true); } else if (Validation.CheckCommand(message, "unauthenticated")) { using (var db = new LiteDatabase(@"Guardians.db")) { var Guardians = db.GetCollection <UserData>("Guardians"); List <string> UnauthenticatedList = new List <string>(); var Guardianlist = Guardians.FindAll(); foreach (var Guardian in Guardianlist) { if (Guardian.Authenticated == false) { UnauthenticatedList.Add(Guardian.DiscordUsername); } } string csv = String.Join(",\n", UnauthenticatedList.Select(x => x.ToString()).ToArray()); System.IO.File.WriteAllText("/opt/files/unauth.csv", csv); await message.Channel.SendFileAsync("/opt/files/unauth.csv", "Unauthenticated users"); System.IO.File.Delete("/opt/files/unauth.csv"); } return(true); } return(false); }
public static async Task <bool> FunCommands(SocketMessage message, CommandContext context, DiscordSocketClient client) { if (Validation.CheckCommand(message, "wednesday")) { string source = "https://i.imgur.com/2SRddtz.jpg"; string desc = "***It is Wednesday,***\n" + "***my dudes***\n"; DiscordFunctions.EmbedThisImage("Wednesday", desc, source, "magenta", context); return(true); } else if (Validation.CheckCommand(message, "ficus")) { string source = "https://pbs.twimg.com/profile_images/884098118907699200/i8L4V-es_400x400.jpg"; string desc = ""; DiscordFunctions.EmbedThisImage("Praise be", desc, source, "magenta", context); return(true); } else if (Validation.CheckCommand(message, "8ball")) { string user = message.Author.Username; if (string.IsNullOrWhiteSpace(message.Content.Replace("!8ball", ""))) { throw new ArgumentException(user + " 🎱 Please enter a question to ask 8ball" + "\n **Command Usage: **.8ball <question> "); } Random rand = new Random(); int value = rand.Next(0, 7); string response = ""; switch (value) { case 0: response = "Yeah"; break; case 1: response = "100% dude"; break; case 2: response = "Probably lol"; break; case 3: response = "lmao, why??"; break; case 4: response = "Nope"; break; case 5: response = "Nah, I doubt it tbh"; break; case 6: response = "Absolutely not"; break; } string title = "🎱 Magic 8 Ball 🎱"; string description = $"**Question:** {message.Content.Replace("!8ball", "")}\n**Asked by: **{user}\n**Answer:** {response}"; DiscordFunctions.EmbedThis(title, description, "", context); return(true); } else if (Validation.CheckCommand(message, "flip") || Validation.CheckCommand(message, "coin")) { await context.Channel.SendMessageAsync("*Flipping a coin...* ⚖️"); Random rand = new Random(); int result = rand.Next(0, 2); string user = context.User.Mention; await Task.Delay(1000); if (result == 0) { await context.Channel.SendMessageAsync(user + "*, it's tails!*"); } else { await context.Channel.SendMessageAsync(user + "*, it's heads!*"); } return(true); } else if (Validation.CheckCommand(message, "cat")) { using (var webclient = new HttpClient()) { webclient.Timeout = TimeSpan.FromSeconds(2); var s = await webclient.GetStringAsync("http://aws.random.cat/meow"); var json = JsonConvert.DeserializeObject <CatDog>(s); await context.Channel.SendMessageAsync(json.File); } return(true); } else if (Validation.CheckCommand(message, "catfact")) { using (var webclient = new HttpClient()) { webclient.Timeout = TimeSpan.FromSeconds(2); var s = await webclient.GetStringAsync("https://catfact.ninja/fact"); var json = JsonConvert.DeserializeObject <CatFact>(s); await context.Channel.SendMessageAsync(json.Fact); } return(true); } else if (Validation.CheckCommand(message, "dog")) { using (var webclient = new HttpClient()) { webclient.Timeout = TimeSpan.FromSeconds(2); var dog = "http://random.dog/" + await webclient.GetStringAsync("http://random.dog/woof"); await context.Channel.SendMessageAsync(dog); } return(true); } else if (Validation.CheckCommand(message, "info")) { var application = await context.Client.GetApplicationInfoAsync(); EmbedBuilder eb = new EmbedBuilder(); IGuildUser bot = await context.Guild.GetCurrentUserAsync(); eb.Author = new EmbedAuthorBuilder().WithName(bot.Nickname ?? bot.Username).WithIconUrl(context.Client.CurrentUser.GetAvatarUrl()); eb.ThumbnailUrl = context.Client.CurrentUser.GetAvatarUrl(); eb.Color = Color.Green; eb.Description = $"{Format.Bold("Info")}\n" + $"- Author: {application.Owner.Username} (ID {application.Owner.Id})\n" + $"- Library: Discord.Net ({DiscordConfig.Version})\n" + $"- Runtime: {RuntimeInformation.FrameworkDescription} {RuntimeInformation.OSArchitecture}\n" + $"- Uptime: {(DateTime.Now - Process.GetCurrentProcess().StartTime).ToString(@"dd\.hh\:mm\:ss")}\n\n" + $"{Format.Bold("Stats")}\n" + $"- Heap Size: {Math.Round(GC.GetTotalMemory(true) / (1024.0 * 1024.0), 2).ToString()} MB\n" + $"- Guilds: {(context.Client as DiscordSocketClient).Guilds.Count}\n" + $"- Channels: {(context.Client as DiscordSocketClient).Guilds.Sum(g => g.Channels.Count)}\n" + $"- Users: {(context.Client as DiscordSocketClient).Guilds.Sum(g => g.Users.Count)}"; await context.Channel.SendMessageAsync("", false, eb.Build()); return(true); } else if (Validation.CheckCommand(message, "ping")) { DiscordFunctions.EmbedThis("Pong", "Status: " + client.Status + "\nResponse Time: " + client.Latency + "ms", "", context); return(true); } else if (Validation.CheckCommand(message, "nihilism")) { await context.Channel.SendMessageAsync(context.User.Mention + $" You get nothing"); return(true); } else if (Validation.CheckCommand(message, "whoami")) { await context.Channel.SendMessageAsync(context.User.Mention + $" You are: " + message.Author.Username + "#" + message.Author.Discriminator.ToString()); return(true); } else if (Validation.CheckCommand(message, "excuse")) { DiscordFunctions.EmbedThis("", Angela.RandomExcuse(), "", context); return(true); } else if (Validation.CheckCommand(message, "pun")) { DiscordFunctions.EmbedThis("", Angela.RandomPun(), "", context); return(true); } else if (Validation.CheckCommand(message, "roll")) { if (Validation.WordCountEqual(message, 2)) { var isNumeric = int.TryParse(DiscordFunctions.GetWord(message, 1), out int n); if (isNumeric == true) { DiscordFunctions.EmbedThis("Rolled", Angela.Roll(Int32.Parse(DiscordFunctions.GetWord(message, 1))).ToString(), "", context); } else { DiscordFunctions.EmbedThis("", "That is not a number", "", context); } } else { // Warn the user it was a bad command DiscordFunctions.EmbedThis("Incomplete Command", "!roll number", "", context); } return(true); } else if (Validation.CheckCommand(message, "nuggets")) { if (Validation.WordCountEqual(message, 2)) { var isNumeric = int.TryParse(DiscordFunctions.GetWord(message, 1), out int n); if (isNumeric == true) { DiscordFunctions.EmbedThis("Nugget Conversion", message.Author.Mention + " $" + DiscordFunctions.GetWord(message, 1) + " is equal to " + Angela.Nuggets(Int32.Parse(DiscordFunctions.GetWord(message, 1))) + " chicken nuggets", "", context); } else { DiscordFunctions.EmbedThis("", "That is not a number", "", context); } } else { // Warn the user it was a bad command DiscordFunctions.EmbedThis("Incomplete Command", "!nuggets number", "", context); } return(true); } else if (Validation.CheckCommand(message, "rate")) { int random = new Random().Next(12); if (random == 11) { random = new Random().Next(12); } await context.Channel.SendMessageAsync(context.User.Mention + $" 🤔 I would rate that a " + random.ToString() + "/10"); return(true); } else if (Validation.CheckCommand(message, "xkcd")) { string xkcdUrl = $"http://xkcd.com/"; Random rand = new Random(); Uri uri = new Uri($"{xkcdUrl}{rand.Next(1, 2246)}/info.0.json"); var response = await new ApiHandler <XKCD>().GetJSONAsync(uri); if (response?.Url != null) { await context.Channel.SendMessageAsync(response.Title + ": " + response.Url); } return(true); } else if (Validation.CheckCommand(message, "points")) { using (var db = new LiteDatabase(@"Points.db")) { try { var Points = db.GetCollection <Points>("Points"); if (Validation.WordCountEqual(message, 3)) { if (Validation.IsHGorAdmin(message, client)) { if (DiscordFunctions.GetWord(message, 1).ToLower() == "add") { Points point = new Points { PointsNumber = 0, PointTitle = DiscordFunctions.GetWord(message, 2) }; Points.Insert(point); DiscordFunctions.EmbedThis(point.PointTitle, "Was added to the points database", "", context); } else if (DiscordFunctions.GetWord(message, 1).ToLower() == "delete") { var result = Points.FindOne(x => x.PointTitle.StartsWith(DiscordFunctions.GetWord(message, 2))); Points.Delete(result.Id); DiscordFunctions.EmbedThis(DiscordFunctions.GetWord(message, 2), "Was removed from the points database", "", context); } } } else if (Validation.WordCountEqual(message, 4)) { if (DiscordFunctions.GetWord(message, 1).ToLower() == "modify") { if (Validation.IsHGorAdmin(message, client)) { var result = Points.FindOne(x => x.PointTitle.StartsWith(DiscordFunctions.GetWord(message, 2))); result.PointsNumber = result.PointsNumber + Convert.ToDouble(DiscordFunctions.GetWord(message, 3)); Points.Update(result); DiscordFunctions.EmbedThis(result.PointTitle, "Current points are now: " + result.PointsNumber, "", context); } } } else { var results = Points.FindAll(); var pointlist = ""; foreach (Points point in results) { pointlist = pointlist + '\t' + '\t' + '\t' + point.PointTitle + ": " + point.PointsNumber + '\n'; } DiscordFunctions.EmbedThis("-------------------Points-------------------", pointlist, "", context); } } catch { } } return(true); } return(false); }
public static async System.Threading.Tasks.Task <bool> TeamCommand(SocketMessage message, CommandContext context) { if (Validation.CheckCommand(message, "squadlead")) { // Make sure we have all parts if (Validation.WordCountEqual(message, 2)) { if (DiscordFunctions.GetWord(message, 2).Contains("@")) { foreach (SocketRole rolesfound in ((SocketGuildUser)message.Author).Roles) { if (rolesfound.Name.ToLower().Contains("team-lead-")) { await DiscordFunctions.SquadLeadTask(context, rolesfound.Name, DiscordFunctions.GetWord(message, 2)); DiscordFunctions.EmbedThis("User is now a squad lead", message.Author.Username, "green", context); break; } } } else { DiscordFunctions.EmbedThis("Incomplete Command", "!squadlead @user", "red", context); } } return(true); } else if (Validation.CheckCommand(message, "squad")) { // Make sure we have all parts if (Validation.WordCountEqual(message, 2)) { if (DiscordFunctions.GetWord(message, 2).Contains("@")) { foreach (SocketRole rolesfound in ((SocketGuildUser)message.Author).Roles) { if (rolesfound.Name.ToLower().Contains("team-lead-")) { await DiscordFunctions.SquadTask(context, DiscordFunctions.GetWord(message, 3), DiscordFunctions.GetWord(message, 2), rolesfound.Name.Replace("team-lead-", "")); DiscordFunctions.EmbedThis("User added to squad", message.Author.Username + " -> " + DiscordFunctions.GetWord(message, 3), "green", context); break; } } } else { DiscordFunctions.EmbedThis("Incomplete Command", "!squad @user squadname", "red", context); } } return(true); } else if (Validation.CheckCommand(message, "addchannel")) { // Make sure we have all parts if (Validation.WordCountGreater(message, 2)) { foreach (SocketRole rolesfound in ((SocketGuildUser)message.Author).Roles) { if (rolesfound.Name.ToLower().Contains("team-lead-")) { var teamname = rolesfound.Name.ToLower().Trim().Replace("team-lead-", ""); var description = message.Content.Replace("!addchannel " + DiscordFunctions.GetWord(message, 1), "").Trim(); if (description.Length == 0) { description = " "; } await DiscordFunctions.CreateChannel(context, DiscordFunctions.GetWord(message, 1) + "-" + teamname, null, description, teamname, 2); DiscordFunctions.EmbedThis("Channel Added", "", "green", context); } } } else { DiscordFunctions.EmbedThis("Incomplete Command", "!addchannel channelname description", "red", context); } return(true); } else if (Validation.CheckCommand(message, "deletechannel")) { // Make sure we have all parts if (Validation.WordCountEqual(message, 2)) { foreach (SocketRole rolesfound in ((SocketGuildUser)message.Author).Roles) { if (rolesfound.Name.ToLower().Contains("team-lead-")) { var teamname = rolesfound.Name.ToLower().Trim().Replace("team-lead-", ""); bool found = false; foreach (var role in context.Guild.Roles) { if (role.Name.ToLower() == teamname) { foreach (var channel in await context.Guild.GetChannelsAsync()) { if (channel.Name == DiscordFunctions.GetWord(message, 1)) { foreach (var perm in channel.PermissionOverwrites) { if (perm.TargetId == role.Id) { await channel.DeleteAsync(); found = true; break; } } } if (found == true) { break; } } } if (found == true) { break; } } } } } else { DiscordFunctions.EmbedThis("Incomplete Command", "!deletechannel channelname", "red", context); } return(true); } return(false); }