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

[Integration] - Create a Discord CLI Tool in Rust Integrated with the Command API #62

Open
miguelcsx opened this issue Sep 26, 2024 · 0 comments

Comments

@miguelcsx
Copy link
Owner

Description

We want to develop a CLI tool in Rust that integrates with our existing command API, allowing users to interact with the commands and data from a terminal. This will broaden accessibility beyond Discord and provide a command-line interface for easier automation, scripting, and integration into other workflows.

Background

As we are externalizing the commands through a RESTful API, it's important to provide users with additional ways to interact with the commands. A command-line interface (CLI) will allow developers and users to access the API from their terminal, enabling more flexible usage scenarios without needing to rely on Discord. This CLI should be easy to use, well-documented, and support the same commands and functionality that the API offers.

Proposal

  1. CLI Implementation in Rust:

    • Build the Discord CLI tool using Rust to leverage its performance, safety features, and rich ecosystem for command-line tools.
    • The CLI will interact with the command API, allowing users to execute commands and retrieve data through simple terminal commands.
  2. Command Mapping:

    • Mirror the available commands from the Discord bot (now abstracted in the API) to be usable from the CLI.
    • Each command should correspond to an API endpoint, providing feedback, outputs, and error handling.
  3. Data Access:

    • The CLI should allow users to fetch data such as command results, logs, or any other relevant information exposed by the API.
    • Ensure that users can query and filter results as needed, potentially supporting flags and options for more customized outputs.
  4. Authentication:

    • Implement authentication mechanisms to ensure secure access to the API.
    • Support token-based authentication to verify user access.
  5. Documentation and Help Commands:

    • Provide comprehensive documentation, including installation instructions, usage examples, and explanations of available commands.
    • Implement --help commands for easy access to usage information for each CLI command.
  6. Extensibility:

    • Design the CLI to be easily extensible, allowing new commands and API features to be added with minimal friction.
    • Ensure future API updates can be smoothly integrated into the CLI.

Benefits

  1. Extended Access: Users can now interact with the command API outside of Discord, making it easier to integrate the commands into various workflows, CI/CD pipelines, or automation scripts.
  2. Developer-Friendly: The Rust-based CLI will provide a fast, lightweight tool that can be easily incorporated into different development environments.
  3. Platform Independence: As a standalone CLI tool, it can be used on multiple platforms (Windows, Linux, macOS) without being tied to Discord’s infrastructure.
  4. Scripting and Automation: Developers can leverage the CLI in their scripts, expanding the potential for automation and customized workflows.

Potential Challenges

  1. API Integration: Ensuring seamless and efficient interaction with the API, especially for commands that require real-time or near-real-time execution.
  2. Error Handling: Handling errors gracefully in the CLI, such as API failures, network issues, or invalid commands.
  3. Security: Properly securing the CLI’s authentication process to ensure that only authorized users can access the API.
  4. User Experience: Ensuring a smooth user experience through clear feedback, meaningful error messages, and intuitive command structures.

Conclusion

By creating a Discord CLI integrated with our API using Rust, we can significantly expand the tool’s accessibility, making it a powerful tool for developers and users who prefer command-line interaction. This will also open up new use cases for automation and system integrations, driving further growth and flexibility for the tool.

miguelcsx added a commit that referenced this issue Sep 26, 2024
- used serenity lib to build discord bot

- made http requests with reqwest

- updated .gitignore and pre-commit for rust integration
miguelcsx added a commit that referenced this issue Sep 26, 2024
- used serenity lib to build discord bot

- made http requests with reqwest

- updated .gitignore and pre-commit for rust integration
miguelcsx added a commit that referenced this issue Oct 1, 2024
- updated dependencies to build slash commands

- made command for `ping` endpoint

- loaded config from environment
miguelcsx added a commit that referenced this issue Oct 1, 2024
- updated dependencies to build slash commands

- made command for `ping` endpoint

- loaded config from environment
miguelcsx added a commit that referenced this issue Oct 2, 2024
- updated dependencies to build slash commands

- made command for `ping` endpoint

- loaded config from environment
miguelcsx added a commit that referenced this issue Oct 2, 2024
- updated dependencies to build slash commands

- made command for `ping` endpoint

- loaded config from environment

For more info look at: #62
miguelcsx added a commit that referenced this issue Oct 17, 2024
## Description

This PR adds an event handler to the Discord bot that prints a message
to the console when the server is ready.

### Changes Made

- Implemented the `on_ready` event to log the bot's status with the
message: "Logged in as {bot_name}!"

### Related Issues

- #62
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

1 participant