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

Commit

Permalink
Added debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Kowlin committed May 15, 2017
1 parent c769c45 commit a119b20
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions buyrole/buyrole.py
Expand Up @@ -11,6 +11,9 @@
from .utils import checks
import os
from difflib import get_close_matches
import logging

log = logging.getLogger('red.buyrole')


class InvalidRole(Exception):
Expand Down Expand Up @@ -213,22 +216,28 @@ async def _process_role(self, server, user, role, paid: bool):
role_list = []
# START LOGIC UNIQUE ROLES
if self.settings_dict[server.id]['roles'][role.id]['uniquegroup'] != 0:
log.debug('Unique role logic:')
# Role is unique
for role_loop, data_loop in self.settings_dict[server.id]['roles'].items():
# About this being easy, fuck loops
if role_loop != role.id and data_loop['uniquegroup'] == role_dict['uniquegroup']:
role_list.append(discord.utils.get(server.roles, id=role_loop))
log.debug(role_list)
# END LOGIC UNIQUE ROLES
if role_dict['price'] != 0 and paid is False:
eco = self.bot.get_cog('Economy').bank
log.debug('Economy required!')
if eco.can_spend(user, role_dict['price']) is True:
eco.withdraw_credits(user, role_dict['price'])
log.debug('Withdrew credits from users')
else:
raise InsufficientBalance('The user has not enough balance')
if role_list is not None:
await self.bot.remove_roles(user, *role_list)
log.debug('Removed roles from role_list')
await asyncio.sleep(0.3)
await self.bot.add_roles(user, discord.utils.get(server.roles, id=role.id))
log.debug('Added role')
return True


Expand Down

0 comments on commit a119b20

Please sign in to comment.