-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom.py
More file actions
33 lines (26 loc) · 1.16 KB
/
random.py
File metadata and controls
33 lines (26 loc) · 1.16 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
import aiohttp
import discord
import random
from discord.ext import commands
class Random(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def flip(self, ctx, count: int):
if count < 0: return await ctx.send("Can't flip a negative number of coins")
if count == 0: return await ctx.send("Well... you flipped nothing so... Nothing")
await ctx.send(" ".join(random.choice(["H", "T"]) for x in range(count)))
@commands.command()
async def roll(self, ctx, count: int):
print("HERE")
if count < 0: return await ctx.send("Can't roll a negative number of dice")
if count == 0: return await ctx.send("Well... you rolled nothing so... Nothing")
await ctx.send(" ".join(str(random.randint(1, 6)) for x in range(count)))
@commands.command()
async def cat(self, ctx):
async with aiohttp.ClientSession() as session:
async with session.get("https://api.thecatapi.com/v1/images/search") as resp:
data = await resp.json()
return await ctx.send(data[0]["url"])
def setup(bot):
bot.add_cog(Random(bot))