Exemplo n.º 1
0
 async def gibxp_assistance(self,
                            ctx,
                            target: Union[discord.Member, discord.User, int,
                                          str] = None,
                            amount: int = 0):
     if not utils.is_staff(ctx.author):
         return
     # Convert target input to discord.Member
     if not target:
         await utils.embed_reply(ctx,
                                 title="💢 Please provide a valid user!")
         return
     if isinstance(target, int):
         target = ctx.guild.get_member(target)
     elif isinstance(target, str):
         target = utils.strip_argument(target)
         target = await utils.get_best_member_match(ctx, target)
     elif isinstance(target, discord.User):
         target = ctx.guild.get_member(target.id)
     elif isinstance(target, discord.Member):
         pass
     else:
         await utils.embed_reply(ctx,
                                 title="💢 That is not a valid user!")
         return
     if not target:
         await utils.embed_reply(ctx,
                                 title="💢 That is not a valid user!")
         return
     # Handle amount
     try:
         amount = int(utils.strip_argument(amount))
     except (
             TypeError,
             ValueError,
     ):
         await utils.embed_reply(ctx,
                                 title="💢 That is not a valid amount!")
         return
     # Actual command
     _, _, assistance_xp = await db.add_user_xp(target.id,
                                                assistance=amount)
     await utils.embed_reply(
         ctx,
         description=(
             f"👌 Gave {amount} assistance XP to <@!{target.id}>!\n"
             if amount >= 0 else
             f"👌 Took {-amount} assistance XP from <@!{target.id}>!\n") +
         f"New assistance XP value: `{assistance_xp}`")
Exemplo n.º 2
0
 async def burrito(self, ctx, target: Union[discord.Member, discord.User, int, str] = None):
     # Convert target input to discord.Member
     if not target:
         target = ctx.author
     if isinstance(target, int):
         target = ctx.guild.get_member(target)
     elif isinstance(target, str):
         target = utils.strip_argument(target)
         target = await utils.get_best_member_match(ctx, target)
     elif isinstance(target, discord.User):
         target = ctx.guild.get_member(target.id)
     elif isinstance(target, discord.Member):
         pass
     else:
         await utils.embed_reply(ctx,
                                 title="💢 That is not a valid user!")
         return
     if not target:
         await utils.embed_reply(ctx,
                                 title="💢 That is not a valid user!")
         return
     # Actual command
     if target.id != ctx.author.id:
         await utils.embed_reply(ctx,
                                 content=f"<@!{target.id}>",
                                 title="🌯 SpaceBurrito!",
                                 description=f"<@!{ctx.author.id}> just delivered you a delicious Space🌌Burrito🌯!\n"
                                             "Eat it before it gets cold!",
                                 thumbnail="https://cdn.discordapp.com/emojis/779465397903949825.png")
     else:
         await utils.embed_reply(ctx,
                                 title="🌯 SpaceBurrito!",
                                 description=f"<@!{ctx.author.id}> doesn't have any friends yet so they bought themselves a delicious Space🌌Burrito🌯!\n"
                                             "Time to eagerly enjoy it in complete silence!",
                                 thumbnail="https://cdn.discordapp.com/emojis/779465397903949825.png")
Exemplo n.º 3
0
 async def cookie(self, ctx, target: Union[discord.Member, discord.User, int, str] = None):
     # Convert target input to discord.Member
     if not target:
         target = ctx.author
     if isinstance(target, int):
         target = ctx.guild.get_member(target)
     elif isinstance(target, str):
         target = utils.strip_argument(target)
         target = await utils.get_best_member_match(ctx, target)
     elif isinstance(target, discord.User):
         target = ctx.guild.get_member(target.id)
     elif isinstance(target, discord.Member):
         pass
     else:
         await utils.embed_reply(ctx,
                                 title="💢 That is not a valid user!")
         return
     if not target:
         await utils.embed_reply(ctx,
                                 title="💢 That is not a valid user!")
         return
     # Actual command
     if target.id != ctx.author.id:
         await utils.embed_reply(ctx,
                                 content=f"<@!{target.id}>",
                                 title="🍪 CyberCookie!",
                                 description=f"<@!{ctx.author.id}> just gave you a delicious Cyber🤖Cookie🍪!\n"
                                             "Eat it before it vaporizes you!",
                                 thumbnail="https://cdn.discordapp.com/emojis/766054797673496596.png")
     else:
         await utils.embed_reply(ctx,
                                 title="🍪 CyberCookie!",
                                 description=f"<@!{ctx.author.id}> doesn't have any friends yet so they treated themselves to a delicious Cyber🤖Cookie🍪!\n"
                                             "Time to eagerly eat it in complete silence!",
                                 thumbnail="https://cdn.discordapp.com/emojis/766054797673496596.png")
