如何让机器人在discord php中编辑自己的消息

问题描述 投票:0回答:1

有人知道如何让 BOT 在 DiscordPHP 中编辑自己的消息吗?

我已经创建了,但它们总是在 Uncaught Error: Call to a member function edit() on null 上出错 这是我的代码:

$message->edit(MessageBuilder::new()
            ->setContent('embeds')
            ->setTts(true))->done()
php discord
1个回答
0
投票

我为我的机器人制作了一台老虎机,并在谷歌上搜索了这个。但我自己发现了。

在我的代码中,我使用了这个:

$msg->reply("Slot is spinning... <a:loading:990300992287424553> \n<a:slotmachine:990303077213012008> <a:slotmachine:990303077213012008> <a:slotmachine:990303077213012008>")->then(function($msg)
{
    if(!($msg instanceof Message)) return $msg->reply("An error excepted.");
    $this->discord->getLoop()->addTimer(3.0, function() use ($msg) {
        $msg->channel->editMessage($msg, "Slot has been spinned. \n:strawberry: :strawberry: :strawberry:");
    });
});

您可以使用这个:

$msg->channel->sendMessage("Hello")->then(function($msg){
    $msg->channel->editMessage($msg, "How are u?");
});

如果你想要超时,你可以像我的代码一样使用。

© www.soinside.com 2019 - 2024. All rights reserved.