-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
56 lines (44 loc) · 1.48 KB
/
bot.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
import asyncio
import os
from itertools import cycle
import time
import discord
from discord.ext import commands
from dotenv import load_dotenv
intents = discord.Intents.all()
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')
bot = commands.Bot(command_prefix=["/", "<@!994664955305533602> ",
"<@994664955305533602> "], case_insensitive=True, intents=intents,
owner_ids=[773902563476897812])
@bot.event
async def on_ready():
print("Bot is ready")
guild = bot.get_guild(GUILD)
print(guild.members)
mem = len(guild.members)
statuses = cycle([f"{mem} Members!", "h!help"])
while not bot.is_closed():
status = next(statuses)
activity = discord.Activity(
type=discord.ActivityType.watching, name=status)
await bot.change_presence(status=discord.Status.dnd, activity=activity)
await asyncio.sleep(20)
bot.remove_command("help")
bot.start_time = int(time.time())
async def load_extensions():
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
try:
await bot.load_extension(f"cogs.{filename[:-3]}")
print(f"Loaded {filename}")
except commands.ExtensionAlreadyLoaded:
pass
except Exception as e:
print(e)
async def main():
async with bot:
await load_extensions()
await bot.start(TOKEN)
asyncio.run(main())