Exemplo n.º 4
0
 async def pat(self, ctx, target: Union[discord.Member, discord.User, int, str] = None):
     # Convert target input to discord.Member
     if not target:
         target = ctx.author
     if isinstance(target, int):
         target = ctx.guild.get_member(target)
     elif isinstance(target, str):
         target = utils.strip_argument(target)
         target = await utils.get_best_member_match(ctx, target)
     elif isinstance(target, discord.User):
         target = ctx.guild.get_member(target.id)
     elif isinstance(target, discord.Member):
         pass
     else:
         await utils.embed_reply(ctx,
                                 title="💢 That is not a valid user!")
         return
     if not target:
         await utils.embed_reply(ctx,
                                 title="💢 That is not a valid user!")
         return
     # Actual command
     if target.id != ctx.author.id:
         await utils.embed_reply(ctx,
                                 content=f"<@!{target.id}>",
                                 title="<a:PatPatPat:836341685952184388> \\*PatPat\\*",
                                 description=f"<@!{ctx.author.id}> just delivered you a truckload of heartfelt pats!\n"
                                             "Cheer up pal, you're a wonderful person!",
                                 thumbnail="https://cdn.discordapp.com/emojis/889187488915128421.gif")
     else:
         await utils.embed_reply(ctx,
                                 title="<a:PatPatPat:836341685952184388> \\*PatPat\\*",
                                 description=f"<@!{ctx.author.id}> doesn't have any friends yet so they tried consoling themselves with a few pats!\n"
                                             "Cheer up pal, life gets better!",
                                 thumbnail="https://cdn.discordapp.com/emojis/889190978001465476.gif")
Exemplo n.º 5
0
 async def xp(self,
              ctx,
              target: Union[discord.Member, discord.User, int, str] = None):
     # Convert target input to discord.Member
     if not target:
         target = ctx.author
     if isinstance(target, int):
         target = ctx.guild.get_member(target)
     elif isinstance(target, str):
         target = utils.strip_argument(target)
         target = await utils.get_best_member_match(ctx, target)
     elif isinstance(target, discord.User):
         target = ctx.guild.get_member(target.id)
     elif isinstance(target, discord.Member):
         pass
     else:
         await utils.embed_reply(ctx, title="💢 That is not a valid user!")
         return
     if not target:
         await utils.embed_reply(ctx, title="💢 That is not a valid user!")
         return
     # Actual command
     level_xp, cred_xp, assistance_xp = await db.get_user_xp(target.id)
     await utils.embed_reply(
         ctx,
         title=f"🔥 {target.name}'s XP:",
         fields=[["Level", f"{level_xp}", True],
                 ["Cred", f"{cred_xp}", True],
                 ["Assistance", f"{assistance_xp}", True]],
         thumbnail=target.avatar_url)
Exemplo n.º 6
0
 async def setxp_cred(self,
                      ctx,
                      target: Union[discord.Member, discord.User, int,
                                    str] = None,
                      amount: int = 0):
     if not utils.is_staff(ctx.author):
         return
     # Convert target input to discord.Member
     if not target:
         await utils.embed_reply(ctx,
                                 title="💢 Please provide a valid user!")
         return
     if isinstance(target, int):
         target = ctx.guild.get_member(target)
     elif isinstance(target, str):
         target = utils.strip_argument(target)
         target = await utils.get_best_member_match(ctx, target)
     elif isinstance(target, discord.User):
         target = ctx.guild.get_member(target.id)
     elif isinstance(target, discord.Member):
         pass
     else:
         await utils.embed_reply(ctx,
                                 title="💢 That is not a valid user!")
         return
     if not target:
         await utils.embed_reply(ctx,
                                 title="💢 That is not a valid user!")
         return
     # Handle amount
     try:
         amount = int(utils.strip_argument(amount))
     except (
             TypeError,
             ValueError,
     ):
         await utils.embed_reply(ctx,
                                 title="💢 That is not a valid amount!")
         return
     # Actual command
     _, cred_xp, _ = await db.set_user_xp(target.id, cred=amount)
     await utils.embed_reply(
         ctx,
         description=f"👌 Set <@!{target.id}>'s cred XP successfully!\n"
         f"New cred XP value: `{cred_xp}`")
