-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
46 lines (37 loc) · 1.35 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
from asyncio import tasks
from discord.ext import commands
import calendar
import asyncio
import discord
import time
import os
from discord_token import TOKEN
bot = commands.Bot(command_prefix="!", help_command = None)
timestamp = calendar.timegm(time.gmtime())
def check_if_it_is_me(ctx):
return ctx.message.author.id == 276627005280092162
@bot.event
async def on_ready():
# count current asyncio loop
task = len([task for task in asyncio.Task.all_tasks() if not task.done()])
await bot.change_presence(status = discord.Status.dnd, activity = discord.Game(name = f"Now processing {task} tasks."))
@bot.command()
@commands.check(check_if_it_is_me)
async def load(ctx, extension):
bot.load_extension(f"Cogs.{extension}")
await ctx.send(f"已加载 {extension}")
@bot.command()
@commands.check(check_if_it_is_me)
async def unload(ctx, extension):
bot.unload_extension(f"Cogs.{extension}")
await ctx.send(f"已卸载 {extension}")
@bot.command()
@commands.check(check_if_it_is_me)
async def reload(ctx, extension):
bot.reload_extension(f"Cogs.{extension}")
await ctx.send(f"已重载 {extension}")
for filename in os.listdir("./Cogs"):
if filename.endswith(".py") and filename != "settings.py" and not (filename.startswith("__")):
bot.load_extension(f"Cogs.{filename[:-3]}")
if __name__ == "__main__":
bot.run(TOKEN)