I'm both a Discord and Golang newbie and have run into an issue.
I'm trying to help someone create a custom command to get Discord's YAGPDB.xyz bot to move a message from one thread to another. The main script does the actual job but the output is a little wrong: we want it to output the actual owner of the message (and timestamp) but it states that I (the person running the command) am the owner.
I've narrowed it down to the fact that when I put the message ID as a parameter, it stays as an int and I need to fetch/instantiate a Message so I can access its properties, like the author, as according to this: There appears to be no specific argument of 'message' type, although there are things like channel and member:
So I have created a test script just to get the author details of a message:
{{$args := parseArgs 1 "Syntax is : '!getauthor (.MessageID to move)'" (carg "int" "message ID")}} {{$message:= ($args.Get 0)}} {{$message.Author}} This is the output:
An error caused the execution of the custom command template to stop: Failed executing CC #9, line 5, row 10: executing "CC #9" at <$message.Author>: can't evaluate field Author in type int 4 {{$message:= ($args.Get 0)}} 5 {{$message.Author}} Any help appreciated.
1 Answer
Did it with getMessage
{{$args := parseArgs 2 "Syntax is : '!move-msg (.MessageID to move) (.ChannelID Source Channel ID)'" (carg "int" "message ID") (carg "int" "source channel ID")}} {{$messageId := $args.Get 0}} {{$sourceChannelId := $args.Get 1}} {{$message := getMessage $sourceChannelId $messageId}} Author: {{$message.Author.Username}}, Created: {{$message.Timestamp.Parse.String}} prints this out:
Author: xxxxx, Created: 2021-12-16 22:14:33.586 +0000 UTC