Exemplo n.º 7
0
 async def rep(self,
               ctx,
               target: Union[discord.Member, discord.User, int,
                             str] = None):
     if not str(ctx.author.id) in rep_cooldown_users:
         # Convert target input to discord.Member
         if not target:
             await utils.embed_reply(
                 ctx,
                 title="💢 Please provide a user to give reputation to!")
             return
         if isinstance(target, int):
             target = ctx.guild.get_member(target)
         elif isinstance(target, str):
             target = utils.strip_argument(target)
             target = await utils.get_best_member_match(ctx, target)
         elif isinstance(target, discord.User):
             target = ctx.guild.get_member(target.id)
         elif isinstance(target, discord.Member):
             pass
         else:
             await utils.embed_reply(ctx,
                                     title="💢 That is not a valid user!")
             return
         if not target:
             await utils.embed_reply(ctx,
                                     title="💢 That is not a valid user!")
             return
         if target.id == ctx.author.id:
             await utils.embed_reply(
                 ctx, title="💢 Thats low even by your standards...")
             return
         # Actual command
         await db.add_user_xp(target.id, cred=globals.REP_CRED_AMOUNT)
         rep_cooldown_users.add(str(ctx.author.id))
         await utils.embed_reply(
             ctx,
             content=f"<@!{target.id}>",
             title="💌 You got some reputation!",
             description=
             f"<@!{ctx.author.id}> likes what you do and showed their gratitude by gifting you **{globals.REP_CRED_AMOUNT} server cred XP**!",
             thumbnail=globals.REP_ICON)
     else:
         await utils.embed_reply(
             ctx,
             title="💢 You're on cooldown!",
             description=
             "You can only use that command once every **24 hours**!\n"
             f"You'll be able to use it again in roughly **{utils.time_to_restart()}**"
         )
