-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
74 lines (62 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
73
74
import json
import discord
from discord.ext import commands, bridge
# cogs
import secrets
from cogs import block, utils
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
intents.guilds = True
def get_prefix(bot, msg):
with open("./data/prefixes.json", "r") as f:
prefixes = json.load(f)
try:
prefix = prefixes.get(str(msg.guild.id))
except AttributeError:
prefix = "$"
return prefix
def when_mentioned_or_function(func):
def inner(bot, msg):
r = list(func(bot, msg))
r = commands.when_mentioned(bot, msg) + r
return r
return inner
bot = bridge.Bot(
command_prefix=when_mentioned_or_function(get_prefix),
description="This is a Bot made by Wiki and Crow.",
intents=intents,
allowed_mentions=discord.AllowedMentions(
everyone=False, # Whether to ping @everyone or @here mentions
roles=False, # Whether to ping role @mentions
# activity=discord.Game(name=input("Playing Status:")),
),
)
@bot.before_invoke
async def on_command(ctx):
try:
if ctx.author.guild_permissions.administrator:
ctx.command.reset_cooldown(ctx)
except:
pass
try:
if await block.BlockUtils.get_perm(ctx, ctx, "blacklist", ctx.author) and ctx.author.guild_permissions.administrator == False:
raise commands.CommandError(
f"{ctx.author.mention}, You were **blocked** from using this bot, direct message <@139095725110722560> if you feel this is unfair")
except AttributeError:
pass
@bot.event
async def on_message(message):
# remove markdown
message.content = utils.escape_markdown(message.content)
# stop if user is bot or is mentioning @everyone
if message.mention_everyone or message.author.bot:
return
extensions = utils.extensions()
for module in extensions[0]:
bot.load_extension(f"cogs.{module}")
print("Found", end=" ")
print(*extensions[0], sep=', ')
print("Ignored", end=" ")
print(*extensions[1], sep=', ')
bot.run(secrets.secret)