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