You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
4.5KB

  1. import discord
  2. import random
  3. from Roxbot import checks
  4. import requests
  5. from discord.ext.commands import bot
  6. class Fun:
  7. def __init__(self, bot_client):
  8. self.bot = bot_client
  9. @bot.command()
  10. async def roll(self, ctx, die):
  11. """
  12. Rolls a die using ndx format.
  13. Usage:
  14. {command_prefix}roll ndx
  15. Example:
  16. .roll 2d20 # Rolls two D20s
  17. """
  18. dice = 0
  19. if die[0].isdigit():
  20. if die[1].isdigit() or die[0] == 0:
  21. return await ctx.send("I only support multipliers from 1-9")
  22. multiplier = int(die[0])
  23. else:
  24. multiplier = 1
  25. if die[1].lower() != "d" and die[0].lower() != "d":
  26. return await ctx.send("Use the format 'ndx'.")
  27. options = (4, 6, 8, 10, 12, 20, 100)
  28. for option in options:
  29. if die.endswith(str(option)):
  30. dice = option
  31. if dice == 0:
  32. return await ctx.send("You didn't give a die to use.")
  33. rolls = []
  34. if dice == 100:
  35. step = 10
  36. else:
  37. step = 1
  38. total = 0
  39. if multiplier > 1:
  40. for x in range(multiplier):
  41. rolls.append(random.randrange(step, dice+1, step))
  42. for r in rolls:
  43. total += r
  44. return await ctx.send("{} rolled **{}**. Totaling **{}**".format(ctx.message.author.mention, rolls, total))
  45. else:
  46. roll = random.randrange(step, dice + 1, step)
  47. return await ctx.send("{} rolled a **{}**".format(ctx.message.author.mention, roll))
  48. @checks.isnt_anal()
  49. @bot.command()
  50. async def spank(self, ctx, *, user: discord.User = None):
  51. """
  52. Spanks the mentioned user ;)
  53. Usage:
  54. {command_prefix}spank @Roxbot_client#4170
  55. {command_prefix}spank Roxbot_client
  56. """
  57. if not user:
  58. return await ctx.send("You didn't mention someone for me to spank")
  59. return await ctx.send(":peach: :wave: *{} spanks {}*".format(self.bot.user.name, user.name))
  60. @checks.isnt_anal()
  61. @bot.command(aliases=["succ"])
  62. async def suck(self, ctx, *, user: discord.User = None):
  63. """
  64. Sucks the mentioned user ;)
  65. Usage:
  66. {command_prefix}suck @Roxbot_client#4170
  67. {command_prefix}suck Roxbot_client
  68. """
  69. if not user:
  70. return await ctx.send("You didn't mention someone for me to suck")
  71. return await ctx.send(":eggplant: :sweat_drops: :tongue: *{} sucks {}*".format(self.bot.user.name, user.name))
  72. @bot.command()
  73. async def hug(self, ctx, *, user: discord.User = None):
  74. """
  75. Hugs the mentioned user :3
  76. Usage:
  77. {command_prefix}hug @Roxbot_client#4170
  78. {command_prefix}hug Roxbot_client
  79. """
  80. if not user:
  81. return await ctx.send("You didn't mention someone for me to hug")
  82. return await ctx.send(":blush: *{} hugs {}*".format(self.bot.user.name, user.name))
  83. @bot.command(aliases=["wf"])
  84. async def waifurate(self, ctx):
  85. """
  86. Rates the mentioned waifu(s)
  87. Usage:
  88. {command_prefix}waifurate @user#9999
  89. """
  90. mentions = ctx.message.mentions
  91. if not mentions:
  92. return await ctx.send("You didn't mention anyone for me to rate.", delete_after=10)
  93. rating = random.randrange(1, 11)
  94. if rating <= 2:
  95. emoji = ":sob:"
  96. elif rating <= 4:
  97. emoji = ":disappointed:"
  98. elif rating <= 6:
  99. emoji = ":thinking:"
  100. elif rating <= 8:
  101. emoji = ":blush:"
  102. elif rating == 9:
  103. emoji = ":kissing_heart:"
  104. else:
  105. emoji = ":heart_eyes:"
  106. if len(mentions) > 1:
  107. return await ctx.send("Oh poly waifu rating? :smirk: Your combined waifu rating is {}/10. {}".format(rating, emoji))
  108. else:
  109. return await ctx.send("Oh that's your waifu? I rate them a {}/10. {}".format(rating, emoji))
  110. @bot.command(aliases=["cf"])
  111. async def coinflip(self, ctx):
  112. """Flip a coin"""
  113. return await ctx.send("The coin landed on {}!".format(random.choice(["heads", "tails"])))
  114. @bot.command()
  115. async def aesthetics(self, ctx, *convert):
  116. """Converts text to be more a e s t h e t i c s"""
  117. WIDE_MAP = dict((i, i + 0xFEE0) for i in range(0x21, 0x7F))
  118. WIDE_MAP[0x20] = 0x3000
  119. convert = str(' '.join(convert)).translate(WIDE_MAP)
  120. if ctx.guild.id == 393764974444675073:
  121. await self.bot.get_channel(394959819796381697).send("{} used the aesthetics command passing the argument '{}'".format(str(ctx.author), ' '.join(convert)))
  122. return await ctx.send(convert)
  123. @bot.command(aliases=["ft", "frog"])
  124. async def frogtips(self, ctx):
  125. """RETURNS FROG TIPS FOR HOW TO OPERATE YOUR FROG"""
  126. endpoint = "https://frog.tips/api/1/tips/"
  127. croak = requests.get(endpoint)
  128. tip = random.choice(croak.json()["tips"])
  129. embed = discord.Embed(title="Frog Tip #{}".format(tip["number"]), description=tip["tip"], colour=discord.Colour(0x4C943D))
  130. embed.set_author(name="HOW TO OPERATE YOUR FROG")
  131. embed.set_footer(text="https://frog.tips")
  132. return await ctx.send(embed=embed)
  133. def setup(bot_client):
  134. bot_client.add_cog(Fun(bot_client))