Skip to content
This repository has been archived by the owner on Feb 6, 2018. It is now read-only.

Fix mute/tempmute #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions rowboat/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ def serialize(self, guild=None, user=None, actor=None, include_metadata=False):
return base

@staticmethod
def admin_config(event):
return getattr(event.base_config.plugins, 'admin', None)
def infractions_config(event):
return getattr(event.base_config.plugins, 'infractions', None)

@classmethod
def temprole(cls, plugin, event, member, role_id, reason, expires_at):
Expand Down Expand Up @@ -335,17 +335,17 @@ def warn(cls, plugin, event, member, reason, guild):
@classmethod
def mute(cls, plugin, event, member, reason):
from rowboat.plugins.modlog import Actions
admin_config = cls.admin_config(event)
infractions_config = cls.infractions_config(event)

plugin.call(
'ModLogPlugin.create_debounce',
event,
['GuildMemberUpdate'],
user_id=member.user.id,
role_id=admin_config.mute_role,
role_id=infractions_config.mute_role,
)

member.add_role(admin_config.mute_role, reason=reason)
member.add_role(infractions_config.mute_role, reason=reason)

plugin.call(
'ModLogPlugin.log_action_ext',
Expand All @@ -362,14 +362,14 @@ def mute(cls, plugin, event, member, reason):
actor_id=event.author.id,
type_=cls.Types.MUTE,
reason=reason,
metadata={'role': admin_config.mute_role})
metadata={'role': infractions_config.mute_role})

@classmethod
def tempmute(cls, plugin, event, member, reason, expires_at):
from rowboat.plugins.modlog import Actions
admin_config = cls.admin_config(event)
infractions_config = cls.infractions_config(event)

if not admin_config.mute_role:
if not infractions_config.mute_role:
plugin.log.warning('Cannot tempmute member %s, no tempmute role', member.id)
return

Expand All @@ -378,10 +378,10 @@ def tempmute(cls, plugin, event, member, reason, expires_at):
event,
['GuildMemberUpdate'],
user_id=member.user.id,
role_id=admin_config.mute_role,
role_id=infractions_config.mute_role,
)

member.add_role(admin_config.mute_role, reason=reason)
member.add_role(infractions_config.mute_role, reason=reason)

plugin.call(
'ModLogPlugin.log_action_ext',
Expand All @@ -400,7 +400,7 @@ def tempmute(cls, plugin, event, member, reason, expires_at):
type_=cls.Types.TEMPMUTE,
reason=reason,
expires_at=expires_at,
metadata={'role': admin_config.mute_role})
metadata={'role': infractions_config.mute_role})

@classmethod
def clear_active(cls, event, user_id, types):
Expand Down