-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot.py
60 lines (51 loc) · 1.73 KB
/
bot.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
import discord
from discord.ext import commands
import json
import logging
from unity_util import bot_config
import sys
with open('config.json', 'r') as f:
conf = json.load(f)
logging.basicConfig(level=logging.INFO, format="[%(levelname)s]\t %(name)s: %(message)s", handlers=[
logging.StreamHandler(sys.stdout),
logging.FileHandler(f'./logs/{bot_config.LOGGING_FILENAME}')
])
intents = discord.Intents(
guilds=True,
members=True,
bans=True,
emojis=True,
messages=True,
guild_messages=True,
dm_messages=True,
reactions=True,
guild_reactions=True,
dm_reactions=True
)
client = commands.Bot(command_prefix = bot_config.DISCORD_PREFIX, intents=intents)
@client.event
async def on_ready():
logging.info(f'Logged in as {client.user.name}, {client.user.id}')
logging.info('-----------------------------------------')
await client.change_presence(activity=discord.Game("Verifying 👀"))
@client.command()
@commands.is_owner()
async def load(ctx, extension):
client.load_extension(f'unity_cogs.{extension}')
await ctx.send(f'{extension} loaded')
logging.info(f'{extension} loaded')
@client.command()
@commands.is_owner()
async def unload(ctx, extension):
client.unload_extension(f'unity_cogs.{extension}')
await ctx.send(f'{extension} unloaded')
logging.info(f'{extension} unloaded')
@client.command()
@commands.is_owner()
async def reload(ctx, extension):
client.reload_extension(f'unity_cogs.{extension}')
await ctx.send('{} reloaded'.format(extension))
logging.info(f'{extension} reloaded')
for cog in conf['preloaded']:
client.load_extension(f'unity_cogs.{cog}')
client.run(bot_config.DISCORD_TOKEN)