forked from Groverkss/Synopsys
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
39 lines (28 loc) · 869 Bytes
/
main.py
File metadata and controls
39 lines (28 loc) · 869 Bytes
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
from discord.ext import commands
from os import environ
from pathlib import Path
def main():
token = environ.get("BOT_TOKEN")
if not token:
print("NO TOKEN")
return
prefix = environ.get("BOT_PREFIX")
if not prefix:
print("NO PREFIX")
return
bot = commands.Bot(command_prefix=commands.when_mentioned_or(prefix))
def no_dm_check(ctx):
if ctx.guild is None:
raise commands.NoPrivateMEssage(
"I refuse to take part in private conversations."
)
return True
# Add cogs
cogs = [file.stem for file in Path("cogs").glob("*py")]
for extension in cogs:
bot.load_extension(f"cogs.{extension}")
# Restrict bot usage to inside guild channels only.
bot.add_check(no_dm_check)
bot.run(token)
if __name__ == "__main__":
main()