mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-07 14:27:54 +00:00
Add message editing command
Signed-off-by: Ske <voltasalt@gmail.com>
This commit is contained in:
parent
33cabff359
commit
3d624b39e4
9 changed files with 173 additions and 11 deletions
|
|
@ -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>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue