-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
93 lines (77 loc) · 2.51 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
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
import os
import discord
from discord.ext import commands
from misc import jsonHandler as jso
from misc import inject
inject.injectVariables()
dev = jso.read_json("mode.json")
dev = dev['dev']
if dev == True:
prefix = os.getenv("devPrefix")
token = os.getenv("devToken")
else:
prefix = "-"
token = os.getenv("discordToken")
client = commands.Bot(command_prefix=prefix, case_insensitive=True)
@client.event
async def on_ready():
print(f"[Client] {client.user} connected to discord!")
client.load_extension('cogs.LightController')
client.load_extension('cogs.Colours')
client.load_extension('cogs.Fun')
client.load_extension('cogs.Music')
@client.command(name="shutdown")
async def _shutdown(ctx):
"""
Shut downs bot
"""
id = 686846374737739797
if str(ctx.author.id) != str(id):
await ctx.send("You are not the bot owner!")
else:
print(f"[Client] {client.user} logged out!")
await ctx.send(':wave: Bye Bye!')
await ctx.bot.logout()
@client.command(name="togglechange", aliases=["tcg"])
async def _changetoggle(ctx, type: bool):
"""
Allow/Disallow Light Controller
"""
id = 686846374737739797
if str(ctx.author.id) != str(id):
await ctx.send("You are not the bot owner!")
else:
data = { "allowDiscordChange": type }
jso.writeJson("controller.json", data)
@client.command(name="reload")
async def _reload(ctx, cog: str):
"""
Reloads a cog
"""
id = 686846374737739797
if str(ctx.author.id) != str(id):
await ctx.send("You are not the bot owner!")
else:
await ctx.send("Attempting to reload cog " + cog)
try:
client.unload_extension(f"cogs.{cog}")
client.load_extension(f"cogs.{cog}")
await ctx.send(f"Reloaded cog {cog}")
except Exception as e:
await ctx.send(f"Error whilst loading cog: ```{e}```")
@client.command(name="load")
async def _reload(ctx, cog: str):
"""
Loads a cog
"""
id = 686846374737739797
if str(ctx.author.id) != str(id):
await ctx.send("You are not the bot owner!")
else:
await ctx.send("Attempting to load cog " + cog)
try:
client.load_extension(f"cogs.{cog}")
await ctx.send(f"Loaded cog {cog}")
except Exception as e:
await ctx.send(f"Error whilst loading cog: ```{e}```")
client.run(str(token))