-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEdelia.py
91 lines (74 loc) · 2.27 KB
/
Edelia.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
import discord
import os
from discord.ext import commands
from discord import Game
from config import Config
def _prefix_callable():
base = [Config.get_option('PREFIX')]
return base
edelia = commands.Bot(
command_prefix=_prefix_callable(),
description=Config.get_option("DESCRIPTION"),
help_command=None,
owner_id=Config.get_option("BOT_OWNER")
)
@edelia.event
async def on_ready():
print(discord.__version__)
print('Logged in as')
print(edelia.user.name)
print(edelia.user.id)
print('------')
await edelia.change_presence(activity=Game(name="IA Become Humans"))
@edelia.command(
hidden=True
)
@commands.is_owner()
async def load(ctx, *, cog: str):
await ctx.message.delete()
await ctx.send("Loading {cog} Module ....".format(cog="cogs." + cog), delete_after=3)
try:
edelia.load_extension("cogs." + cog)
await ctx.send("{cog} loaded successfully.".format(cog=cog), delete_after=3)
except Exception:
await ctx.send("Cannot load extension", delete_after=5)
@edelia.command(
hidden=True
)
@commands.is_owner()
async def reload(ctx):
await ctx.message.delete()
await ctx.send("Reloading all the extensions", delete_after=3)
print("Reloading all the extensions")
for file in os.listdir("cogs"):
if file.endswith('.py'):
edelia.reload_extension('cogs.{}'.format(file.replace('.py', '')))
print("{} Extension Loaded".format(file.replace('.py', '')))
await ctx.send("Everything is reloaded.", delete_after=3)
@edelia.command(
name="changeprefix",
hidden=True
)
@commands.is_owner()
async def change_prefix(ctx, *, prefix: str):
await ctx.message.delete()
await ctx.send("Changing the prefix of the bot", delete_after=3)
print("Changing prefix of the bot")
current_conf = Config.get_config()
previous_prefix = current_conf['PREFIX']
current_conf['PREFIX'] = prefix
Config.update_config(current_conf)
print("Prefix changed")
edelia.command_prefix = prefix
await ctx.send("Have changed the prefix from {} to {}".format(
previous_prefix,
prefix
), delete_after=3)
def edelia_init():
for file in os.listdir("cogs"):
if file.endswith('.py'):
edelia.load_extension('cogs.{}'.format(file.replace('.py', '')))
print("{} Extension Loaded".format(file.replace('.py', '')))
edelia.run(Config.get_option("BOT_TOKEN"))
if __name__ == '__main__':
edelia_init()