-
Notifications
You must be signed in to change notification settings - Fork 22
/
dice.py
30 lines (25 loc) · 952 Bytes
/
dice.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
from pyrogram import Client, filters
from pyrogram.types import Message
from utils.misc import modules_help, prefix
from utils.scripts import format_exc
import asyncio
@Client.on_message(filters.command("dice", prefix) & filters.me)
async def dice_text(client: Client, message: Message):
try:
value = int(message.command[1])
if value not in range(1, 7):
raise AssertionError
except (ValueError, IndexError, AssertionError):
return await message.edit("<b>Invalid value</b>")
try:
message.dice = type("bruh", (), {"value": 0})()
while message.dice.value != value:
message = (await asyncio.gather(
message.delete(),
client.send_dice(message.chat.id)
))[1]
except Exception as e:
await message.edit(format_exc(e))
modules_help["dice"] = {
"dice [1-6]*": "Generate dice with specified value. Works only in groups"
}