-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnoharm.py
More file actions
51 lines (40 loc) · 1.14 KB
/
noharm.py
File metadata and controls
51 lines (40 loc) · 1.14 KB
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
import os
import discord
import random
from dadjokes import Dadjoke
client = discord.Client()
usage = '''\
Welcome to the NoHarm bot!
Available commands:
-hello
-dadjoke
'''.format(length='multi-line', ordinal='second')
def coinToss():
flip = random.randint(0, 1)
if (flip == 0):
return "Heads"
else:
return "Tails"
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('-hello'):
await message.channel.send('Hello!')
if message.content.startswith('-dadjoke'):
dadjoke = Dadjoke()
await message.channel.send(dadjoke.joke)
print(dadjoke.joke)
dadjoke = None
if message.content.startswith('-help'):
await message.channel.send(usage)
if message.content.startswith('-coinflip') or message.content.startswith('-cf'):
await message.channel.send(coinToss())
token = os.getenv('NOHARM_TOKEN')
if token:
client.run(token)
else:
print("NOHARM_TOKEN environment variable required")