-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (46 loc) · 1.6 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
53
54
55
56
57
58
import os
import logging
import discord
from commands.TimeCommand import TimeCommand
from commands.CobraCommand import CobraCommand
from commands.RoleCommand import RoleCommand
from keep_alive import keep_alive
from config import CONFIG
# Setup logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s %(levelname)s %(name)s: %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
logger = logging.getLogger('cobra_bot')
# Setup Bot
intents = discord.Intents.default()
intents.members = True # required for reaction events to work
bot = discord.ext.commands.Bot(
command_prefix="!",
intents=intents,
description=
"Cobra Bot is a Discord Bot that helps you run Netrunner Tournaments using Discord!"
)
# On startup, log all servers you are connected to.
@bot.event
async def on_ready():
logger.log(logging.INFO,
"Hello! My name is {0.user} and I am ready!".format(bot))
for guild in bot.guilds:
logger.log(logging.INFO, guild.name)
# Add support for !time commands
bot.add_cog(TimeCommand(bot))
# Add support for !cobra commands
bot.add_cog(CobraCommand(bot))
# Add support for role management commands
if (CONFIG.ROLE_MANAGEMENT_ENABLED):
bot.add_cog(RoleCommand(bot))
if __name__ == "__main__":
# This is for replit.com
# Startup Web Server in separate thread, to keep alive bot.
# You still need to have a WebServer to be pinged externally. Check out https://uptimerobot.com/
keep_alive()
# Create your Bot and get token from https://discord.com/developers/
# Get Token from environment variables
# Startup Bot
bot.run(os.environ['discord_bot_token'])