Merge pull request #32 from EL20202/typescript

added functionality for reacting to in-line replies
This commit is contained in:
WatDuhHekBro 2021-04-07 01:02:22 -05:00 committed by GitHub
commit 9c2ff59a34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,8 +10,19 @@ export default new Command({
async run($: CommonLibrary): Promise<any> {
let target: Message | undefined;
let distance = 1;
if ($.args.length >= 2) {
// allows reactions by using an in-line reply
if($.message.reference){
const messageID = $.message.reference.messageID;
try{
target = await $.channel.messages.fetch(messageID!)
}catch{
return $.channel.send("Unknown error occurred!")
}
}
// handles reacts by message id/distance
else if ($.args.length >= 2) {
const last = $.args[$.args.length - 1]; // Because this is optional, do not .pop() unless you're sure it's a message link indicator.
const URLPattern = /^(?:https:\/\/discord.com\/channels\/(\d{17,19})\/(\d{17,19})\/(\d{17,19}))$/;
const copyIDPattern = /^(?:(\d{17,19})-(\d{17,19}))$/;