-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
42 lines (32 loc) · 1.18 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
# bot.py
import os
import discord
from discord.ext import commands
from dotenv import load_dotenv
from fact.fact import Fact
from fact.wordcount import WordCount
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
COMMAND_PREFIX = '.'
client = commands.Bot(command_prefix=COMMAND_PREFIX)
FACTS = {
'wordcount': WordCount(client)
}
VALID_FACT_ARGUMENTS = ['common', 'wordcount', 'lasttype']
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
@client.command(name='fact', help='Tells you whatever fact you wish to know about your discord server.')
async def fact(ctx, fact_name='none', *fact_args):
if fact_name == 'none':
await ctx.send(f'No fact name was given! Use {COMMAND_PREFIX}fact list to see the list of facts!')
elif fact_name == 'list':
await ctx.send('List of facts:')
for key in FACTS:
await ctx.send(key)
elif fact_name.lower() not in FACTS.keys():
await ctx.send(f'This is not a valid fact name! Use {COMMAND_PREFIX}fact list to see the list of facts!')
else:
current_fact = FACTS.get(fact_name.lower())
await current_fact.display_fact(ctx, fact_args)
client.run(TOKEN)