Skip to content

Commit

Permalink
roles
Browse files Browse the repository at this point in the history
  • Loading branch information
geirawsm committed Jul 29, 2024
1 parent e533998 commit aa7f80a
Showing 1 changed file with 37 additions and 32 deletions.
69 changes: 37 additions & 32 deletions sausage_bot/cogs/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,38 +1471,41 @@ async def on_raw_reaction_add(payload):
select=('msg_id')
)
_guild = discord_commands.get_guild()
log.debug(f'reaction_messages[0]: {list(reaction_messages[0])}')
log.debug(f'payload.message_id: {payload.message_id}')
if str(payload.message_id) in list(reaction_messages[0]):
# TODO var msg
log.debug('Found message, checking add reactions...')
emoji_string = f'<:{payload.emoji.name}:{payload.emoji.id}>'
reactions = await db_helper.get_combined_output(
envs.roles_db_roles_schema,
envs.roles_db_msgs_schema,
key='msg_id',
select=[
'emoji',
'role_name'
],
where=[
('A.msg_id', payload.message_id)
]
)
log.debug(f'emoji_string is {emoji_string}')
log.debug(f'reactions is {reactions}')
for reaction in reactions:
if emoji_string in reaction[0]:
role_id = re.search(
r'<@&(\d+)>', reaction[1]
)[1]
await _guild.get_member(
payload.user_id
).add_roles(
get(discord_commands.get_guild().roles, id=int(role_id)),
reason='Added in accordance with '
'reaction messages'
)
for reaction_message in reaction_messages:
if str(payload.message_id) == str(reaction_message[0]):
# TODO var msg
log.debug('Found message, checking add reactions...')
emoji_string = f'<:{payload.emoji.name}:{payload.emoji.id}>'
reactions = await db_helper.get_combined_output(
envs.roles_db_roles_schema,
envs.roles_db_msgs_schema,
key='msg_id',
select=[
'emoji',
'role_name'
],
where=[
('A.msg_id', payload.message_id)
]
)
log.debug(f'emoji_string is {emoji_string}')
log.debug(f'reactions is {reactions}')
for reaction in reactions:
if emoji_string in reaction[0]:
role_id = re.search(
r'<@&(\d+)>', reaction[1]
)[1]
await _guild.get_member(
payload.user_id
).add_roles(
get(
discord_commands.get_guild().roles,
id=int(role_id)
),
reason='Added in accordance with '
'reaction messages'
)
break
break
return

Expand Down Expand Up @@ -1559,6 +1562,8 @@ async def on_raw_reaction_remove(payload):
f'{reaction_message}'
)
break
break
break
return


Expand Down

0 comments on commit aa7f80a

Please sign in to comment.