Skip to content

feat: add verified role auto-grant cog#6

Closed
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1770879525-verified-role-cog
Closed

feat: add verified role auto-grant cog#6
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1770879525-verified-role-cog

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Feb 12, 2026

feat: add verified role auto-grant cog

Summary

Adds a new Verified cog that automatically grants the Verified role whenever Logistics or Problem Writing is added to a member. Includes:

  • on_member_update listener that detects trigger role additions, grants Verified, and looks up the audit log to identify who added the role
  • Logs all grants to <#1471399531580100670> with member mention, trigger role name, and moderator info
  • Hourly periodic sync loop that catches any members who have a trigger role but are missing Verified
  • Enables intents.members (privileged intent) on the bot

Review & Testing Checklist for Human

  • Privileged intent: intents.members = True requires the "Server Members Intent" toggle to be enabled in the Discord Developer Portal. If not already on, the bot will fail to connect after this change.
  • Audit log attribute access: entry.changes.after.roles on line 63 may raise AttributeError if entry.changes.after is None or lacks a .roles attribute — the surrounding try/except only catches discord.Forbidden and discord.HTTPException, not AttributeError. Worth verifying against the discord.py docs or testing live.
  • Verify hardcoded values: Confirm channel ID 1471399531580100670 and role names "Verified", "Logistics", "Problem Writing" match the actual server configuration exactly (case-sensitive).
  • Live test: Deploy to a test environment or staging bot, add Logistics/Problem Writing to a member, and confirm (a) Verified is granted, (b) log message appears in the channel with correct moderator attribution, (c) periodic sync catches existing members missing Verified.

Notes


Open with Devin

Co-Authored-By: Oliver Ni <oliver.ni@gmail.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor Author

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

@devin-ai-integration
Copy link
Contributor Author

Closing due to inactivity for more than 7 days. Configure here.

Copy link
Contributor Author

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

limit=10,
):
if entry.target and entry.target.id == after.id:
if any(r.name in TRIGGER_ROLE_NAMES for r in entry.changes.after.roles):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Unhandled AttributeError when audit log entry is a role-removal-only action

On line 59, entry.changes.after.roles is accessed inside a try/except that only catches discord.Forbidden and discord.HTTPException. In discord.py, AuditLogDiff attributes are set dynamically: for member_role_update entries, $add populates after.roles and $remove populates before.roles. If one of the 10 fetched audit log entries targeting the same member is a role removal (no roles added), entry.changes.after won't have a roles attribute, raising AttributeError. This is not caught by the except clause, so the entire on_member_update handler crashes—meaning the log message to the channel is never sent.

Example crash scenario

A moderator removes some role from the member shortly before (or concurrently with) adding a trigger role. The audit log now has a removal entry for the same member within the last 10 member_role_update entries. The loop hits that entry first, entry.target.id == after.id matches, and entry.changes.after.roles raises AttributeError.

Suggested change
if any(r.name in TRIGGER_ROLE_NAMES for r in entry.changes.after.roles):
if hasattr(entry.changes.after, 'roles') and any(r.name in TRIGGER_ROLE_NAMES for r in entry.changes.after.roles):
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@devin-ai-integration
Copy link
Contributor Author

Devin is archived and cannot be woken up. Please unarchive Devin if you want to continue using it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants