2024-03-23 10:45:48 +00:00
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
import discord
|
|
|
|
import platform
|
|
|
|
|
|
|
|
from discord.ext import bridge
|
|
|
|
|
|
|
|
logs = logging.getLogger('Racu.Core')
|
|
|
|
|
|
|
|
|
|
|
|
class RacuBot(bridge.Bot):
|
|
|
|
async def on_ready(self):
|
|
|
|
logs.info(f"[INFO] Logged in as {self.user.name} | {self.user.id}")
|
|
|
|
logs.info(f"[INFO] discord.py API version: {discord.__version__}")
|
|
|
|
logs.info(f"[INFO] Python version: {platform.python_version()}")
|
|
|
|
logs.info(f"[INFO] Running on: {platform.system()} {platform.release()} ({os.name})")
|
|
|
|
logs.info("-------------------------------------------------------")
|
|
|
|
|
|
|
|
"""
|
|
|
|
https://docs.pycord.dev/en/stable/api/events.html#discord.on_ready
|
|
|
|
This function isn't guaranteed to only be called once.
|
|
|
|
Event is called when RESUME request fails.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@staticmethod
|
2024-03-23 11:05:38 +00:00
|
|
|
async def get_or_fetch_channel(guild, channel_id):
|
2024-03-23 10:45:48 +00:00
|
|
|
channel = guild.get_channel(channel_id)
|
|
|
|
|
|
|
|
if not channel:
|
|
|
|
try:
|
|
|
|
channel = await guild.fetch_channel(channel_id)
|
|
|
|
|
|
|
|
except (discord.HTTPException, discord.NotFound, discord.Forbidden):
|
2024-03-23 11:05:38 +00:00
|
|
|
return None
|
2024-03-23 10:45:48 +00:00
|
|
|
|
|
|
|
return channel
|