Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle discord commands like laravel commands #10

Open
Wulfheart opened this issue Mar 10, 2023 · 4 comments
Open

Handle discord commands like laravel commands #10

Wulfheart opened this issue Mar 10, 2023 · 4 comments

Comments

@Wulfheart
Copy link

Hello,

I started to work on a discord bot after I found your package lacking too much functionality. However, after the 1.0.0 update I am blown away by the functionality it offers right now. Great work!

I would like to extend the package to have Commands which look like Laravel's artisan commands.
Would you be willing to merge such a PR?

Thank you in advance.

@nwilging
Copy link
Owner

I'd be very interested to see that implementation. Anything that can appropriately/efficiently "laravel-ize" things in this package are welcome.

@Wulfheart
Copy link
Author

Wulfheart commented Mar 10, 2023

Am I allowed to bump the php version to at least 8.1?

@nwilging
Copy link
Owner

if it's absolutely necessary, sure. however there is a small percentage of installs of this package on 7.4, so ideally it still supports that far back (despite being EOL, we all know how PHP upgrades in the wild usually go 😂 )

@Wulfheart
Copy link
Author

It turns out I don't have that much time right now. I tinkered around with an extension but it would require some changes in your codebase. Namely it lacks the ability to send responses directly from a command (https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response).
My basic proposed file structure would be:

class MyCommand extends SlashCommand {
  protected string $name = 'MyName';
  protected string $description = 'MyDescription';
  
  public function handle(): void {
    doSomething();
    // Until now it would show the loading bar as the whole command gets pushed to the queue
    $this->sendResponse(new Message('content', $embeds, $components));
    $this->sendFollowUp(new Message('content'));
  }
}

@nwilging nwilging mentioned this issue Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants