@AkimotoRyou/

vire-bot_py

Python

Clan Private discord bot

fork
loading
Files
  • main.py
  • keep_alive.py
  • requirements.txt
  • stats.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import discord
import os
import time
import asyncio
from keep_alive import keep_alive

client = discord.Client()
messages = joined = 0

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}, Members Joined: {joined}\n")

            messages = 0
            joined = 0

            await asyncio.sleep(5)
        except Exception as e:
            print(e)
            await asyncio.sleep(5)

@client.event
async def on_member_join(member):
    global joined
    joined += 1
    for channel in member.server.channels:
        if str(channel) == "server-log":
            await client.send_message(f"""Welcome to {member.guild.name} {member.mention}""")

@client.event
async def on_message(message):
    global messages
    messages += 1

    id = client.get_guild(message.guild.id)
    channels = ["bot", "bot-general", "admin-commands"]
    author = ["Asterisk*#6944"]
    prefix = ["vb", "<@541413292900352005>"]
    bad_word = ["cok", "fuck", "shit"]

    msgStrt = message.content.lower().split(" ",1)[0]
    command = message.content.lower().split(" ")[1]

    edit = message.content
    for word in bad_words:
        if message.content.lower().count(word) > 0:
            edit.replace(word, "[Censored]")
            await message.delete()
            await message.channel.send(f"""{message.author.name} : {edit}""")

    if str(message.channel) in channels or str(message.author) in author and str(msgStrt) in prefix:
        if command == "help":
            embed = discord.Embed(title="Help on Bot", description="Some useful commands")
            embed.add_field(name="help", value="Show this message.")
            embed.add_field(name="members", value="Print number of members.")
            await message.channel.send(content=None, embed=embed)
        elif command == "members":
            await message.channel.send(f"""# of Members: {id.member_count}""")

keep_alive()
token = os.environ.get("TOKEN")
client.loop.create_task(update_stats())
client.run(token)