-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
41 lines (32 loc) · 954 Bytes
/
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
import discord
from discord.ext import commands
from core.classes import Cog_Extension
import json
import random
import os
import asyncio
"""
1.5 重大更新需加入intents 詳細請閱讀官方文件
https://discordpy.readthedocs.io/en/latest/intents.html#intents-primer
"""
# 啟用所有 intents
intents = discord.Intents.default()
intents.members = True
# 讀取設定檔 load settings
with open('setting.json', 'r', encoding='utf8') as jfile:
jdata = json.load(jfile)
"""
command_prefix: 指令前綴
owner_ids: 擁有者ID
"""
bot = commands.Bot(command_prefix=jdata['Prefix'], owner_ids=jdata['Owner_id'], intents=intents)
# Bot完成啟動後事件
@bot.event
async def on_ready():
print(">> Bot is online <<")
# 載入cmds資料夾內所有cog
for filename in os.listdir('./cmds'):
if filename.endswith('.py'):
bot.load_extension(f'cmds.{filename[:-3]}')
if __name__ == "__main__":
bot.run(jdata['TOKEN'])