This repository has been archived by the owner on Jan 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·95 lines (81 loc) · 2.65 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
86
87
88
89
90
91
92
93
94
95
import time
import discord
from discord.ext import commands
from jishaku.help_command import MinimalEmbedPaginatorHelp
from cogs.utils.config import read, write
from cogs.utils.errors import CommandDisabled, ModuleDisabled
import logging
from logging.handlers import RotatingFileHandler
logger = logging.getLogger('discord')
logger.setLevel(logging.INFO)
handler = RotatingFileHandler(filename='debug.log', encoding='utf-8', mode='a', maxBytes=50000000, backupCount=1)
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)
bot = commands.Bot(command_prefix=commands.when_mentioned_or(*["g!", "G!", "Guardian ", "Guard ", "guardian ", "guard "]),
help_command=MinimalEmbedPaginatorHelp(), owner_ids={421698654189912064, 317731855317336067},
case_insensitive=True, activity=discord.Game("early development - open alpha."))
bot.started = time.time()
cogs = [
# "cogs.config",
"jishaku",
"cogs.mod",
# "cogs.meta",
# "cogs.appeals",
# "cogs._utils",
# "cogs.events"
]
@bot.event
async def on_ready():
bot.last_reboot = time.time()
print(f"Logged in as {bot.user.name} - {discord.utils.oauth_url(bot.user.id)}")
for cog in cogs:
try:
bot.load_extension(cog)
except:
continue
print(f"{len(bot.guilds)} guilds, {len(bot.cogs)} cogs.")
@bot.before_invoke
async def makesuretheyareregisteredindatabase(ctx):
d = read("./data/core.json")
if d.get(str(ctx.guild.id)) is None:
d[str(ctx.guild.id)] = {
"warns": {},
"mutes": {},
"unmutes:": {},
"bans": {},
"kicks": {},
"unbans": {},
"next id": 1,
"log channel": None,
"toggles": {"commands": [], "modules": []},
"muted role": None,
"appeal server": None,
"automod": {
"enabled": False,
"upscale": False,
"spam": {"in": 5, "count": 5, "punishment": None},
"maxmentions": {"max": 10, "includeroles": True, "punishment": None},
"ignore": {"roles": [], "channels": [], "users": []}
}
}
write("./data/core.json", d)
@bot.check
async def notdisabled(ctx):
if ctx.guild:
data = read("./data/core.json")
cog = ctx.command.cog_name
cmdname = ctx.command.name
i = str(ctx.guild.id)
if data.get(str(ctx.guild.id)):
if cmdname in data[i]["toggles"]["commands"]:
raise CommandDisabled("Command Disabled")
elif cog in data[i]["toggles"]["modules"]:
raise ModuleDisabled("Module Disabled")
else:
return True
else:
return True
@bot.event
async def on_disconnect():
logging.critical("Disconnected from discord.")
bot.run("INSERT_TOKEN_HERE!")