Rwkregime

Untitled

Jul 20th, 2018
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1.  
  2. import discord, random, json,requests
  3. from discord.ext import commands
  4.  
  5. # create bot instance
  6. bot = commands.Bot(command_prefix='!', description='jeth discord Bot By Juji')
  7. # load file into json and data define
  8. o = json.load(open('jessf.json','r',encoding='utf-8-sig'))
  9. data = [(m['datestamp'],m['content']) for m in o]
  10. # load commands txt
  11.  
  12. # login
  13. @bot.event
  14. async def on_ready():
  15. channel = discord.Object(id=432066274336440330)
  16. print("Logged in as: name={}, id={}".format( bot.user.name, bot.user.id ))
  17. client = discord.Client()
  18.  
  19. @bot.command(pass_context=True)
  20. async def jeth(ctx):
  21. # Chooses a random quote
  22. content = random.choice(data)
  23. msg = "{}".format(content)
  24. await bot.say(msg)
  25.  
  26. async def timedjeth():
  27. await bot.wait_until_ready()
  28. while not bot.is_closed():
  29. await asyncio.sleep(60)
  30.  
  31. bot.timedjeth = bot.loop.create_task(timedjeth())
  32. bot.timedjeth
  33. channel = bot.get_channel(457515801369640971)
  34. content = random.choice(data)
  35. msg = "{}".format(content)
  36. await bot.send(msg)
  37.  
  38.  
  39.  
  40. @bot.command(pass_context=True)
  41. async def jethx(ctx, n: int = 1):
  42. """Chooses a random quote."""
  43. msg = ["{}".format(content) for content in [random.choice(data) for _ in range(0,n)]]
  44. await bot.say('\n'.join(msg))
  45.  
  46. @bot.command(pass_context=True)
  47. async def search(ctx, phrase : str):
  48. # Match data with a search-phrase
  49. results = []
  50. for datestamp, content in data:
  51. if phrase in content: results.append( "{} \n{}\n".format(datestamp, content))
  52. if len(results) > 8: break
  53.  
  54. if len(results) > 0:
  55. msg = "\n\n {}".format( "\n".join(results) )
  56. else:
  57. msg = "` {} jeth Never Said That Before I Gayce`".format(phrase)
  58. await bot.say(msg)
  59.  
  60.  
  61.  
  62. @bot.command(pass_context=True)
  63. async def jethashackscommands(ctx):
  64. # Returns Commands
  65. with open('commands.txt','r',encoding='utf-8-sig') as content_file:
  66. read = content_file.read()
  67. msg = "{}".format(read)
  68. await bot.say(msg)
Advertisement
Add Comment
Please, Sign In to add comment