mirror of
https://github.com/Ryujinx/ryuko-ng.git
synced 2025-01-03 20:15:28 +00:00
fix 2 bugs
This commit is contained in:
parent
f9ad10b285
commit
8db1d66996
|
@ -70,7 +70,7 @@ async def on_ready():
|
||||||
log.info(f'\nLogged in as: {bot.user.name} - '
|
log.info(f'\nLogged in as: {bot.user.name} - '
|
||||||
f'{bot.user.id}\ndpy version: {discord.__version__}\n')
|
f'{bot.user.id}\ndpy version: {discord.__version__}\n')
|
||||||
game_name = f"{config['base']['prefix']}help"
|
game_name = f"{config['base']['prefix']}help"
|
||||||
await bot.change_presence(game=discord.Game(name=game_name))
|
await bot.change_presence(activity=discord.Game(name=game_name))
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
|
|
|
@ -18,39 +18,38 @@ class Common:
|
||||||
self.bot.aiogetbytes = self.aiogetbytes
|
self.bot.aiogetbytes = self.aiogetbytes
|
||||||
self.bot.get_relative_timestamp = self.get_relative_timestamp
|
self.bot.get_relative_timestamp = self.get_relative_timestamp
|
||||||
|
|
||||||
|
def get_relative_timestamp(self, time_from=None, time_to=None,
|
||||||
def get_relative_timestamp(self, time_from=None, time_to=None,
|
humanized=False, include_from=False,
|
||||||
humanized=False, include_from=False,
|
include_to=False):
|
||||||
include_to=False):
|
# Setting default value to utcnow() makes it show time from cog load
|
||||||
# Setting default value to utcnow() makes it show time from cog load
|
# which is not what we want
|
||||||
# which is not what we want
|
if not time_from:
|
||||||
if not time_from:
|
time_from = datetime.datetime.utcnow()
|
||||||
time_from = datetime.datetime.utcnow()
|
if not time_to:
|
||||||
if not time_to:
|
time_to = datetime.datetime.utcnow()
|
||||||
time_to = datetime.datetime.utcnow()
|
if humanized:
|
||||||
if humanized:
|
humanized_string = humanize.naturaltime(time_to - time_from)
|
||||||
humanized_string = humanize.naturaltime(time_to - time_from)
|
if include_from and include_to:
|
||||||
if include_from and include_to:
|
str_with_from_and_to = f"{humanized_string} "\
|
||||||
str_with_from_and_to = f"{humanized_string} "\
|
f"({str(time_from).split('.')[0]} "\
|
||||||
f"({str(time_from).split('.')[0]} "\
|
f"- {str(time_to).split('.')[0]})"
|
||||||
f"- {str(time_to).split('.')[0]})"
|
return str_with_from_and_to
|
||||||
return str_with_from_and_to
|
elif include_from:
|
||||||
elif include_from:
|
str_with_from = f"{humanized_string} "\
|
||||||
str_with_from = f"{humanized_string} "\
|
f"({str(time_from).split('.')[0]})"
|
||||||
f"({str(time_from).split('.')[0]})"
|
return str_with_from
|
||||||
return str_with_from
|
elif include_to:
|
||||||
elif include_to:
|
str_with_to = f"{humanized_string} ({str(time_to).split('.')[0]})"
|
||||||
str_with_to = f"{humanized_string} ({str(time_to).split('.')[0]})"
|
return str_with_to
|
||||||
return str_with_to
|
return humanized_string
|
||||||
return humanized_string
|
else:
|
||||||
else:
|
epoch = datetime.datetime.utcfromtimestamp(0)
|
||||||
epoch = datetime.datetime.utcfromtimestamp(0)
|
epoch_from = (time_from - epoch).total_seconds()
|
||||||
epoch_from = (time_from - epoch).total_seconds()
|
epoch_to = (time_to - epoch).total_seconds()
|
||||||
epoch_to = (time_to - epoch).total_seconds()
|
second_diff = epoch_to - epoch_from
|
||||||
second_diff = epoch_to - epoch_from
|
result_string = str(datetime.timedelta(
|
||||||
result_string = str(datetime.timedelta(
|
seconds=second_diff)).split('.')[0]
|
||||||
seconds=second_diff)).split('.')[0]
|
return result_string
|
||||||
return result_string
|
|
||||||
|
|
||||||
async def aioget(self, url):
|
async def aioget(self, url):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue