Advertisement
TheInfiniteCode

Untitled

May 11th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.46 KB | None | 0 0
  1. import discord, asyncio
  2. from discord.ext import commands
  3. import time, os
  4. from api import footer
  5. from config import config
  6. #from logger import log
  7. import asyncio
  8. import StormBotAPI
  9.  
  10.  
  11. # https://discordpy.readthedocs.io/en/v0.16.12/api.htmls
  12.  
  13. prefix = config["prefix"]
  14. client = commands.Bot(command_prefix=prefix)
  15. client.remove_command("help")
  16.  
  17. @client.event
  18. async def on_ready():
  19. print("A renszer elindult!")
  20. counter = 0
  21. while not counter > 0:
  22. await client.change_presence(game=discord.Game(name=f"{len(client.servers)} szerveren | {prefix}help"))
  23. await asyncio.sleep(10)
  24.  
  25. modules = ["help", "clear", "ban", "noswear", "mute", "fun", "clientwc", "skin", "skull", "info", "fortnite", "music"]
  26. #modules = ["broadcast"]
  27.  
  28. dev = config["dev"]
  29. notdev = config["notdev"]
  30.  
  31. @client.command(pass_context = True)
  32. async def teszt(ctx):
  33. await client.say("<a:loading:485457384999747585> naon menő bot XD")
  34.  
  35.  
  36. @client.command(pass_context=True)
  37. async def load(ctx, module:str=None):
  38. if not ctx.message.author.id == dev:
  39. embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(), description = notdev)
  40. embed.set_footer(text=footer())
  41. return await client.say(embed=embed)
  42. if module == None:
  43. embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(), description = f"Használat: {prefix}load [modul]")
  44. embed.set_footer(text=footer())
  45. return await client.say(embed=embed)
  46. try:
  47. client.load_extension(module)
  48. embed = discord.Embed(title = "Sikeres konfigurálás!", colour = discord.Colour.green(), description = f"A(z) `{module}` modul be lett töltve!")
  49. embed.set_footer(text=footer())
  50. return await client.say(embed=embed)
  51. except Exception as error:
  52. embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(),description = f"Nem sikerült betölteni a(z) `{module}` modult!")
  53. embed.add_field(name = "Hibaüzenet", value = error, inline = False)
  54. embed.set_footer(text=footer())
  55. return await client.say(embed=embed)
  56.  
  57. @client.command(pass_context=True)
  58. async def unload(ctx, module:str=None):
  59. if not ctx.message.author.id == dev:
  60. embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(), description = notdev)
  61. embed.set_footer(text=footer())
  62. return await client.say(embed=embed)
  63. if module == None:
  64. embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(), description = f"Használat: {prefix}unload [modul]")
  65. embed.set_footer(text=footer())
  66. return await client.say(embed=embed)
  67. try:
  68. client.unload_extension(module)
  69. embed = discord.Embed(title = "Sikeres konfigurálás!", colour = discord.Colour.green(), description = f"A(z) `{module}` modul le lett tiltva!")
  70. embed.set_footer(text=footer())
  71. return await client.say(embed=embed)
  72. except Exception as error:
  73. embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(),description = f"Nem sikerült letiltani a(z) `{module}` modult!")
  74. embed.add_field(name = "Hibaüzenet", value = error, inline = False)
  75. embed.set_footer(text=footer())
  76. return await client.say(embed=embed)
  77.  
  78. @client.command(pass_context=True, aliases = ["rl"])
  79. async def reload(ctx, module:str=None):
  80. if not ctx.message.author.id == dev:
  81. embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(), description = notdev)
  82. embed.set_footer(text=footer())
  83. return await client.say(embed=embed)
  84. if module == None:
  85. embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(), description = f"Használat: {prefix}reload [modul]")
  86. embed.set_footer(text=footer())
  87. return await client.say(embed=embed)
  88. try:
  89. client.unload_extension(module)
  90. client.load_extension(module)
  91. embed = discord.Embed(title = "Sikeres konfigurálás!", colour = discord.Colour.green(), description = f"A(z) `{module}` modul sikeresen újratöltve!")
  92. embed.set_footer(text=footer())
  93. return await client.say(embed=embed)
  94. except Exception as error:
  95. embed = discord.Embed(title = "Hiba!", colour = discord.Colour.red(),description = f"Nem sikerült újratölteni a(z) `{module}` module!")
  96. embed.add_field(name = "Hibaüzenet", value = error, inline = False)
  97. embed.set_footer(text=footer())
  98. return await client.say(embed=embed)
  99.  
  100. async def get_uptime():
  101. await client.wait_until_ready()
  102. global seconds
  103. seconds = 0
  104. global minutes
  105. minutes = 0
  106. global hours
  107. hours = 0
  108. global days
  109. days = 0
  110. global weeks
  111. weeks = 0
  112. while not client.is_closed:
  113. await asyncio.sleep(1)
  114. seconds += 1
  115. if seconds==60:
  116. minutes += 1
  117. seconds = 0
  118. if minutes==60:
  119. hours += 1
  120. minutes = 0
  121. if hours==24:
  122. days += 1
  123. hours = 0
  124. if days==7:
  125. weeks += 1
  126. days = 0
  127.  
  128. client.loop.create_task(get_uptime())
  129.  
  130. @client.command(pass_context = True)
  131. async def uptime():
  132. msg = "{0} hét, {1} nap, {2} óra, {3} perc és {4} másodperc".format(weeks, days, hours, minutes, seconds)
  133. embed = discord.Embed(title="Ennyi ideje fut a bot", description=msg, colour = discord.Colour.blue())
  134. await client.say(embed=embed)
  135.  
  136. if __name__ == '__main__':
  137. for _module in modules:
  138. try:
  139. client.load_extension(_module)
  140. print("» Sikeresen betöltődött a(z) '{}' modul!".format(_module))
  141. except Exception as error:
  142. print("=========================")
  143. print("» Nem sikerült betölteni a(z) '{}' modult!".format(_module))
  144. print("Hibaüzenet: \n{}".format(error))
  145. print("=========================")
  146. with open("token.txt", "r") as f:
  147. client.run(f.read())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement