Added command for bot opinion
This commit is contained in:
parent
3ac40ba00e
commit
b4a8923f9e
|
@ -3,6 +3,7 @@ using DeukBot4.MessageHandlers.Permissions;
|
|||
|
||||
namespace DeukBot4.MessageHandlers
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
||||
public class CommandAttribute : Attribute
|
||||
{
|
||||
public string Command { get; }
|
||||
|
|
|
@ -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."
|
||||
};
|
||||
}
|
||||
}
|
|
@ -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<string> arr, string sep)
|
||||
{
|
||||
return string.Join(sep, arr);
|
||||
}
|
||||
|
||||
public static T Choice<T>(this IEnumerable<T> arr, Random random)
|
||||
{
|
||||
var a = arr.ToArray();
|
||||
return a[random.Next(0, a.Count())];
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue