optional embed title field for ctx.maybe_send_embed() #4879
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 milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot#4879
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
What component of Red (cog, command, API) would you like to see improvements on?
ctx.maybe_send_embed()
Describe the enhancement you're suggesting.
In
ctx.maybe_send_embed(), accept an optional kwarg for the title of the embed if it is able to be sent. This function has proved to be very helpful and takes the place of a manually created check-for-embed-permissions-and-send function in every cog, and it would be great to have this additional feature for when a title would be nice to have but is not required. Additionally, this could be expanded to accept every field a typical discord.Embed would accept, but currently the title field would be most useful.What would the function do with the title field if the message could NOT be sent as an embed? Ignore it, prepend it, etc?
prepending it would probably look ugly, best would be to ignore it
I agree with kingslayer268, I imagined this for scenarios where it's a nice to have but not need to have.
+1 to being able to pass an Embed object for use (instead of individual fields).
Yami, if that were the case would the fallback be just sending the description? If so, I think that's fine as well 👍
I'd probably rather the fallback be the existing message arg. That way people can customize it as they like for complex embeds
I think it would be good to still be able to use either the message arg as the embed desc (as right now) or the embed desc as the fallback message, as part of the reason this function is so helpful for me right now is that I only have to pass in 1 thing instead of both, otherwise it would only be 1 more step to add in a try-except myself instead.
I think there should be a completely different function for that,
ctx.maybe_send_embed()is meant for simple messagesI like the idea of being similar to regular
Messageable.sendbut instead of passing the content arg as the messages plain-text response it chooses to use either the plain-text or the embed field depending on embed-link permissions. Keeping backwards compatibility is a must though but adding an optional embed argument with the function sounds like it would work well.So my thought/thinking is this
Add an optional (kw)arg to the existing function that accepts a discord.Embed object (similar to
Messageable.sendas Trusty said).If the bot can send an Embed, it will use the new arg if provided, otherwise it will embed the existing
messagearg as it currently doesIf the bot can not send an Embed, it will use the existing message arg as normal
I was thinking similar to what Yami just said, but the message arg is made optional as well so in cases where that is not provided and an embed is, then the embed's description would be used (of course, one of the two would need to be provided).
I thought this method was supposed to be embed independent, if we were to pass a title, how would the title and content be shown when embed are disabled ? Same goes any other embed part.
If we want to just send based on context permissions perhaps we should just add a public accessible attribute to context to flag if embeds are allowed in the context and let the develop handle it how they want (to avoid building both an embed object and a text object) the behaviour in this method should be consistent across the board (the final message)
I don't think pulling the embed description is worth it since the user can provide that themselves with the proposed alternative by doing
await ctx.maybe_send_embed(embed.description, embed=embed). The original arg's should still exist as they do now just add the new optional (kw)arg for a full embed to use.Thanks Trusty for explaining that, I agree now that the original message arg can stay as is.
Erledigt in
00637234e. Neu:ctx.maybe_send_embed(message, *, title=None). Der Titel wird als Embed-Titel verwendet oder ohne Embed fett vorangestellt.Generated by Claude Code