mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Add allowed_mentions and mention everyone check to stream alerts (#4182)
* [streams]allowed_mentions on stream announcement Allows role mentions for discord.py 1.4+ # Type [x] Bugfix [ ] Enhancement [ ] New feature Description of the changes Referencing line 747. Gives permissions to mention role on stream announcement. * Update streams.py * Add `mention_everyone` defaults Lines for reference: - [751-753]: ```py if can_mention_everyone: await self.save_streams() return # if bot can mention everyone already, let's stop here``` - [722-774]: ```py if can_mention_everyone: mentions.append(role.mention) return # if bot can mention everyone already, let's stop here (part two)``` 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. Thanks! * *sweats* * imagine variable naming Should complete all passes. * misplaced unindent on return * Update redbot/cogs/streams/streams.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> * Update redbot/cogs/streams/streams.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> * Update redbot/cogs/streams/streams.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> * You're a beast jack Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> * this would cover all channels in guild (think) * give this a reeeeee * Update streams.py * adds channel argument https://github.com/Cog-Creators/Red-DiscordBot/pull/4182#pullrequestreview-468012281 * image style checking, self * imagine Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
parent
bf581b9f97
commit
341fd254fb
@ -712,7 +712,9 @@ class Streams(commands.Cog):
|
||||
ignore_reruns = await self.config.guild(channel.guild).ignore_reruns()
|
||||
if ignore_reruns and is_rerun:
|
||||
continue
|
||||
mention_str, edited_roles = await self._get_mention_str(channel.guild)
|
||||
mention_str, edited_roles = await self._get_mention_str(
|
||||
channel.guild, channel
|
||||
)
|
||||
|
||||
if mention_str:
|
||||
alert_msg = await self.config.guild(
|
||||
@ -749,14 +751,20 @@ class Streams(commands.Cog):
|
||||
)
|
||||
)
|
||||
|
||||
m = await channel.send(content, embed=embed)
|
||||
m = await channel.send(
|
||||
content,
|
||||
embed=embed,
|
||||
allowed_mentions=discord.AllowedMentions(roles=True, everyone=True),
|
||||
)
|
||||
stream._messages_cache.append(m)
|
||||
if edited_roles:
|
||||
for role in edited_roles:
|
||||
await role.edit(mentionable=False)
|
||||
await self.save_streams()
|
||||
|
||||
async def _get_mention_str(self, guild: discord.Guild) -> Tuple[str, List[discord.Role]]:
|
||||
async def _get_mention_str(
|
||||
self, guild: discord.Guild, channel: discord.TextChannel
|
||||
) -> Tuple[str, List[discord.Role]]:
|
||||
"""Returns a 2-tuple with the string containing the mentions, and a list of
|
||||
all roles which need to have their `mentionable` property set back to False.
|
||||
"""
|
||||
@ -768,9 +776,10 @@ class Streams(commands.Cog):
|
||||
if await settings.mention_here():
|
||||
mentions.append("@here")
|
||||
can_manage_roles = guild.me.guild_permissions.manage_roles
|
||||
can_mention_everyone = channel.permissions_for(guild.me).mention_everyone
|
||||
for role in guild.roles:
|
||||
if await self.config.role(role).mention():
|
||||
if can_manage_roles and not role.mentionable:
|
||||
if not can_mention_everyone and can_manage_roles and not role.mentionable:
|
||||
try:
|
||||
await role.edit(mentionable=True)
|
||||
except discord.Forbidden:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user