Skip to content

Commit

Permalink
[StreamRoles] Option to disable automatic alert deletion
Browse files Browse the repository at this point in the history
Resolves #55.

Signed-off-by: Toby Harradine <[email protected]>
  • Loading branch information
Tobotimus committed Aug 26, 2019
1 parent efc5cb5 commit 56035c3
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion streamroles/streamroles.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(self, bot: Red):
mode=str(FilterList.blacklist),
alerts__enabled=False,
alerts__channel=None,
alerts__autodelete=True,
)
self.conf.register_member(
blacklisted=False, whitelisted=False, alert_messages={}
Expand Down Expand Up @@ -258,6 +259,19 @@ async def alerts_setchannel(
await self.conf.guild(ctx.guild).alerts.channel.set(channel.id)
await ctx.tick()

@alerts.command(name="autodelete")
async def alerts_autodelete(self,
ctx: commands.Context,
true_or_false: bool
):
"""Enable or disable alert autodeletion.
This is enabled by default. When enabled, alerts will be deleted
once the streamer's role is removed.
"""
await self.conf.guild(ctx.guild).alerts.autodelete.set(true_or_false)
await ctx.tick()

async def _get_filter_list(
self, guild: discord.Guild, mode: FilterList
) -> Tuple[List[discord.Member], List[discord.Role]]:
Expand Down Expand Up @@ -383,7 +397,7 @@ async def _update_member(
if has_role:
log.debug("Removing streamrole %s from member %s", role.id, member.id)
await member.remove_roles(role)
if channel:
if channel and await self.conf.guild(member.guild).alerts.autodelete():
await self._remove_alert(member, channel)

async def _update_members_with_role(self, role: discord.Role) -> None:
Expand Down

0 comments on commit 56035c3

Please sign in to comment.