Add message editing command

Signed-off-by: Ske <voltasalt@gmail.com>
This commit is contained in:
Ske
2021-05-03 12:33:30 +02:00
parent 33cabff359
commit 3d624b39e4
9 changed files with 173 additions and 11 deletions

View File

@@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Myriad.Types;
using PluralKit.Core;
namespace PluralKit.Bot
@@ -68,6 +71,27 @@ namespace PluralKit.Bot
return matched;
}
public static ulong? MatchMessage(this Context ctx, bool parseRawMessageId)
{
if (ctx.Message.Type == Message.MessageType.Reply && ctx.Message.MessageReference != null)
return ctx.Message.MessageReference.MessageId;
var word = ctx.PeekArgument();
if (word == null)
return null;
if (parseRawMessageId && ulong.TryParse(word, out var mid))
return mid;
var match = Regex.Match(word, "https://(?:\\w+.)?discord(?:app)?.com/channels/\\d+/\\d+/(\\d+)");
if (!match.Success)
return null;
var messageId = ulong.Parse(match.Groups[1].Value);
ctx.PopArgument();
return messageId;
}
public static async Task<List<PKMember>> ParseMemberList(this Context ctx, SystemId? restrictToSystem)
{
var members = new List<PKMember>();