[Streams] Add toggleable button to stream alerts #5856
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!5856
Loading…
Reference in a new issue
No description provided.
Delete branch "streams-button"
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?
Description of the changes
This PR adds a toggleable
[p]streamset livebuttonsetting which creates a button under each stream alert (created either through[p]streamalertor[p]twitchstream/[p]youtubestreamand the like) that will link to the relevant stream.It is off by default.
Closes #5646
I'm also not sure if
livebuttonis the best name for this setting, I couldn't think of anything better. Maybe something likebuttonsorusebuttonslooks better? Would love to hear feedback.Have the changes in this PR been tested?
Yes
Since #5683 has now been merged, should the toggle for the button be taken from[p]set usebuttonsinstead of having it be a separate setting?In case not,I've renamed the setting to[p]streamset usebuttonsfor consistency.EDIT: After a short discussion on Discord, the setting should stay like it currently is since
[p]set usebuttonsis global, while[p]streamset usebuttonsshould be per-guild.Functionally works fine (aside from a small timeout issue which is mentioned in the review comment), I just have a couple of stylistic suggestions.
Code above is identical, this can be deduplicated by making this fragment not part of the
if. To simplify this further,viewcan be set toNoneby default as then we don't have to do a ternary if insidectx.send()call.Also, the view needs to have a timeout set to
Noneas the default is 3 minutes.Code below is identical, this can be deduplicated.
@ -708,0 +720,4 @@@streamset.command(name="usebuttons")@commands.guild_only()async def use_buttons(self, ctx: commands.Context):"""Toggle whether to use buttons for stream alerts."""@ -776,0 +801,4 @@use_buttons: bool = await self.config.guild(channel.guild).use_buttons()view = Noneif use_buttons:stream_url = embed.urlSimplification by removal of the ternary if operator and replacing it with always setting initial value of
viewtoNone.Also, the view needs to have a timeout set to
Noneas the default is 3 minutes.From my testing I actually found that timeouts don't matter for
discord.ButtonStyle.linkstyle buttons, they're usable past the timeout which is why I didn't set one. You're right though that it's still better to set it explicitly.Hmm, you're right, we actually shouldn't set a timeout to
Nonebecause then it forever stays in the memory. We should just keep the default so that it's at least removed from the memory after 3 minutes.The reason why I suggested this change was that the buttons disappeared from the message after a bit which I thought was related to the timeout (but it isn't because that would require you to explicitly edit the message in
on_timeout())... I'm actually not sure why it happened and if it actually happened (maybe I confused messages?).Would you mind removing the
timeout=parameter?Done! You might've had
[p]streamset autodeletetoggled on and didn't notice the message getting deleted? Not sureI think that "Watch the stream" might be a better button caption, what do you think?
Sure, sounds more natural to me
Works as expected.