-
Notifications
You must be signed in to change notification settings - Fork 1
/
o_o.py
51 lines (41 loc) · 1.39 KB
/
o_o.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
import discord
from discord.ext import commands
from discord import app_commands
from discord.ext.commands import Greedy, Context
from typing import Literal, Optional
import os
import traceback
cogslist = [
'cogs.notion_manager'
]
class o_o(commands.Bot):
def __init__(self):
super().__init__(
command_prefix='/',
intents=discord.Intents.all())
if os.path.isfile('.env'):
from dotenv import load_dotenv
load_dotenv()
self.MY_GUILD = discord.Object(id=int(os.environ['DISCORD_GUILD_ID']))
async def setup_hook(self):
for cog in cogslist:
try:
await self.load_extension(cog)
except Exception:
traceback.print_exc()
async def on_ready(self):
print(f'{self.user} has connected to Discord!')
await bot.change_presence(status=discord.Status.online, activity=discord.Game(f'豊かな人生'))
await self.tree.sync()
await self.tree.sync(guild=self.MY_GUILD)
bot = o_o()
@bot.tree.command(name='reload')
async def reload(interaction: discord.Interaction):
print('reloading...')
for cog in cogslist:
try:
await bot.reload_extension(cog)
except Exception:
traceback.print_exc()
await interaction.response.send_message('reloading success!')
bot.run(os.environ['DISCORD_BOT_TOKEN'])