2017-08-26 17:24:37 +00:00
|
|
|
|
using Discord.WebSocket;
|
|
|
|
|
using Noikoio.RegexBot.ConfigItem;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Noikoio.RegexBot.Feature.AutoMod.Responses
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Kicks the invoking user.
|
|
|
|
|
/// Takes no parameters.
|
|
|
|
|
/// </summary>
|
2017-09-05 17:18:07 +00:00
|
|
|
|
class Kick : ResponseBase
|
2017-08-26 17:24:37 +00:00
|
|
|
|
{
|
2017-09-05 17:18:07 +00:00
|
|
|
|
public Kick(ConfigItem rule, string cmdline) : base(rule, cmdline)
|
2017-08-26 17:24:37 +00:00
|
|
|
|
{
|
|
|
|
|
// Throw exception if extra parameters found
|
|
|
|
|
if (cmdline.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Length > 1)
|
|
|
|
|
throw new RuleImportException("Incorrect number of parameters.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override async Task Invoke(SocketMessage msg)
|
|
|
|
|
{
|
|
|
|
|
var target = (SocketGuildUser)msg.Author;
|
|
|
|
|
await target.KickAsync(Uri.EscapeDataString($"Rule '{Rule.Label}'"));
|
2017-10-21 19:05:46 +00:00
|
|
|
|
#warning Remove EscapeDataString call on next Discord.Net update
|
2017-08-26 17:24:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|