-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
35 lines (27 loc) · 1.17 KB
/
test.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
31
32
33
34
35
import discord, random, asyncio
class GGonnyang(discord.Client):
async def on_ready(self):
print(f'Logged in as {self.user} (ID: {self.user.id})')
print('------')
async def on_message(self, message):
if message.author.id == self.user.id:
return
if message.content.startswith('$guess'):
await message.channel.send('Guess a number between 1 and 10.')
def is_correct(m):
return m.author == message.author and m.content.isdigit()
answer = random.randint(1, 10)
try:
guess = await self.wait_for('message', check=is_correct, timeout=5.0)
except asyncio.TimeoutError:
return await message.channel.send(f'Sorry, you took too long it was {answer}.')
if int(guess.content) == answer:
await message.channel.send('You are right!')
else:
await message.channel.send(f'Oops. It is actually {answer}.')
intents = discord.Intents.default()
f = open("C:\\Users\\Pongc\\Desktop\\Develop\\GGonnyang.py\\token", "r")
token = f.readline()
f.close()
APP = GGonnyang(intents=intents)
APP.run(token)