-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
56 lines (37 loc) · 1.4 KB
/
main.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
from bot import Bot, logging_conf
import discord
import logging
import logging.config
default_extensions = ["cogs.general", "cogs.texte", "cogs.utils", "cogs.challenge"]
logging.config.dictConfig(logging_conf)
log = logging.getLogger()
help_attrs = dict(hidden=True, aliases=['aide', 'commandes'])
bot = Bot(command_prefix='!', default_extensions=default_extensions,
pm_help=True, help_attrs=help_attrs,
command_not_found="Aucune commande nommée `{}`",
command_has_no_subcommands="Aucune sous-commandes pour {0.name}")
@bot.event
async def on_ready():
log.info("--> Successfully connected!")
log.info("------------------------------------------")
@bot.event
async def on_message(message):
if message.author.bot:
return
await bot.process_commands(message)
@bot.event
async def on_command(ctx):
log.info(u"{0.content} sent by {0.author.name}".format(ctx.message))
if not isinstance(ctx.channel, discord.abc.PrivateChannel) and ctx.invoked_with != "eval":
await ctx.message.delete()
@bot.event
async def on_command_error(ctx, err):
log.error(u"{0.content} sent by {0.author.name}. Error : {1}".format(ctx.message, err))
def get_account():
with open('account') as f:
return f.read()
if __name__ == '__main__':
log.info("--> Connecting..")
account = get_account()
bot.run(account)
log.info("--> That's all, folks!")