Exemplo n.º 8
0
 async def help(self, ctx, subcommand=None):
     prfx = globals.BOT_PREFIX.lower()
     if subcommand:
         subcommand = utils.strip_argument(subcommand)
     if subcommand and subcommand.lower().startswith(prfx):
         subcommand = subcommand[len(prfx):]
     if subcommand:
         subcommand = subcommand.lower()
         for cog_name in globals.bot.cogs:
             if cog_name.lower() == "jishaku":
                 continue
             if cog_name.lower() == subcommand:
                 cog = globals.bot.get_cog(cog_name)
                 desc = ""
                 if "staff" in cog_name.lower() and not utils.is_staff(
                         ctx.author):
                     desc += "These are **staff only** commands, you can't use them!\n\n"
                 desc += cog.description + "\n\n"
                 for command in sorted(cog.get_commands(),
                                       key=lambda x: x.name):
                     desc += f'{prfx}**{command.name}**: ' + (
                         command.description[:command.description.
                                             find("\n")] if "\n" in command.
                         description else command.description) + '\n'
                 desc += f"\nYou can use `{prfx}help [ command ]` to see more info about it!\n"
                 desc += f"**\nA.L.T.I.E.R.A. Bot**{(' `' + os.environ.get('HEROKU_RELEASE_VERSION') + '`') if os.environ.get('HEROKU_RELEASE_VERSION') else ''}, made with ❤️ by [WillyJL](https://linktr.ee/WillyJL)"
                 await utils.embed_reply(
                     ctx,
                     title=f"⁉️   A.L.T.I.E.R.A. Help  >  {cog_name}",
                     description=desc)
                 return
         for command in globals.bot.commands:
             cog_name = command.cog.qualified_name
             if cog_name.lower() == "jishaku":
                 continue
             aliases = [alias.lower() for alias in command.aliases]
             if command.name.lower() == subcommand or subcommand in aliases:
                 desc = ""
                 if "staff" in cog_name.lower() and not utils.is_staff(
                         ctx.author):
                     desc += "This is a **staff only** command, you can't use it!\n\n"
                 desc += command.description + "\n\n"
                 desc += "**Usage**: `" + command.usage.format(
                     prfx=prfx) + "`\n"
                 if command.help:
                     desc += command.help + "\n"
                 if aliases:
                     desc += f"\n**Aliases**: `{prfx}" + f"`, `{prfx}".join(
                         aliases) + "`\n"
                 desc += f"**\nA.L.T.I.E.R.A. Bot**{(' `' + os.environ.get('HEROKU_RELEASE_VERSION') + '`') if os.environ.get('HEROKU_RELEASE_VERSION') else ''}, made with ❤️ by [WillyJL](https://linktr.ee/WillyJL)"
                 await utils.embed_reply(
                     ctx,
                     title=
                     f"⁉️   A.L.T.I.E.R.A. Help  >  {cog_name}  >  {prfx}{command.name}",
                     description=desc)
                 return
     desc = "You can use these commands to see a category of commands:\n\n"
     for cog_name in sorted(list(globals.bot.cogs)):
         if cog_name.lower() == "jishaku":
             continue
         if "staff" in cog_name.lower() and not utils.is_staff(ctx.author):
             continue
         cog = globals.bot.get_cog(cog_name)
         desc += f"{prfx}help **{cog_name.lower()}**: " + (
             cog.description[:cog.description.find('\n')]
             if '\n' in cog.description else cog.description) + "\n"
     desc += f"\nYou can use `{prfx}help [ command ]` to see more info about it!\n"
     desc += f"\n**A.L.T.I.E.R.A. Bot**{(' `' + os.environ.get('HEROKU_RELEASE_VERSION') + '`') if os.environ.get('HEROKU_RELEASE_VERSION') else ''}, made with ❤️ by [WillyJL](https://linktr.ee/WillyJL)"
     await utils.embed_reply(ctx,
                             title="⁉️   A.L.T.I.E.R.A. Help",
                             description=desc)
     return
Exemplo n.º 9
0
 async def dice(self,
                ctx,
                arg1: str = None,
                arg2: str = None,
                arg3: str = None):
     # Arg1
     if arg1 is not None:
         try:
             max = int(utils.strip_argument(arg1))
         except (
                 ValueError,
                 TypeError,
         ):
             await utils.embed_reply(
                 ctx, title="💢 Please provide a valid number!")
             return
     else:
         max = 6
     # Arg2
     if arg2 is not None:
         throws = max
         try:
             max = int(utils.strip_argument(arg2))
         except (
                 ValueError,
                 TypeError,
         ):
             await utils.embed_reply(
                 ctx, title="💢 Please provide valid numbers!")
             return
     else:
         throws = 1
     # Arg3
     if arg3 is not None:
         try:
             mod = int(utils.strip_argument(arg3))
         except (
                 ValueError,
                 TypeError,
         ):
             await utils.embed_reply(
                 ctx, title="💢 Please provide valid numbers!")
             return
     else:
         mod = 0
     # Adjustments
     throws_adjusted = False
     max_adjusted = False
     mod_adjusted = False
     if throws > 10:
         throws = 10
         throws_adjusted = True
     if throws < 1:
         throws = 1
         throws_adjusted = True
     if max > 100:
         max = 100
         max_adjusted = True
     if max < 2:
         max = 2
         max_adjusted = True
     if mod > 100:
         mod = 100
         mod_adjusted = True
     if mod < -100:
         mod = -100
         mod_adjusted = True
     # Actual command
     result = 0
     rolls = []
     for _ in range(throws):
         roll = random.randint(1, max)
         result += roll
         rolls.append(str(roll))
     result += mod
     await utils.embed_reply(
         ctx,
         title="🎲 Dice roll!",
         description=
         f'Throws: {throws}{" (adjusted)" if throws_adjusted else ""}\n'
         f'Max: {max}{" (adjusted)" if max_adjusted else ""}\n'
         f'Modifier: {mod:+}{" (adjusted)" if mod_adjusted else ""}\n'
         '\n'
         f'Result:  __**{str(result)}**__ ( `{", ".join(rolls)}{f", {mod:+}" if mod != 0 else ""}` )',
         add_timestamp=False)
