-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
66 lines (54 loc) · 2 KB
/
Copy pathmain.py
File metadata and controls
66 lines (54 loc) · 2 KB
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
import os
import asyncio
import logging
import discord
from discord.ext import commands
from dotenv import load_dotenv
from utils.logger import setup_logger
# Load environment variables
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD_ID = int(os.getenv('GUILD_ID'))
LOG_CHANNEL_ID = int(os.getenv('LOG_CHANNEL_ID'))
# Set up logging
logger = setup_logger()
# Set up intents
intents = discord.Intents.default()
intents.members = True # Needed for moderation commands
intents.presences = True # Needed for status information
class PointerBot(commands.Bot):
def __init__(self):
super().__init__(
command_prefix="!", # Prefix won't be used with slash commands
intents=intents,
help_command=None, # Disable default help command
)
self.log_channel = None
async def setup_hook(self):
# Load cogs
await self.load_extension("cogs.moderation")
logger.info("Loaded moderation cog")
await self.load_extension("cogs.tickets")
logger.info("Loaded tickets cog")
# Sync commands with guild
self.tree.copy_global_to(guild=discord.Object(id=GUILD_ID))
await self.tree.sync(guild=discord.Object(id=GUILD_ID))
logger.info(f"Synced slash commands to guild: {GUILD_ID}")
async def on_ready(self):
logger.info(f"Logged in as {self.user.name} | {self.user.id}")
await self.change_presence(activity=discord.Activity(
type=discord.ActivityType.watching,
name="Pointer | https://pointer.f1shy312.com"
))
# Set up log channel
self.log_channel = self.get_channel(LOG_CHANNEL_ID)
if not self.log_channel:
logger.error(f"Could not find log channel with ID: {LOG_CHANNEL_ID}")
else:
logger.info(f"Log channel set to: {self.log_channel.name}")
async def main():
bot = PointerBot()
async with bot:
await bot.start(TOKEN)
if __name__ == "__main__":
asyncio.run(main())