-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
85 lines (69 loc) · 2.29 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# python3.11
# TODO Need to add ways to handle errors in requests for APIs
# TODO Add slash commands
import discord
from discord.ext.commands import Bot
from discord import Intents
import logging
import datetime
import json
import os.path
import asyncio
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# logger.setLevel(logging.INFO)
dt = datetime.datetime.now().strftime("%Y-%m-%d")
handler = logging.FileHandler(
filename="./logs/discord-" + dt + ".log", encoding="utf-8", mode="w"
)
handler.setFormatter(
logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s")
)
logger.addHandler(handler)
if os.path.isfile("./config/config-test.json"):
with open("./config/config-test.json", "r") as f:
config = json.load(f)
twitch = dict()
youtube = dict()
intents = Intents(
guilds=True,
members=True,
presences=True,
messages=True,
reactions=False,
voice_states=True,
message_content=True,
emojis_and_stickers=True,
)
class MyBot(Bot):
async def setup_hook(self):
await self.load_extension("cogs.reminders")
# await bot.load_extension("cogs.streamer_role")
await self.load_extension("cogs.roles")
await self.load_extension("cogs.wizards_event_posts")
await self.load_extension("cogs.misc")
# The following commands require waiting for the bot to be ready
asyncio.create_task(self.load_extension("cogs.twitch_notif"))
asyncio.create_task(self.load_extension("cogs.yt_notif"))
asyncio.create_task(self.load_extension("cogs.ffz_sync"))
bot = MyBot(intents=intents, command_prefix="!", log_handler=None)
# bot.tree = app_commands.CommandTree(bot)
@bot.event
async def on_ready():
await bot.change_presence(
activity=discord.Activity(
type=discord.ActivityType.watching, name="you struggle"
)
)
logger.info("Logged in as " + bot.user.name)
mchannel = bot.get_channel(422170422516121612)
await mchannel.send("reboot successful")
# await bot.tree.sync(guild=discord.Object(id=422170422516121610))
# await bot.tree.sync(guild=discord.Object(id=504675193751601152))
TOKEN = str(config["DISCORD"]["TOKEN"])
logger.info(TOKEN)
try:
print("starting bot")
bot.run(TOKEN)
except:
logger.exception("message: ")