Exemplo n.º 10
0
 async def stats(self,
                 ctx,
                 target: Union[discord.Member, discord.User, int,
                               str] = None):
     # Convert target input to discord.Member
     if not target:
         target = ctx.author
     if isinstance(target, int):
         target = ctx.guild.get_member(target)
     elif isinstance(target, str):
         target = utils.strip_argument(target)
         target = await utils.get_best_member_match(ctx, target)
     elif isinstance(target, discord.User):
         target = ctx.guild.get_member(target.id)
     elif isinstance(target, discord.Member):
         pass
     else:
         await utils.embed_reply(ctx, title="💢 That is not a valid user!")
         return
     if not target:
         await utils.embed_reply(ctx, title="💢 That is not a valid user!")
         return
     # Actual command
     level_xp, cred_xp, assistance_xp = await db.get_user_xp(target.id)
     level = xp.xp_to_lvl(level_xp)
     cred = xp.xp_to_lvl(cred_xp)
     assistance = xp.xp_to_lvl(assistance_xp)
     level_next = math.floor((level[2] - level[1]) * 100 / level[2])
     cred_next = math.floor((cred[2] - cred[1]) * 100 / cred[2])
     assistance_next = math.floor(
         (assistance[2] - assistance[1]) * 100 / assistance[2])
     # Setup image foundation
     if target.id == globals.ADMIN_ID:
         img = Image.open("assets/backgrounds/admin.png")
     elif utils.is_staff(target):
         img = Image.open("assets/backgrounds/staff.png")
     else:
         img = Image.open("assets/backgrounds/default.png")
     draw = ImageDraw.Draw(img)
     # Draw user avatar
     if str(target.avatar_url).startswith(
             "https://cdn.discordapp.com/embed/avatars"):
         avatar = globals.default_avatar
     else:
         avatar = (await
                   utils.pil_img_from_link(str(target.avatar_url))).resize((
                       200,
                       200,
                   ))
     try:
         img.paste(avatar, (
             24,
             18,
         ), avatar)
     except ValueError:
         img.paste(avatar, (
             24,
             18,
         ))
     # Apply base overlay
     if target.id == globals.ADMIN_ID:
         img.paste(globals.overlays_admin, (
             0,
             0,
         ), globals.overlays_admin)
     elif utils.is_staff(target):
         img.paste(globals.overlays_staff, (
             0,
             0,
         ), globals.overlays_staff)
     else:
         img.paste(globals.overlays_default, (
             0,
             0,
         ), globals.overlays_default)
     # Draw username
     username = target.name.encode('ascii', 'replace').decode(
         'ascii')  # Remove non-ascii glyphs
     utils.draw_text(draw, globals.font35, username, "#FFFFFF", (
         268,
         85,
     ), 298)
     # Draw main level and cred values
     utils.draw_text(draw, globals.font47, f"LV:{level[0]}", "#009EDF", (
         277,
         141,
     ), 999)
     if target.id == globals.ADMIN_ID:
         utils.draw_text(draw, globals.font47, f"SC:{cred[0]}", "#16F2D6", (
             434,
             141,
         ), 999)
     else:
         utils.draw_text(draw, globals.font47, f"SC:{cred[0]}", "#F06B02", (
             434,
             141,
         ), 999)
     # Draw trophy shards
     x = 267
     for i in range(utils.get_trophy_amount(target)):
         if i % 2:
             img.paste(globals.shards_white, (
                 x,
                 194,
             ), globals.shards_white)
         else:
             if target.id == globals.ADMIN_ID:
                 img.paste(globals.shards_teal, (
                     x,
                     194,
                 ), globals.shards_teal)
             else:
                 img.paste(globals.shards_orange, (
                     x,
                     194,
                 ), globals.shards_orange)
         x += 24
     # Draw single level values
     if target.id == globals.ADMIN_ID:
         utils.draw_text(draw, globals.font16, "LVL:", "#090D18", (
             275,
             425,
         ), 999)
         utils.draw_text(draw, globals.font24, f"{level[0]}", "#090D18", (
             308,
             423,
         ), 999)
     else:
         utils.draw_text(draw, globals.font16, "LVL:", "#FFFFFF", (
             275,
             425,
         ), 999)
         utils.draw_text(draw, globals.font24, f"{level[0]}", "#FFFFFF", (
             308,
             423,
         ), 999)
     utils.draw_text(draw, globals.font16, "LVL:", "#FFFFFF", (
         275,
         518,
     ), 999)
     utils.draw_text(draw, globals.font24, f"{cred[0]}", "#FFFFFF", (
         308,
         516,
     ), 999)
     if target.id == globals.ADMIN_ID:
         utils.draw_text(draw, globals.font16, "LVL:", "#009EDF", (
             275,
             619,
         ), 999)
         utils.draw_text(draw, globals.font24, f"{assistance[0]}",
                         "#009EDF", (
                             308,
                             617,
                         ), 999)
     else:
         utils.draw_text(draw, globals.font16, "LVL:", "#F06B02", (
             275,
             619,
         ), 999)
         utils.draw_text(draw, globals.font24, f"{assistance[0]}",
                         "#F06B02", (
                             308,
                             617,
                         ), 999)
     # Draw single percentage values
     if level_next >= 100:
         utils.draw_text(draw, globals.font30, "MAX", "#090D18", (
             579 - globals.font30.getsize("MAX")[0],
             398,
         ), 999)
     else:
         utils.draw_text(draw, globals.font30, f"{level_next}", "#090D18", (
             565 - globals.font30.getsize(f"{level_next}")[0],
             398,
         ), 999)
         utils.draw_text(draw, globals.font20, "%", "#090D18", (
             565,
             407,
         ), 999)
     if cred_next >= 100:
         utils.draw_text(draw, globals.font30, "MAX", "#090D18", (
             579 - globals.font30.getsize("MAX")[0],
             491,
         ), 999)
     else:
         utils.draw_text(draw, globals.font30, f"{cred_next}", "#090D18", (
             565 - globals.font30.getsize(f"{cred_next}")[0],
             491,
         ), 999)
         utils.draw_text(draw, globals.font20, "%", "#090D18", (
             565,
             500,
         ), 999)
     if assistance_next >= 100:
         utils.draw_text(draw, globals.font30, "MAX", "#090D18", (
             579 - globals.font30.getsize("MAX")[0],
             593,
         ), 999)
     else:
         utils.draw_text(
             draw, globals.font30, f"{assistance_next}", "#090D18", (
                 565 - globals.font30.getsize(f"{assistance_next}")[0],
                 593,
             ), 999)
         utils.draw_text(draw, globals.font20, "%", "#090D18", (
             565,
             602,
         ), 999)
     # Overlay percentage bars
     if target.id == globals.ADMIN_ID:
         level_bar = globals.bars["teal_white"][
             utils.get_bar_index_from_lvl_percent(level_next)]
         cred_bar = globals.bars["blue_white"][
             utils.get_bar_index_from_lvl_percent(cred_next)]
         assistance_bar = globals.bars["white_blue"][
             utils.get_bar_index_from_lvl_percent(assistance_next)]
     else:
         level_bar = globals.bars["blue_white"][
             utils.get_bar_index_from_lvl_percent(level_next)]
         cred_bar = globals.bars["orange_white"][
             utils.get_bar_index_from_lvl_percent(cred_next)]
         assistance_bar = globals.bars["white_orange"][
             utils.get_bar_index_from_lvl_percent(assistance_next)]
     img.paste(level_bar, (
         218,
         457,
     ), level_bar)
     img.paste(cred_bar, (
         218,
         550,
     ), cred_bar)
     img.paste(assistance_bar, (
         218,
         650,
     ), assistance_bar)
     # Send the image
     binary = io.BytesIO()
     img.save(binary, format="PNG")
     binary.seek(0)
     await ctx.reply(
         file=discord.File(binary, filename=username[:16] + ".png"))