Add allowed_mentions and mention everyone check to stream alerts #4182

Merged
kablekompany merged 16 commits from patch-1 into V3/develop 2020-08-16 00:59:54 +02:00
kablekompany commented 2020-08-14 06:13:45 +02:00 (Migrated from github.com)

Allows role mentions for discord.py 1.4+

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

Referencing line 747 in commit. Gives permissions to mention role on stream announcement.

Allows role mentions for discord.py 1.4+ ### Type - [x] Bugfix - [ ] Enhancement - [ ] New feature ### Description of the changes Referencing line `747` in commit. Gives permissions to mention role on stream announcement.
palmtree5 (Migrated from github.com) reviewed 2020-08-14 06:13:45 +02:00
Twentysix26 (Migrated from github.com) reviewed 2020-08-14 06:13:45 +02:00
Jackenmen (Migrated from github.com) reviewed 2020-08-14 21:40:50 +02:00
Jackenmen (Migrated from github.com) left a comment

While this PR solves the issue with mentions not actually pinging, do you think you could also make this not edit the roles if bot has mention everyone perms (as that perm now also allows to ping non-mentionable roles)?

While this PR solves the issue with mentions not actually pinging, do you think you could also make this not edit the roles if bot has mention everyone perms (as that perm now also allows to ping non-mentionable roles)?
kablekompany commented 2020-08-15 09:46:01 +02:00 (Migrated from github.com)

Lines for reference:

  • [750-754]:
guild = channel.guild
can_mention_everyone = guild.me.guild_permissions.mention_everyone
if can_mention_everyone:
  await self.save_streams()
  return # if bot can mention everyone already, let's stop here 
  • [772-776]:
can_mention_everyone = guild.me.guild_permissions.mention_everyone
if can_mention_everyone:
  for role in guild.roles:
    mentions.append(role.mention)
    return  # if bot can mention everyone already, let's stop here

Hopefully, this is what you had in mind? Humbly admit I may not have a business in biting this piece but looking forward to feedback on the best methodology for the wanted outcome. Sorry for the redraws on simple mistakes...

Thanks!

## Lines for reference: - `[750-754]`: ```py guild = channel.guild can_mention_everyone = guild.me.guild_permissions.mention_everyone if can_mention_everyone: await self.save_streams() return # if bot can mention everyone already, let's stop here ``` - `[772-776]`: ```py can_mention_everyone = guild.me.guild_permissions.mention_everyone if can_mention_everyone: for role in guild.roles: mentions.append(role.mention) return # if bot can mention everyone already, let's stop here ``` Hopefully, this is what you had in mind? Humbly admit I may not have a business in biting this piece but looking forward to feedback on the best methodology for the wanted outcome. Sorry for the redraws on simple mistakes... Thanks!
Jackenmen (Migrated from github.com) requested changes 2020-08-15 12:09:06 +02:00
Jackenmen (Migrated from github.com) left a comment

The added changes make the bot mention all roles in the guild, which is not the same behavior as there was before.

This can also be simplified a lot, I sent the review comments which should make it clear what should be done here.

The added changes make the bot mention all roles in the guild, which is not the same behavior as there was before. This can also be simplified a lot, I sent the review comments which should make it clear what should be done here.
Jackenmen (Migrated from github.com) commented 2020-08-15 11:57:54 +02:00

This can all be removed if you apply my other suggestion.

This can all be removed if you apply my other suggestion. ```suggestion ```
@ -760,9 +768,10 @@ class Streams(commands.Cog):
if await settings.mention_here():
mentions.append("@here")
Jackenmen (Migrated from github.com) commented 2020-08-15 11:59:04 +02:00

This can be all removed if you apply my other suggestion.

This can be all removed if you apply my other suggestion. ```suggestion ```
Jackenmen (Migrated from github.com) commented 2020-08-15 12:02:52 +02:00

This is all that needs to be done here:

                if not can_mention_everyone and can_manage_roles and not role.mentionable:
This is all that needs to be done here: ```suggestion if not can_mention_everyone and can_manage_roles and not role.mentionable: ```
Jackenmen (Migrated from github.com) commented 2020-08-15 12:05:22 +02:00

It would be better if this were checking for permissions in channel:

        can_mention_everyone = channel.permissions_for(guild.me).mention_everyone

This requires you to also add a channel argument to this function and pass it in the place where it's called.

It would be better if this were checking for permissions in channel: ```suggestion can_mention_everyone = channel.permissions_for(guild.me).mention_everyone ``` This requires you to also add a `channel` argument to this function and pass it in the place where it's called.
kablekompany commented 2020-08-15 20:48:43 +02:00 (Migrated from github.com)

committed suggestions and added channel iteration for can_mention_everyone github.com/kablekompany/Red-DiscordBot@8eb21913bb/redbot/cogs/streams/streams.py (L767)

committed suggestions and added channel iteration for `can_mention_everyone` https://github.com/kablekompany/Red-DiscordBot/blob/8eb21913bb402b634af7a22a0414ede7c3014eb4/redbot/cogs/streams/streams.py#L767
Jackenmen (Migrated from github.com) reviewed 2020-08-15 20:50:17 +02:00
Jackenmen (Migrated from github.com) commented 2020-08-15 20:50:17 +02:00

As I said before, you need to add channel param to _get_mention_str() method so that the bot checks the permission for the channel it will send the message in. Iterating through all channels here doesn't make much sense - we only care about permissions in that specific channel the message will be sent in.

As I said before, you need to add `channel` param to `_get_mention_str()` method so that the bot checks the permission for the channel it will send the message in. Iterating through all channels here doesn't make much sense - we only care about permissions in *that specific channel* the message will be sent in.
kablekompany (Migrated from github.com) reviewed 2020-08-15 21:03:06 +02:00
kablekompany (Migrated from github.com) commented 2020-08-15 21:03:06 +02:00

understood. param added, iteration removed

understood. param added, iteration removed
Jackenmen (Migrated from github.com) requested changes 2020-08-15 21:09:31 +02:00
Jackenmen (Migrated from github.com) left a comment

Looks alright now, there's just one thing left - it looks like you forgot to pass the channel argument to _get_mention_str() call in line 716.

Looks alright now, there's just one thing left - it looks like you forgot to pass the channel argument to `_get_mention_str()` call in line 716.
kablekompany commented 2020-08-15 21:22:15 +02:00 (Migrated from github.com)

big time appreciate your patience and guidance @jack1142

big time appreciate your patience and guidance @jack1142
Jackenmen (Migrated from github.com) approved these changes 2020-08-16 00:58:16 +02:00
Jackenmen (Migrated from github.com) left a comment

Looks good to me, and thanks so much for including new functionality related to Mention Everyone perm as well ❤️

Looks good to me, and thanks so much for including new functionality related to Mention Everyone perm as well ❤️
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
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!4182
No description provided.