optional embed title field for ctx.maybe_send_embed() #4879

Closed
opened 2021-03-08 19:26:44 +01:00 by Obi-Wan3 · 15 comments
Obi-Wan3 commented 2021-03-08 19:26:44 +01:00 (Migrated from github.com)

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 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.
Flame442 commented 2021-03-08 19:45:52 +01:00 (Migrated from github.com)

What would the function do with the title field if the message could NOT be sent as an embed? Ignore it, prepend it, etc?

What would the function do with the title field if the message could NOT be sent as an embed? Ignore it, prepend it, etc?
kingslayer268 commented 2021-03-08 20:08:06 +01:00 (Migrated from github.com)

prepending it would probably look ugly, best would be to ignore it

prepending it would probably look ugly, best would be to ignore it
Obi-Wan3 commented 2021-03-08 20:14:15 +01:00 (Migrated from github.com)

I agree with kingslayer268, I imagined this for scenarios where it's a nice to have but not need to have.

I agree with kingslayer268, I imagined this for scenarios where it's a **nice** to have but not **need** to have.
yamikaitou commented 2021-03-08 21:03:11 +01:00 (Migrated from github.com)

+1 to being able to pass an Embed object for use (instead of individual fields).

+1 to being able to pass an Embed object for use (instead of individual fields).
Obi-Wan3 commented 2021-03-08 21:10:46 +01:00 (Migrated from github.com)

Yami, if that were the case would the fallback be just sending the description? If so, I think that's fine as well 👍

Yami, if that were the case would the fallback be just sending the description? If so, I think that's fine as well 👍
yamikaitou commented 2021-03-08 21:13:18 +01:00 (Migrated from github.com)

I'd probably rather the fallback be the existing message arg. That way people can customize it as they like for complex embeds

I'd probably rather the fallback be the existing message arg. That way people can customize it as they like for complex embeds
Obi-Wan3 commented 2021-03-08 21:16:56 +01:00 (Migrated from github.com)

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 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.
kingslayer268 commented 2021-03-08 21:28:41 +01:00 (Migrated from github.com)

+1 to being able to pass an Embed object for use (instead of individual fields).

I think there should be a completely different function for that, ctx.maybe_send_embed() is meant for simple messages

> +1 to being able to pass an Embed object for use (instead of individual fields). I think there should be a completely different function for that, `ctx.maybe_send_embed()` is meant for simple messages
TrustyJAID commented 2021-03-08 21:29:13 +01:00 (Migrated from github.com)

I like the idea of being similar to regular Messageable.send but 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.

I like the idea of being similar to regular `Messageable.send` but 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.
yamikaitou commented 2021-03-08 21:33:59 +01:00 (Migrated from github.com)

So my thought/thinking is this

Add an optional (kw)arg to the existing function that accepts a discord.Embed object (similar to Messageable.send as Trusty said).
If the bot can send an Embed, it will use the new arg if provided, otherwise it will embed the existing message arg as it currently does
If the bot can not send an Embed, it will use the existing message arg as normal

So my thought/thinking is this Add an optional (kw)arg to the existing function that accepts a discord.Embed object (similar to `Messageable.send` as Trusty said). If the bot can send an Embed, it will use the new arg if provided, otherwise it will embed the existing `message` arg as it currently does If the bot can not send an Embed, it will use the existing message arg as normal
Obi-Wan3 commented 2021-03-08 21:45:44 +01:00 (Migrated from github.com)

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 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).
Drapersniper commented 2021-03-08 21:47:38 +01:00 (Migrated from github.com)

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 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)
TrustyJAID commented 2021-03-08 21:47:45 +01:00 (Migrated from github.com)

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.

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.
Obi-Wan3 commented 2021-03-08 21:55:41 +01:00 (Migrated from github.com)

Thanks Trusty for explaining that, I agree now that the original message arg can stay as is.

Thanks Trusty for explaining that, I agree now that the original message arg can stay as is.
Owner

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

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](https://claude.ai/code)_
Sign in to join this conversation.
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
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot#4879
No description provided.