Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- import time
- import asyncio
- #id = 576935257941475338
- messages = joined = 0
- def read_token():
- with open("token.txt", "r") as f:
- lines = f.readlines()
- return lines[0].strip()
- token = read_token()
- client = discord.Client()
- async def update_stats():
- await client.wait_until_ready()
- global messages, joined
- while not client.is_closed():
- try:
- with open("stats.txt", "a") as f:
- f.write(f"TIME: {int(time.time())}, MESSAGES: {messages}, MEM JOINED: {joined}\n")
- messages = 0
- joined = 0
- await asyncio.sleep(60)
- except Exception as e:
- print(e)
- await asyncio.sleep(60)
- @client.event
- async def on_member_join(member):
- global joined
- joined += 1
- for channel in member.server.channels:
- if str(channel) == "welcome":
- await client.send_message(f"""`Welcome to FS, {member.mention}""")
- @client.event
- async def on_message(message):
- global messages
- messages += 1
- id = client.get_guild(576935257941475338)
- channels = ["bot-spam", "entry-application"]
- if str(message.channel) in channels:
- if message.content.find("db!hello") != -1:
- await message.channel.send("`Hi!`")
- elif message.content == "db!users":
- await message.channel.send(f"""`# of members: {id.member_count}`""")
- elif message.content == "db!logmein":
- role = discord.utils.get(message.guild.roles, name="MEMBER")
- await message.author.add_roles(role)
- await message.channel.send(f"""`You have been logged into the server. Thank you.`""")
- asyncio.sleep(5)
- await message.delete()
- client.loop.create_task(update_stats())
- client.run(token)
Advertisement
Add Comment
Please, Sign In to add comment