diff --git a/disco/bot/command.py b/disco/bot/command.py index b1f4c78..a301360 100644 --- a/disco/bot/command.py +++ b/disco/bot/command.py @@ -3,6 +3,8 @@ import argparse from holster.enum import Enum +from six import integer_types + from disco.bot.parser import ArgumentSet, ArgumentError from disco.util.functional import cached_property @@ -186,7 +188,7 @@ class Command(object): return ctx.msg.client.state.users.select_one(username=uid[0], discriminator=uid[1]) def resolve_channel(ctx, cid): - if isinstance(cid, (int, long)): + if isinstance(cid, integer_types): return ctx.msg.guild.channels.get(cid) else: return ctx.msg.guild.channels.select_one(name=cid) diff --git a/disco/bot/parser.py b/disco/bot/parser.py index e9cabfc..8283fc8 100644 --- a/disco/bot/parser.py +++ b/disco/bot/parser.py @@ -131,6 +131,7 @@ class ArgumentSet(object): value : str The string value to attempt conversion on. """ + exc = None for typ_name in types: typ = self.types.get(typ_name) if not typ: @@ -139,9 +140,10 @@ class ArgumentSet(object): try: return typ(ctx, value) except Exception as e: + exc = e continue - raise e + raise exc def append(self, arg): """ diff --git a/disco/gateway/sharder.py b/disco/gateway/sharder.py index 99e8d1a..8fc9d0a 100644 --- a/disco/gateway/sharder.py +++ b/disco/gateway/sharder.py @@ -6,6 +6,7 @@ import pickle import logging import marshal +from six import integer_types, string_types from six.moves import range from disco.client import Client @@ -83,7 +84,7 @@ class AutoSharder(object): @staticmethod def dumps(data): - if isinstance(data, (basestring, int, long, bool, list, set, dict)): + if isinstance(data, (string_types, integer_types, bool, list, set, dict)): return '\x01' + marshal.dumps(data) elif isinstance(data, object) and data.__class__.__name__ == 'code': return '\x01' + marshal.dumps(data) diff --git a/disco/util/snowflake.py b/disco/util/snowflake.py index a9aeb15..ad453a7 100644 --- a/disco/util/snowflake.py +++ b/disco/util/snowflake.py @@ -26,7 +26,10 @@ def from_datetime(date): def from_timestamp(ts): - return long(ts * 1000.0 - DISCORD_EPOCH) << 22 + if six.PY3: + return int(ts * 1000.0 - DISCORD_EPOCH) << 22 + else: + return long(ts * 1000.0 - DISCORD_EPOCH) << 22 def to_snowflake(i):