-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
60 lines (49 loc) · 1.69 KB
/
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
import json
import os
import discord
from discord.ext import commands
import asyncio
from adminRole import *
__cogs=["admin","score"]
intents = discord.Intents.default()
intents.message_content = True
# client = discord.Client(intents=intents)
token = os.getenv("DC_BOT_TOKEN")
bot = commands.Bot(command_prefix='$', intents=intents)
@bot.command(name="reload" ,help="reload all cogs")
async def reload(ctx):
try:
if roleCheck(adminRoleName,ctx.author) or roleCheck(superAdminRoleName,ctx.author):
for i in __cogs:
await bot.reload_extension(f"cogs.{i}")
await ctx.send("reload all cogs")
else:
print(f"{ctx.message.author} try to reload all cogs")
except Exception as e:
await ctx.send("reload error")
print(f"reload error {e}")
# @bot.command()
# async def help(ctx):
# with open("HELP.md","r") as f:
# await ctx.send(f.read())
@bot.event
async def on_ready():
print('login: ', bot.user)
game = discord.Game("use `$help` command to get help")
# discord.Status.<狀態>,可以是online,offline,idle,dnd,invisible
await bot.change_presence(status=discord.Status.online, activity=game)
try:
# for filename in os.listdir("./cogs"):
# if filename.endswith(".py"):
# await bot.load_extension(f"cogs.{filename[:-3]}")
for i in __cogs:
await bot.load_extension(f"cogs.{i}")
print(f"load {i}")
except Exception as e:
print(f"load error {e}")
else:
print("load all cogs")
slash = await bot.tree.sync()
print(f"load {len(slash)} slash commands")
if __name__ == "__main__":
bot.run(token)