-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
52 lines (38 loc) · 1.25 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
import os
import locale
import aiohttp
from dotenv import load_dotenv
import discord
from discord.ext import commands, tasks
load_dotenv()
locale.setlocale(locale.LC_ALL, 'fr_FR.utf8')
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN')
GUILD_ID = os.getenv('GUILD_ID')
VOICE_CHANNEL_ID = os.getenv('VOICE_CHANNEL_ID')
APP_ID = os.getenv('APP_ID')
class MyBot(commands.Bot):
def __init__(self, command_prefix, *, intents, **options):
super().__init__(command_prefix, intents=intents, **options)
self.session = None
self.initial_extensions = [
'cogs.music',
'cogs.event',
'cogs.utils',
]
async def setup_hook(self):
self.background_task.start()
self.session = aiohttp.ClientSession()
for ext in self.initial_extensions:
await self.load_extension(ext)
async def close(self):
await super().close()
await self.session.close()
@tasks.loop(minutes=10)
async def background_task(self):
print('Running background task...')
@staticmethod
async def on_ready():
print('Ready!')
if __name__ == '__main__':
bot = MyBot('!', intents=discord.Intents().all(), application_id=APP_ID)
bot.run(DISCORD_TOKEN)