-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
49 lines (38 loc) · 1.12 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
47
48
49
import os
import asyncio
import dotenv
import discord
from discord.ext import commands
# Load the .env file:
dotenv.load_dotenv()
bot_token = os.getenv("BOT_TOKEN")
# Intents allow you to specify which events you want to receive:
intents = discord.Intents.all()
intents.members = True
# Create a bot with the specified prefix and intents:
bot = commands.Bot(
command_prefix='!',
intents=intents,
case_insensitive=True,
help_command=None,
)
@bot.event
# When the bot is ready, print a message to the console:
async def on_ready():
print(f'We have logged in as {bot.user}')
# Change the bot's presence:
await bot.change_presence(activity=discord.Game(name="with your feelings!"))
print("Bot Activated!")
async def load():
# Load all cogs in the cogs folder:
for file in os.listdir('./cogs'):
if file.endswith('.py'):
await bot.load_extension(f'cogs.{file[:-3]}')
# Run the bot:
async def main():
# Load all cogs:
await load()
# Start the bot:
await bot.start(bot_token)
# Run the main function:
asyncio.run(main())