-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
107 lines (81 loc) · 3.53 KB
/
app.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
96
97
98
99
100
101
102
103
104
105
106
107
#
# Hifi Superstar Discord Bot
# Copyright (c) 2021 - 2023 by Philip Butkiewicz and contributors <https://github.com/philipbutkiewicz>
#
import discord
import json
import sys
import asyncio
from hifisuperstar.Bot import Bot
from hifisuperstar.cogs.Regex.RegexCog import RegexCog
from hifisuperstar.cogs.SelectableRoles.SelectableRolesCog import SelectableRolesCog
from hifisuperstar.cogs.UserJoin.UserJoinCog import UserJoinCog
from hifisuperstar.core.Server.Events import Events
from hifisuperstar.io.Logger import log_init
from hifisuperstar.cogs.Music.MusicCog import MusicCog
from hifisuperstar.cogs.Spotify.SpotifyCog import SpotifyCog
from hifisuperstar.cogs.AntiLoudmouth.AntiLoudmouthCog import AntiLoudmouthCog
from hifisuperstar.cogs.Jokes.JokesCog import JokesCog
from hifisuperstar.cogs.RandomPictures.RandomPicturesCog import RandomPicturesCog
from hifisuperstar.cogs.Kenja.KenjaCog import KenjaCog
from hifisuperstar.cogs.Acl.AclCog import AclCog
from hifisuperstar.cogs.ImageSearch.ImageSearchCog import ImageSearchCog
from hifisuperstar.cogs.VoiceRecorder.VoiceRecorderCog import VoiceRecorderCog
from hifisuperstar.cogs.Szperus.SzperusCog import SzperusCog
from hifisuperstar.io.UnbufferedOutput import UnbufferedOutput
# Disable output buffering
sys.stdout = UnbufferedOutput(sys.stdout)
sys.stdout.reconfigure(encoding='utf-8')
# Read configuration
config = {}
with open('config.json', 'r', encoding='utf-8') as f:
config = json.loads(f.read())
# Configure the Discord client
client = Bot(intents=(discord.Intents.all()))
# Setup logging
log_init()
# Setup events
@client.event
async def on_member_join(member):
await Events.run_event('on_member_join', member=member)
@client.event
async def on_reaction_add(reaction, member):
await Events.run_event('on_reaction_add', reaction=reaction, member=member)
@client.event
async def on_message(message):
await Events.run_event('on_message', message=message)
@client.event
async def on_voice_state_update(member, prev, cur):
await Events.run_event('on_voice_state_update', member=member, prev=prev, cur=cur)
# Add all cogs
if len(config['Bot']['Enabled_Cogs']) == 0:
print('No cogs have been enabled. Please enable at least 1 cog in the config.json file.')
sys.exit(1)
if 'Music' in config['Bot']['Enabled_Cogs']:
client.add_cog(MusicCog(config))
if 'Spotify' in config['Bot']['Enabled_Cogs']:
client.add_cog(SpotifyCog(config))
if 'AntiLoudmouth' in config['Bot']['Enabled_Cogs']:
client.add_cog(AntiLoudmouthCog(config, client))
if 'Jokes' in config['Bot']['Enabled_Cogs']:
client.add_cog(JokesCog(config))
if 'RandomPictures' in config['Bot']['Enabled_Cogs']:
client.add_cog(RandomPicturesCog(config))
if 'Kenja' in config['Bot']['Enabled_Cogs']:
client.add_cog(KenjaCog(config))
if 'Acl' in config['Bot']['Enabled_Cogs']:
client.add_cog(AclCog(config))
if 'ImageSearch' in config['Bot']['Enabled_Cogs']:
client.add_cog(ImageSearchCog(config))
if 'VoiceRecorder' in config['Bot']['Enabled_Cogs']:
client.add_cog(VoiceRecorderCog(config))
if 'Regex' in config['Bot']['Enabled_Cogs']:
client.add_cog(RegexCog(config))
if 'UserJoin' in config['Bot']['Enabled_Cogs']:
client.add_cog(UserJoinCog(config))
if 'SelectableRoles' in config['Bot']['Enabled_Cogs']:
client.add_cog(SelectableRolesCog(config))
if 'Szperus' in config['Bot']['Enabled_Cogs']:
client.add_cog(SzperusCog(config))
# Run the client
client.run(config['Bot']['Token'])