Browse Source

Couple of fixes

pull/11/head
andrei 9 years ago
parent
commit
9330d4a8dd
  1. 2
      disco/bot/bot.py
  2. 9
      disco/types/base.py
  3. 2
      disco/types/user.py

2
disco/bot/bot.py

@ -431,6 +431,8 @@ class Bot(object):
for entry in map(lambda i: getattr(mod, i), dir(mod)):
if inspect.isclass(entry) and issubclass(entry, Plugin) and not entry == Plugin:
if getattr(entry, '_shallow', False) and Plugin in entry.__bases__:
continue
loaded = True
self.add_plugin(entry, config)

9
disco/types/base.py

@ -142,11 +142,14 @@ def enum(typ):
return _f
# TODO: make lazy
def lazy_datetime(data):
if not data:
return property(lambda: None)
return None
if isinstance(data, int):
return real_datetime.utcfromtimestamp(data)
def get():
for fmt in DATETIME_FORMATS:
try:
return real_datetime.strptime(data.rsplit('+', 1)[0], fmt)
@ -154,8 +157,6 @@ def lazy_datetime(data):
continue
raise ValueError('Failed to conver `{}` to datetime'.format(data))
return property(get)
def datetime(data):
if not data:

2
disco/types/user.py

@ -8,7 +8,7 @@ class User(SlottedModel, with_equality('id'), with_hash('id')):
username = Field(text)
avatar = Field(binary)
discriminator = Field(str)
bot = Field(bool)
bot = Field(bool, default=False)
verified = Field(bool)
email = Field(str)

Loading…
Cancel
Save