需要有关WebService::Discord::Webhook Perl模块的信息

92vpleto  于 8个月前  发布在  Perl
关注(0)|答案(1)|浏览(75)

我试图使用WebService::Discord::Webhook Perl模块来发布到我的Discord WebHook,并使基本的“内容”值正常工作,但我想附加一个文件,无论我尝试什么,我都会得到这个错误:

code: 400 Bad Request
    content: {"content": ["Could not interpret \"{'file': 'News.txt', 'content': 'News Report  - 10/02/2023', 'data': '        -=[  EMPIRE NEWS  ]=-\\n::::::::::::::::::::::::::::::::::::::::::::::::::\\n!       \"All the news that fits, we print.\"      !\\n::::::::::::::::::::::::::::::::::::::::::::::::::\\n       Mon Oct  2 22:56:38 2023\\n\\n\\nRelative calm prevails.\\n\\nThe details of Empire news since Mon Oct  2 22:48:55 2023\\n\\nNo news at the moment...\\n'}\" as string."]} at ./poststats line 74.

我试着称之为:

my %NewsHash = (
content    => "News Report  - $CurDate",
file       => "News.txt",
data       => "$file_content"
);
my $hash_ref = \%NewsHash;
$webhook->execute( $hash_ref );

谁能提供一个文件调用的例子给我?

我把定义改成这样:

my %NewsHash = {
content    => "News Report - $CurDate",
file       => {
name       => "News.txt",
data       => "$file_content"
              }
};
$webhook->execute( %NewsHash );

现在我得到了这个错误:

PARAMETER ERROR: Execute request missing required parameters (must have at least content, embed, or file) at ./poststats line 82.
o2gm4chl

o2gm4chl1#

->execute需要一个键值对列表,而不是一个哈希引用。

$webhook->execute(
   content => "News Report - $CurDate",
   file    => ...,
   ...
);
my @params = (
   content => "News Report - $CurDate",
   file    => ...,
   ...
);

$webhook->execute( @params );
my %params = (
   content => "News Report - $CurDate",
   file    => ...,
   ...
);

$webhook->execute( %params );

相关问题