-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrng.py
29 lines (21 loc) · 817 Bytes
/
rng.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
import random
from discord.ext import commands
class RNG():
def __init__(self, bot):
self.bot = bot
@commands.command()
async def roll(self, dice : str):
"""Rolls a dice in NdN format."""
try:
rolls, limit = map(int, dice.split('d'))
except Exception:
await self.bot.say('Format has to be in NdN!')
return
result = ', '.join(str(random.randint(1, limit)) for r in range(rolls))
await self.bot.say(result)
@commands.command(description='For when you wanna settle the score some other way')
async def choose(self, *choices : str):
"""Chooses between multiple choices."""
await self.bot.say(random.choice(choices))
def setup(bot):
bot.add_cog(RNG(bot))