-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
86 lines (59 loc) · 2.5 KB
/
Copy pathmain.py
File metadata and controls
86 lines (59 loc) · 2.5 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#Third Party Libraries
import discord
from discord.ext import commands, tasks
from discord import app_commands, Activity, ActivityType, ui
from itertools import cycle
from pathlib import Path
import motor.motor_asyncio
import os
from datetime import datetime
#Local Code
import settings
from mongo import Document
import emotes
cwd = Path(__file__).parents[0]
cwd = str(cwd)
logger= settings.logging.getLogger('bot')
async def get_prefix(bot, message):
# If dm's
if not message.guild:
return commands.when_mentioned_or("!")(bot, message)
try:
data = await bot.server_config.find(message.guild.id)
# Make sure we have a useable prefix
if not data or "prefix" not in data:
return commands.when_mentioned_or("!")(bot, message)
return commands.when_mentioned_or(data["prefix"])(bot, message)
except:
return commands.when_mentioned_or("!")(bot, message)
def run():
intents= discord.Intents.all()
bot = commands.Bot(command_prefix=get_prefix, owner_id =int(os.getenv("OWNER_ID")) ,intents=intents,help_command=None)
status= cycle(['!help | huskybot.net', f'{len(bot.guilds)} servers'])
bot.muted_users= {}
@bot.event
async def on_ready():
await bot.change_presence(status=discord.Status.do_not_disturb, activity=discord.Game(name=" 🥳 HAPPY NEW YEAR"))
bot.mongo= motor.motor_asyncio.AsyncIOMotorClient(str(settings.MONGO_TOKEN))
bot.db= bot.mongo['database']
bot.config = Document(bot.db, 'servers')
bot.server_config = Document(bot.db, 'Server Configs')
bot.user_data = Document(bot.db, 'User Data')
logger.info(f'User: {bot.user} (ID: {bot.user.id})')
for filename in os.listdir('AdminCommands'):
if filename.endswith('.py'):
await bot.load_extension(f'AdminCommands.{filename[:-3]}')
logger.info("Admin Commands Ready! [1/3]")
for filename in os.listdir('Commands'):
if filename.endswith('.py'):
await bot.load_extension(f'Commands.{filename[:-3]}')
logger.info("Commands Ready! [2/3]")
for filename in os.listdir('Events'):
if filename.endswith('.py'):
await bot.load_extension(f'Events.{filename[:-3]}')
logger.info("Events Ready! [3/3]")
bot.tree.copy_global_to(guild=settings.GUILDS_ID)
await bot.tree.sync()
bot.run(settings.DISCORD_API_SECRET, root_logger=True)
if __name__ == '__main__':
run()