Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Geekeh
GitHub Repository: Geekeh/Bloxflip-Mines-Predictor-Discord-Bot
Path: blob/main/main.py
1526 views
1
import discord
2
import time
3
from discord import app_commands
4
import random
5
6
# https://github.com/Digiwind/Digiwind-Videos/blob/main/DPY%20Slash%20Commands.py for slash command template
7
class aclient(discord.Client):
8
def __init__(self):
9
super().__init__(intents = discord.Intents.default())
10
self.synced = False
11
12
async def on_ready(self):
13
await self.wait_until_ready()
14
if not self.synced:
15
await tree.sync()
16
self.synced = True
17
print(f"We have logged in as {self.user}.")
18
19
client = aclient()
20
tree = app_commands.CommandTree(client)
21
22
@tree.command(name = 'mines', description='mines game mode')
23
async def mines(interaction: discord.Interaction, tile_amt: int, round_id : str):
24
if len(round_id) == 36:
25
start_time = time.time()
26
grid = ['❌','❌','❌','❌','❌','❌','❌','❌','❌','❌','❌','❌','❌','❌','❌','❌','❌','❌','❌','❌','❌','❌','❌','❌','❌']
27
already_used = []
28
29
count = 0
30
while tile_amt > count:
31
a = random.randint(0, 24)
32
if a in already_used:
33
continue
34
already_used.append(a)
35
grid[a] = '✅'
36
count += 1
37
38
chance = random.randint(45,95)
39
if tile_amt < 4:
40
chance = chance - 15
41
42
em = discord.Embed(color=0x0025ff)
43
em.add_field(name='Grid', value="\n" + "```"+grid[0]+grid[1]+grid[2]+grid[3]+grid[4]+"\n"+grid[5]+grid[6]+grid[7]+grid[8]+grid[9]+"\n"+grid[10]+grid[11]+grid[12]+grid[13]+grid[14]+"\n"+grid[15]+grid[16]+grid[17] \
44
+grid[18]+grid[19]+"\n"+grid[20]+grid[21]+grid[22]+grid[23]+grid[24] + "```\n" + f"**Accuracy**\n```{chance}%```\n**Round ID**\n```{round_id}```\n**Response Time:**\n```{str(int(time.time() - int(start_time)))}```")
45
em.set_footer(text='made by geek')
46
await interaction.response.send_message(embed=em)
47
else:
48
em = discord.Embed(color=0xff0000)
49
em.add_field(name='Error', value="Invalid round id")
50
await interaction.response.send_message(embed=em)
51
52
client.run('bot token')
53
54