-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbot.py
54 lines (40 loc) · 1.23 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
import disnake
from disnake.ext import commands
import os
import logging
import datetime
from dotenv import load_dotenv
load_dotenv()
TOKEN: str = os.getenv("TOKEN", "")
logfile_name = datetime.datetime.now().strftime(
"%Y-%m-%d %H-%M-%S"
) # Setting the filename from current date and time
if not os.path.exists("logs"):
os.mkdir("logs") # Creating a folder for logs if it doesn't exist
logging.basicConfig(
level=logging.INFO,
format="%(levelname)s %(asctime)s - %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
filemode="a",
filename=f".\\logs\\{logfile_name}.log",
)
intents = disnake.Intents.default()
intents.message_content = True
intents.members = True
# Set test guild so the bot instantly registers the commands for the spotdl server.
client = commands.InteractionBot(
intents=intents,
sync_commands=True,
reload=True,
)
@client.event
async def on_ready():
# Set presence
activity = disnake.Activity(name="over spotDL", type=disnake.ActivityType.watching)
await client.change_presence(activity=activity)
print("Ready!")
# Load all extensions
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
client.load_extension(f"cogs.{filename[:-3]}")
client.run(TOKEN)