Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
Discord PHP Create Invite link From Channel ID

I am developing a discord bot with php. I want to create invite link via DiscordPHP package.

Here what I write

include __DIR__.'/vendor/autoload.php';
use Discord\Discord;
$discord = new Discord([
    'token' => 'MY_TOKKEN',
]);
$discord->on('ready', function ($discord) {
    echo "Bot is ready!", PHP_EOL;
    $discord->on('message', function ($message, $discord) {
        $channel = $message->channel;
        $channel->createInvite([
            'max_age' => 60,
            'max_uses' => 5,
        ])->done(function (Invite $invite) {
            echo $invite->code;
        });
    });
});
$discord->run();

From echo $invite->code; I didn't getting any response string which I acn use to share.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I do not know discord lib , but you can debug by make var_dump($invite) and check result if you getting anything My update run this

include __DIR__.'/vendor/autoload.php';
use Discord\Discord;
$discord = new Discord([
    "token" => "your token",
]);
$discord->on('ready', function ($discord) {
    echo "Bot is ready!", PHP_EOL;
    $discord->on('message', function ($message, $discord) {
        $channel = $message->channel;
        $channel->createInvite([
            'max_age' => 60,
            'max_uses' => 5,
        ])->done(function (Invite $invite) {
            echo $invite->code;
        });
    });
}); $discord->run();

and check permissions on your discord that bot allowed to make invite

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!