[CustomCom] Add last_editor in [p]cc show and add the alias [p]cc info to this command. #6216

Manually merged
AAA3A-AAA3A merged 0 commits from AAA3A-AAA3A/patch-11 into V3/develop 2026-11-21 16:09:45 +01:00
AAA3A-AAA3A commented 2023-07-25 13:34:23 +02:00 (Migrated from github.com)

Description of the changes

Hello,

This PR adds the last editor of a CC to the output of the [p]cc show command. If the CC was created before this PR was merged, the cog will use editors[-1]. This allows the author of a CC to know who modified it and to check before removing a change.
This PR also adds the alias [p]cc info to this command, as I think this is the command name that comes to mind when you think of "displaying information about a CC".

Thanks in advance,
Have a nice day,
AAA3A

Have the changes in this PR been tested?

Yes

### Description of the changes Hello, This PR adds the last editor of a CC to the output of the `[p]cc show` command. If the CC was created before this PR was merged, the cog will use `editors[-1]`. This allows the author of a CC to know who modified it and to check before removing a change. This PR also adds the alias `[p]cc info` to this command, as I think this is the command name that comes to mind when you think of "displaying information about a CC". Thanks in advance, Have a nice day, AAA3A ### Have the changes in this PR been tested? <!-- Choose one (remove the line that doesn't apply): --> Yes <!-- If the question doesn't apply (for example, it's not a code change), choose Yes. Please respond to this question truthfully. We do not delay nor reject PRs based on the answer to this question but it allows to better review this PR. -->
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2026-05-20 13:12:20 +02:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull request overview

This pull request enhances the CustomCommands cog by exposing “last editor” information in the [p]cc show output and adding a more discoverable alias for the command.

Changes:

  • Track and store last_editor metadata when a custom command is edited.
  • Display Last editor in [p]cc show, with a fallback to editors[-1] for older commands.
  • Add [p]cc info as an alias of [p]cc show.
Comments suppressed due to low confidence (1)

redbot/cogs/customcom/customcom.py:629

  • In the elif cmd.get("last_editor"): branch, the code assigns to author instead of last_editor, which can also leave last_editor undefined and crash when formatting the output (e.g., when the last editor is no longer in the guild). This branch should set the last_editor display string instead.
            elif member := ctx.guild.get_member(_leid):
                last_editor = f"{member} ({_leid})"
            elif cmd.get("last_editor"):
                author = f"{cmd['last_editor']['name']} ({_leid})"
            else:

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

## Pull request overview This pull request enhances the CustomCommands cog by exposing “last editor” information in the `[p]cc show` output and adding a more discoverable alias for the command. **Changes:** - Track and store `last_editor` metadata when a custom command is edited. - Display `Last editor` in `[p]cc show`, with a fallback to `editors[-1]` for older commands. - Add `[p]cc info` as an alias of `[p]cc show`. <details> <summary>Comments suppressed due to low confidence (1)</summary> **redbot/cogs/customcom/customcom.py:629** * In the `elif cmd.get("last_editor"):` branch, the code assigns to `author` instead of `last_editor`, which can also leave `last_editor` undefined and crash when formatting the output (e.g., when the last editor is no longer in the guild). This branch should set the `last_editor` display string instead. ``` elif member := ctx.guild.get_member(_leid): last_editor = f"{member} ({_leid})" elif cmd.get("last_editor"): author = f"{cmd['last_editor']['name']} ({_leid})" else: ``` </details> --- 💡 <a href="/Cog-Creators/Red-DiscordBot/new/V3/develop?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
@ -74,0 +74,4 @@
if com_info.get("last_editor", {}).get("id", 0) == user_id:
com_info["last_editor"]["id"] = 0xDE1
com_info["last_editor"]["name"] = "Deleted User"
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-05-20 13:12:20 +02:00

com_info.get("last_editor", {}).get("id", 0) will raise an AttributeError when last_editor is present but set to None (as in newly-created CCs). Please guard against None (e.g., treat non-dict/None as {}) before calling .get() and before writing into com_info["last_editor"][...].

This issue also appears on line 625 of the same file.

`com_info.get("last_editor", {}).get("id", 0)` will raise an AttributeError when `last_editor` is present but set to `None` (as in newly-created CCs). Please guard against `None` (e.g., treat non-dict/None as `{}`) before calling `.get()` and before writing into `com_info["last_editor"][...]`. This issue also appears on line 625 of the same file.
Jackenmen (Migrated from github.com) requested changes 2026-05-28 15:13:30 +02:00
Jackenmen (Migrated from github.com) left a comment

I feel that it would be better for us to handle this entirely through the editors list rather than special-case the last editor - i.e. have a migration that changes editors from a list of IDs to a list of dictionaries in the form of: {"id": 123, "name": None} and update the implementation to append new editor as {"id: editor.id, "name": str(editor)} or, if they're already on the list, move them to the end (essentially making the list be in edit order).

I feel that it would be better for us to handle this entirely through the `editors` list rather than special-case the last editor - i.e. have a migration that changes `editors` from a list of IDs to a list of dictionaries in the form of: `{"id": 123, "name": None}` and update the implementation to append new editor as `{"id: editor.id, "name": str(editor)}` or, if they're already on the list, move them to the end (essentially making the list be in edit order).
Mrcoolgamer11 manually merged commit a047547099 into V3/develop 2026-11-21 16:09:45 +01:00
Sign in to join this conversation.
No reviewers
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
1 participant
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!6216
No description provided.