-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.py
37 lines (27 loc) · 1007 Bytes
/
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
# Standard imports
import json
import os
# Third-party imports
import discord
# Local imports
from channel_check import update_channel # update_channel程式從core目錄底下引入
from channel_check import change_status # update_channel程式從core目錄底下引入
intt = discord.Intents.default()
intt.members = True
intt.message_content = True
bot = discord.Bot(intents=intt)
# 變更目前位置到專案根目錄(SCAICT-DISCORD-BOT 資料夾),再找檔案
os.chdir("./")
with open(f"{os.getcwd()}/token.json", "r", encoding="utf-8") as file:
token = json.load(file)
for filename in os.listdir(f"{os.getcwd()}/cog"):
if filename.endswith(".py"):
bot.load_extension(f"cog.{filename[:-3]}")
print(f"📖 {filename} loaded") # test
@bot.event
async def on_ready():
print(f"✅ {bot.user} is online")
bot.loop.create_task(update_channel(bot))
bot.loop.create_task(change_status(bot))
if __name__ == "__main__":
bot.run(token["discord_token"])