R_Milligan3

Sunday_Afternoon

Aug 29th, 2021
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. 1 #!/usr/bin/python3.9$
  2. 2 import discord$
  3. 3 from discord.ext import commands$
  4. 4 import os$
  5. 5 import json$
  6. 6 import time$
  7. 7 import asyncio$
  8. 8 import requests$
  9. 9 $
  10. 10 client=commands.Bot(command_prefix='!')$
  11. 11 messages=joined=0$
  12. 12 $
  13. 13 async def update_stats():$
  14. 14 await client.wait_until_ready()$
  15. 15 global messages,joined$
  16. 16 while not client.is_closed():$
  17. 17 try:$
  18. 18 with open('stats.txt','a')as f:$
  19. 19 f.write(f"Time: {int(time.time())} Messages: {messages} Number Joined: {joined}\n")$
  20. 20 messages=0$
  21. 21 joined=0$
  22. 22 await asyncio.sleep(5)$
  23. 23 except Exception as e:$
  24. 24 print(e)$
  25. 25 await asyncio.sleep(5)$
  26. 26 $
  27. 27 @client.event$
  28. 28 async def on_member_join(member):$
  29. 29 global joined$
  30. 30 joined +=1$
  31. 31 for channel in member.server.channels:$
  32. 32 if str(channel)=='recipes':$
  33. 33 await client.send_message(f"Welcome to the Server: {member.mention}")$
  34. 34 $
  35. 35 def get_quote():$
  36. 36 response=requests.get('https://zenquotes.io/api/random')$
  37. 37 json_data=json.loads(response.text)$
  38. 38 quote=json_data[0]['q']+ ' -'+json_data[0]['a']$
  39. 39 return quote$
  40. 40 $
  41. 41 $
  42. 42 @client.event$
  43. 43 async def on_message(message):$
  44. 44 global messages$
  45. 45 messages +=1$
  46. 46 id=client.get_guild(874976028479619113)$
  47. 47 channels=['recipes','testers','general']$
  48. 48 valid_users=['M_Roberts#3646']$
  49. 49 $
  50. 50 bad_words=['fox','chicken','turnip']$
  51. 51 for word in bad_words:$
  52. 52 if message.content.count(word)>0:$
  53. 53 await message.channel.purge(limit=1)$
  54. 54 $
  55. 55 if message.content=='$Ceck':$
  56. 56 embed=discord.Embed(type='Command Types',description='Useful Commands')$
  57. 57 embed.add_field(name='Hello',value='Greets the User')$
  58. 58 embed.add_field(name='users',value='Number on Server')$
  59. 59 await message.channel.send(embed=embed)$
  60. 60 $
  61. 61 if str(message.channel)in channels and str(message.author)in valid_users:$
  62. 62 if message.content.find('Hello')!=-1:$
  63. 63 await message.channel.send(f"Hi there {message.author}")$
  64. 64 elif message.content=='users':$
  65. 65 await message.channel.send(f"Number on Server: {id.member_count}")$
  66. 66 elif message.content.startswith('$Inspire'):$
  67. 67 quote=get_quote()$
  68. 68 await message.channel.send(quote)$
  69. 69 else:$
  70. 70 print(f"Member {message.author} tried to message {message.content} in Channel: {message.channel}")$
  71. 71 $
  72. 72 @client.command()$
  73. 73 async def load(ctx,extension):$
  74. 74 client.load_extension(f"Cogs.{extension}")$
  75. 75 $
  76. 76 @client.command()$
  77. 77 async def unload(ctx,extension):$
  78. 78 client.unload_extension(f"Cogs.{extension}")$
  79. 79 $
  80. 80 for filename in os.listdir('./Cogs'):$
  81. 81 if filename.endswith('.py'):$
  82. 82 client.load_extension(f"Cogs.{filename[:-3]}")$
  83. 83 $
  84. 84 client.loop.create_task(update_stats())
  85. client.run('My API_Key')
  86.  
  87.  
  88.  
Advertisement
Add Comment
Please, Sign In to add comment