Skip to content

Commit

Permalink
extras: add block to storage conversion command (#1220)
Browse files Browse the repository at this point in the history
  • Loading branch information
lifehackerhansol authored Aug 7, 2023
1 parent 0c2a2df commit c647557
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cogs/extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,18 @@ async def close_thread(self, ctx: GuildContext):
await ctx.send("Thread has been marked as solved.")
await ctx.channel.edit(archived=True, locked=True)

@commands.command()
async def blockconvert(self, ctx, blocks: int):
"""Converts Nintendo Blocks to normal storage units. 1 block == 128 KiB"""
kibibytes = blocks << 7 # 1 block == 128 KiB
ret = f"{kibibytes} KiB"
if kibibytes > 1048576: # over 1 GiB
ret = f"{kibibytes >> 20} GiB"
elif kibibytes > 1024: # over 1 MiB
ret = f"{kibibytes >> 10} MiB"

await ctx.send(f"{blocks} blocks is equivalent to {ret}.")


async def setup(bot):
await bot.add_cog(Extras(bot))

0 comments on commit c647557

Please sign in to comment.