docs: Document SetApiView/SetApiModal in Shared API Keys guide #6803
No reviewers
Labels
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot!6803
Loading…
Reference in a new issue
No description provided.
Delete branch "docs/apikeys-setapiview"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds a "Prompting for API Keys" section to the Shared API Keys guide, covering
SetApiView/SetApiModal.Closes #6114
Description of the changes
The guide only covers the
[p]set apiroute and reading tokens back in code - nothing aboutSetApiView/SetApiModalinredbot.core.utils.views, which are a handy way to let a cog prompt the owner for keys via a secure button + modal instead of typing them in chat.The new section covers:
SetApiViewwithdefault_service/default_keysto prompt for a service's keyskey value-per-line format, and that you keep the pre-filled key label (typing just the value gets rejected - this caught me out at first)SetApiModalfor embedding in a customdiscord.ui.ViewDocs only, no code changes.
Have the changes in this PR been tested?
Yes
@ -48,6 +48,37 @@ Basic Usage# Use the API key to access content as you normally wouldI think
[p]set apishould be the "primary" way that users interface with the API key system, with the View already spawning from that command if no inputs are given (albeit without the service specific hints). Instead, I think the View is better used as a fallback included with the error message when the owner attempts to use a command requiring an API where the key has not been set. Adding an extra command in your cog that does the same thing as the existing command just bloats the bot with no real benefit, but dynamically responding to commands that fail due to missing keys can save a step for the owner.Changing the example to that kind of setup would be more impactful.
@ -48,6 +48,37 @@ Basic Usage# Use the API key to access content as you normally wouldGood point - I hadn't clocked that
[p]set apialready opens the modal when run bare, so a separate command really is just duplication. Reworked the example around the missing-key fallback instead: the command checks for the key and, if it isn't set, replies with the error plus the button so the owner can set it in place. Better fit, thanks!Attempting to make some things render nicer
@ -48,6 +48,37 @@ Basic Usage# Use the API key to access content as you normally wouldThank you for contributing!