-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
46 lines (36 loc) · 1.32 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
# main.py
import asyncio
import os
import discord
from helpers import onMessageHelper
from dotenv import load_dotenv
from discord.ext import commands
# import token from env file
load_dotenv()
token = os.getenv('DISCORD_TOKEN')
command_prefix = os.getenv('COMMAND_PREFIX')
# set variables
cogsList = ['cog.standardCog', 'cog.remindCog', 'cog.openaiCog']
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
zeldaBot = commands.Bot(command_prefix=command_prefix, case_insensitive=True, help_command=None, intents=intents)
# set up cogs then start the bot
async def start():
async with zeldaBot:
for extension in cogsList:
await zeldaBot.load_extension(extension)
await zeldaBot.start(token)
# setup when the bot starts
@zeldaBot.event
async def on_ready():
await zeldaBot.change_presence(activity=discord.Streaming(name='type "!help"', url='https://www.twitch.tv'
'/MattyReign'))
print(f'{zeldaBot.user.name} has connected to Discord!')
# function to load adn watch for non-standard commands
@zeldaBot.event
async def on_message(message):
await onMessageHelper.userMessage(message, zeldaBot)
await zeldaBot.process_commands(message)
# run the bot
asyncio.run(start())