-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
72 lines (60 loc) · 2.07 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
# vinny - discord moderation bot
# Copyright (C) 2024 0vf
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import discord
import os
import asyncio
from discord.ext import commands
from pathlib import Path
from utils import utils
from cogwatch import Watcher
import datetime
import sys
base_dir = Path(__file__).resolve().parent
class bot(commands.Bot):
def __init__(self) -> None:
intents = discord.Intents.all()
intents.emojis_and_stickers = False
allowed_mentions = discord.AllowedMentions(everyone=False, roles=False, users=True)
super().__init__(
intents=intents,
max_messages=5000,
command_prefix="Vinny",
allowed_mentions=allowed_mentions,
activity=discord.Activity(type=discord.ActivityType.listening, name="your every move")
)
bot = bot()
tree = bot.tree
config_data = utils.load_config()
token = config_data['discord']['token']
intents = discord.Intents.default()
@bot.event
async def on_ready():
print(f'logged in to {bot.user}')
bot.start_time = datetime.datetime.now(datetime.UTC)
watcher = Watcher(bot, path='cogs', debug=False)
await watcher.start()
async def loadcogs():
command_path = base_dir / 'cogs/cmds'
for files in os.listdir(command_path):
if files.endswith(".py"):
await bot.load_extension(f'cogs.cmds.{files[:-3]}')
extensions_path = base_dir / 'cogs/exts'
for files in os.listdir(extensions_path):
if files.endswith(".py"):
await bot.load_extension(f'cogs.exts.{files[:-3]}')
async def init():
async with bot:
await loadcogs()
await bot.start(token)
asyncio.run(init())