mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-08 20:28:55 -05:00
[Streams] Improve config calls in stream alerts (#4968)
* [Streams] Improve config calls in stream alerts. * config->guild_data, style changes Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
parent
88abe469b6
commit
8eac787f7b
@ -784,11 +784,11 @@ class Streams(commands.Cog):
|
|||||||
continue
|
continue
|
||||||
if await self.bot.cog_disabled_in_guild(self, channel.guild):
|
if await self.bot.cog_disabled_in_guild(self, channel.guild):
|
||||||
continue
|
continue
|
||||||
ignore_reruns = await self.config.guild(channel.guild).ignore_reruns()
|
|
||||||
if ignore_reruns and is_rerun:
|
guild_data = await self.config.guild(channel.guild).all()
|
||||||
|
if guild_data["ignore_reruns"] and is_rerun:
|
||||||
continue
|
continue
|
||||||
ignore_schedules = await self.config.guild(channel.guild).ignore_schedule()
|
if guild_data["ignore_schedule"] and is_schedule:
|
||||||
if ignore_schedules and is_schedule:
|
|
||||||
continue
|
continue
|
||||||
if is_schedule:
|
if is_schedule:
|
||||||
# skip messages and mentions
|
# skip messages and mentions
|
||||||
@ -798,15 +798,13 @@ class Streams(commands.Cog):
|
|||||||
await set_contextual_locales_from_guild(self.bot, channel.guild)
|
await set_contextual_locales_from_guild(self.bot, channel.guild)
|
||||||
|
|
||||||
mention_str, edited_roles = await self._get_mention_str(
|
mention_str, edited_roles = await self._get_mention_str(
|
||||||
channel.guild, channel
|
channel.guild, channel, guild_data
|
||||||
)
|
)
|
||||||
|
|
||||||
if mention_str:
|
if mention_str:
|
||||||
alert_msg = await self.config.guild(
|
if guild_data["live_message_mention"]:
|
||||||
channel.guild
|
# Stop bad things from happening here...
|
||||||
).live_message_mention()
|
content = guild_data["live_message_mention"]
|
||||||
if alert_msg:
|
|
||||||
content = alert_msg # Stop bad things from happening here...
|
|
||||||
content = content.replace(
|
content = content.replace(
|
||||||
"{stream.name}", str(stream.name)
|
"{stream.name}", str(stream.name)
|
||||||
) # Backwards compatibility
|
) # Backwards compatibility
|
||||||
@ -825,11 +823,9 @@ class Streams(commands.Cog):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
alert_msg = await self.config.guild(
|
if guild_data["live_message_nomention"]:
|
||||||
channel.guild
|
# Stop bad things from happening here...
|
||||||
).live_message_nomention()
|
content = guild_data["live_message_nomention"]
|
||||||
if alert_msg:
|
|
||||||
content = alert_msg # Stop bad things from happening here...
|
|
||||||
content = content.replace(
|
content = content.replace(
|
||||||
"{stream.name}", str(stream.name)
|
"{stream.name}", str(stream.name)
|
||||||
) # Backwards compatibility
|
) # Backwards compatibility
|
||||||
@ -859,17 +855,16 @@ class Streams(commands.Cog):
|
|||||||
await self.save_streams()
|
await self.save_streams()
|
||||||
|
|
||||||
async def _get_mention_str(
|
async def _get_mention_str(
|
||||||
self, guild: discord.Guild, channel: discord.TextChannel
|
self, guild: discord.Guild, channel: discord.TextChannel, guild_data: dict
|
||||||
) -> Tuple[str, List[discord.Role]]:
|
) -> Tuple[str, List[discord.Role]]:
|
||||||
"""Returns a 2-tuple with the string containing the mentions, and a list of
|
"""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.
|
all roles which need to have their `mentionable` property set back to False.
|
||||||
"""
|
"""
|
||||||
settings = self.config.guild(guild)
|
|
||||||
mentions = []
|
mentions = []
|
||||||
edited_roles = []
|
edited_roles = []
|
||||||
if await settings.mention_everyone():
|
if guild_data["mention_everyone"]:
|
||||||
mentions.append("@everyone")
|
mentions.append("@everyone")
|
||||||
if await settings.mention_here():
|
if guild_data["mention_here"]:
|
||||||
mentions.append("@here")
|
mentions.append("@here")
|
||||||
can_manage_roles = guild.me.guild_permissions.manage_roles
|
can_manage_roles = guild.me.guild_permissions.manage_roles
|
||||||
can_mention_everyone = channel.permissions_for(guild.me).mention_everyone
|
can_mention_everyone = channel.permissions_for(guild.me).mention_everyone
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user