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.

83 lines
3.3KB

  1. import datetime
  2. import requests
  3. import load_config
  4. from discord import utils
  5. from discord.ext import commands
  6. from discord.ext.commands import bot
  7. from config.server_config import ServerConfig
  8. def is_gss():
  9. return commands.check(lambda ctx: ctx.guild.id == 393764974444675073)
  10. def is_not_nsfw_disabled():
  11. def predicate(ctx):
  12. role = utils.get(ctx.guild.roles, id=397866388145831937)
  13. return role not in ctx.author.roles
  14. return commands.check(lambda ctx: predicate(ctx))
  15. class GaySoundsShitposting():
  16. def __init__(self, bot_client):
  17. self.bot = bot_client
  18. self.con = ServerConfig()
  19. self.servers = self.con.servers
  20. self.guild = self.bot.get_guild(393764974444675073)
  21. self.nsfw_image_role = utils.get(self.guild.roles, id=394941004043649036)
  22. self.selfie_role = utils.get(self.guild.roles, id=394939389823811584)
  23. def tatsumaki_api_call(self, member):
  24. base = "https://api.tatsumaki.xyz/"
  25. url = base + "guilds/" + str(self.guild.id) + "/members/" + str(member.id) + "/stats"
  26. r = requests.get(url,headers={"Authorization":load_config.tat_token})
  27. return r.json()
  28. @is_gss()
  29. @bot.command(pass_context=True)
  30. async def selfieperms(self, ctx):
  31. """Requests the selfie perm role."""
  32. member = ctx.author
  33. required_score = int(self.servers[self.guild.id]["gss"]["required_score"])
  34. days = int(self.servers[self.guild.id]["gss"]["required_days"])
  35. data = self.tatsumaki_api_call(member)
  36. if self.selfie_role in member.roles:
  37. await member.remove_roles(self.selfie_role, reason="Requested removal of Selfie Perms")
  38. return await ctx.send("You already had {}. It has now been removed.".format(self.selfie_role.name))
  39. time = datetime.datetime.now() - ctx.author.joined_at
  40. if time > datetime.timedelta(days=days) and int(data["score"]) >= required_score:
  41. await member.add_roles(member, self.selfie_role, reason="Requested Selfie perms")
  42. await ctx.send("You have now have the {} role".format(self.selfie_role.name))
  43. else:
  44. return await ctx.send(
  45. "You do not meet the requirements for this role. You need at least {} score with <@!172002275412279296> and to have been in the server for {} days.".format(required_score, days)
  46. )
  47. @is_not_nsfw_disabled()
  48. @is_gss()
  49. @bot.command(pass_context=True)
  50. async def nsfwperms(self, ctx):
  51. """Requests the NSFW Image Perm role."""
  52. member = ctx.author
  53. required_score = int(self.servers[self.guild.id]["gss"]["required_score"])
  54. days = int(self.servers[self.guild.id]["gss"]["required_days"])
  55. data = self.tatsumaki_api_call(member)
  56. if self.nsfw_image_role in member.roles:
  57. await member.remove_roles(self.nsfw_image_role, reason="Requested removal of NSFW Perms")
  58. return await ctx.send("You already had {}. It has now been removed.".format(self.nsfw_image_role.name))
  59. time = datetime.datetime.now() - ctx.author.joined_at
  60. if time > datetime.timedelta(days=days) and int(data["score"]) >= required_score:
  61. await member.add_roles(self.nsfw_image_role, reason="Requested NSFW perms")
  62. await ctx.send("You have now have the {} role".format(self.nsfw_image_role.name))
  63. else:
  64. return await ctx.send(
  65. "You do not meet the requirements for this role. You need at least {} score with <@!172002275412279296> and to have been in the server for {} days.".format(required_score, days)
  66. )
  67. def setup(bot_client):
  68. bot_client.add_cog(GaySoundsShitposting(bot_client))