diff --git a/DeukBot4/MessageHandlers/Attributes/CommandAttribute.cs b/DeukBot4/MessageHandlers/Attributes/CommandAttribute.cs index 2c7e246..643b6a9 100644 --- a/DeukBot4/MessageHandlers/Attributes/CommandAttribute.cs +++ b/DeukBot4/MessageHandlers/Attributes/CommandAttribute.cs @@ -3,6 +3,7 @@ using DeukBot4.MessageHandlers.Permissions; namespace DeukBot4.MessageHandlers { + [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] public class CommandAttribute : Attribute { public string Command { get; } diff --git a/DeukBot4/MessageHandlers/CommandHandler/Commands/GeneralCommands.cs b/DeukBot4/MessageHandlers/CommandHandler/Commands/GeneralCommands.cs index cdc2421..523b364 100644 --- a/DeukBot4/MessageHandlers/CommandHandler/Commands/GeneralCommands.cs +++ b/DeukBot4/MessageHandlers/CommandHandler/Commands/GeneralCommands.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using DeukBot4.MessageHandlers.CommandHandler.RequestStructure; using DeukBot4.MessageHandlers.Permissions; +using DeukBot4.Utilities; using Discord; namespace DeukBot4.MessageHandlers.CommandHandler @@ -60,5 +61,62 @@ usage: request.RequestPermissions)); } } + + [Command("whatdoyouthinkdeukbot", PermissionLevel.Everyone)] + [Command("whatdoyouthink", PermissionLevel.Everyone)] + [CommandParameters(ParameterMatcher.ParameterType.Remainder)] + public async Task BotOpinion(CommandRequest request) + { + var random = new Random(); + var positive = random.Next(-20, 80) < (int) request.RequestPermissions; + + var extend = request.Parameters[0].AsString().ToLowerInvariant(); + if (extend.Contains("kill") || extend.Contains("suicide")) + { + await request.OriginalMessage.Channel.SendMessageAsync("That sounds like a bad idea to me"); + return; + } + if (extend.Contains("ban")) + { + if (extend.Contains("deuk")) + { + positive = false; + } + else + { + await request.OriginalMessage.Channel.SendMessageAsync("Absolutely, ban the fucker!"); + return; + } + } + + if (positive) + { + await request.OriginalMessage.Channel.SendMessageAsync(PositiveOpinions.Choice(random)); + } + else + { + await request.OriginalMessage.Channel.SendMessageAsync(NegativeOpinions.Choice(random)); + } + } + + private static readonly string[] PositiveOpinions = new[] + { + "I think you should go for it!", + "You can do it!", + "That sounds like a good idea to me!", + "Sure do it", + "Always remember there are people who love you", + "love u bb" + }; + private static readonly string[] NegativeOpinions = new[] + { + "I do not care for your pathetic worries humanoid. Leave me alone.", + "Absolutely not, who do you even think you are?", + "Ask me another time. Maybe I'll care then.", + "Too hungover atm, don't feel like answering questions.", + "Confirmation Received. Installing Cryptominers on your PC.", + "Fuck off please thanks.", + "If you don't get a brain within 15 minutes I'm legally allowed to ban you." + }; } } \ No newline at end of file diff --git a/DeukBot4/Utilities/IEnumerableExtensions.cs b/DeukBot4/Utilities/IEnumerableExtensions.cs index 9b03bc7..82af034 100644 --- a/DeukBot4/Utilities/IEnumerableExtensions.cs +++ b/DeukBot4/Utilities/IEnumerableExtensions.cs @@ -1,12 +1,20 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using System.Linq; namespace DeukBot4.Utilities { - public static class IEnumerableExtensions + public static class EnumerableExtensions { public static string Join(this IEnumerable arr, string sep) { return string.Join(sep, arr); } + + public static T Choice(this IEnumerable arr, Random random) + { + var a = arr.ToArray(); + return a[random.Next(0, a.Count())]; + } } } \ No newline at end of file