diff --git a/disco/types/channel.py b/disco/types/channel.py index a54b4bf..7636047 100644 --- a/disco/types/channel.py +++ b/disco/types/channel.py @@ -3,7 +3,7 @@ from holster.enum import Enum from disco.types.base import Model, Field, snowflake, enum, listof, dictof, text from disco.types.permissions import PermissionValue -from disco.util import to_snowflake +from disco.util.snowflake import to_snowflake from disco.util.functional import cached_property, one_or_many, chunks from disco.types.user import User from disco.types.permissions import Permissions, Permissible diff --git a/disco/types/guild.py b/disco/types/guild.py index 9e38582..70ff577 100644 --- a/disco/types/guild.py +++ b/disco/types/guild.py @@ -1,7 +1,7 @@ from holster.enum import Enum from disco.api.http import APIException -from disco.util import to_snowflake +from disco.util.snowflake import to_snowflake from disco.util.functional import cached_property from disco.types.base import Model, Field, snowflake, listof, dictof, datetime, text, binary, enum from disco.types.user import User diff --git a/disco/types/message.py b/disco/types/message.py index ba88328..52e2bb6 100644 --- a/disco/types/message.py +++ b/disco/types/message.py @@ -3,7 +3,7 @@ import re from holster.enum import Enum from disco.types.base import Model, Field, snowflake, text, datetime, dictof, listof, enum -from disco.util import to_snowflake +from disco.util.snowflake import to_snowflake from disco.util.functional import cached_property from disco.types.user import User diff --git a/disco/util/__init__.py b/disco/util/__init__.py index 2a0f667..e69de29 100644 --- a/disco/util/__init__.py +++ b/disco/util/__init__.py @@ -1,12 +0,0 @@ -import six - - -def to_snowflake(i): - if isinstance(i, six.integer_types): - return i - elif isinstance(i, str): - return int(i) - elif hasattr(i, 'id'): - return i.id - - raise Exception('{} ({}) is not convertable to a snowflake'.format(type(i), i)) diff --git a/disco/util/snowflake.py b/disco/util/snowflake.py index bbca39d..e642aa6 100644 --- a/disco/util/snowflake.py +++ b/disco/util/snowflake.py @@ -1,3 +1,5 @@ +import six + from datetime import datetime DISCORD_EPOCH = 1420070400000 @@ -16,3 +18,14 @@ def to_unix(snowflake): def to_unix_ms(snowflake): return ((int(snowflake) >> 22) + DISCORD_EPOCH) + + +def to_snowflake(i): + if isinstance(i, six.integer_types): + return i + elif isinstance(i, str): + return int(i) + elif hasattr(i, 'id'): + return i.id + + raise Exception('{} ({}) is not convertable to a snowflake'.format(type(i), i))