Add initiative rolls
This commit is contained in:
parent
bead178487
commit
cab8ed7d83
|
@ -43,10 +43,14 @@ def dice(count):
|
||||||
|
|
||||||
return '{0}\n**{1}**'.format(', '.join(results), succ(successes))
|
return '{0}\n**{1}**'.format(', '.join(results), succ(successes))
|
||||||
|
|
||||||
|
def initiative(init_mod):
|
||||||
|
roll = random.randint(1, 10)
|
||||||
|
return('{0}+{1} = **{2} Initiative**'.format(roll, init_mod, roll+init_mod))
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print('logged in as {0.user}'.format(client), file=sys.stderr)
|
print('logged in as {0.user}'.format(client), file=sys.stderr)
|
||||||
await client.change_presence(activity=discord.Game('!n for n dice, !0 for chance die'))
|
await client.change_presence(activity=discord.Game('!n for n dice, ?i for initiative'))
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
async def on_message(message):
|
async def on_message(message):
|
||||||
|
@ -66,6 +70,17 @@ async def on_message(message):
|
||||||
await message.channel.send(chance_die())
|
await message.channel.send(chance_die())
|
||||||
else:
|
else:
|
||||||
await message.channel.send(dice(count))
|
await message.channel.send(dice(count))
|
||||||
|
elif message.content.startswith('?'):
|
||||||
|
try:
|
||||||
|
init_mod=int(message.content.split()[0][1:])
|
||||||
|
except ValueError:
|
||||||
|
print('error parsing message {0}'.format(message.content), file=sys.stderr)
|
||||||
|
return
|
||||||
|
|
||||||
|
if init_mod > 20 or init_mod < -20:
|
||||||
|
await message.channel.send(':thinking:')
|
||||||
|
else:
|
||||||
|
await message.channel.send(initiative(init_mod))
|
||||||
|
|
||||||
with open('token') as f:
|
with open('token') as f:
|
||||||
token = f.read().strip()
|
token = f.read().strip()
|
||||||
|
|
Loading…
Reference in a new issue