Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- from discord.ext.commands import Bot
- from discord.ext import commands
- import asyncio
- import time
- import random
- Client = discord.Client() #Initialise Client
- client = commands.Bot(command_prefix = "<prefix>") #Initialise client bot
- @client.event
- async def on_message(message):
- if message.content.upper().startswith('<prefix>GUESS'): #Replace <prefix> with your bot prefix
- userID = message.author.name
- await client.send_message(message.channel, ':question: | Guess a number between 1 to 10, **%s**' % (userID))
- def guess_check(m):
- return m.content.isdigit()
- guess = await client.wait_for_message(timeout=5.0, author=message.author, check=guess_check)
- answer = random.randint(1, 10)
- if guess is None:
- fmt = ':question: | Sorry, you took too long. It was {}.'
- await client.send_message(message.channel, fmt.format(answer))
- return
- if int(guess.content) == answer:
- await client.send_message(message.channel, ':question: | You are right, **%s**!' % (userID))
- else:
- await client.send_message(message.channel, ':question: | Sorry. It is actually {}, **%s**.'.format(answer) % (userID))
- client.run("<token>") #Insert your bots token here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement