-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
69 lines (47 loc) · 1.56 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
59
60
61
62
63
64
65
66
67
68
import logging
import sys
import signal
import discord
from discord.ext import commands
#Put your token here:
#==============================
TOKEN = "<PASTE YOUR TOKEN HERE!>"
#==============================
#Logging
LOGGER = logging.getLogger('Bot')
LOGGER.setLevel(logging.INFO)
print_handler = logging.StreamHandler(sys.stdout)
file_handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
file_handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
print_handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
LOGGER.addHandler(file_handler)
LOGGER.addHandler(print_handler)
EXT_PERMS = discord.Permissions(
kick_members=True,
move_members=True,
connect=True,
speak=True,
administrator=True
)
BOT = commands.Bot(
command_prefix="+",
case_insensitive=True,
description="TR3-VR Bot",
intents=discord.Intents.all(),
member_cache_flags=discord.MemberCacheFlags.all()
)
@BOT.event
async def on_ready():
LOGGER.info("Bot is ready")
LOGGER.info("Invite link: %s", discord.utils.oauth_url(BOT.user.id, permissions=EXT_PERMS))
@BOT.event
async def on_command_error(ctx, err):
LOGGER.error("Error while processing command %s", ctx.message.content, exc_info=err)
#catch CTRL+C (linux only!)
def shutdown():
BOT.loop.create_task(BOT.close())
if sys.platform != "win32":
BOT.loop.add_signal_handler(signal.SIGINT, shutdown)
BOT.loop.add_signal_handler(signal.SIGTERM, shutdown)
BOT.load_extension("tr3vr")
BOT.run(TOKEN)