python bot tutorial code example
Example 1: Discord.py bot example
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='prefix here')
@bot.event
async def on_ready():
print('Logged in as: ' + bot.user.name)
print('Ready!\n')
@bot.command()
async def commandname(ctx, *, somevariable)
Code goes here
await ctx.send('Message')
bot.run('yourtoken')
Example 2: python bots
import random
import time
choices=0
incorrect=1
incorrect1=1
incorrect2=1
print ("Welcome user. What is your name?")
cname = input()
print ("Before we start, I have to explain the rules to you.")
print ("This adventure game has multiple endings depending on what cycles of commands you choose to go through. Whenever your input is required, options will be displayed on the screen. Please choose one of the options and enter it in.")
time.sleep(6.5)
print ("\n")
print ("You wake up in a dark cave")
print ("You don't remember going to sleep in here...")
time.sleep(2)
print ("You're thinking about how you could've gotten here and what to do next when all of a sudden...")
time.sleep(2.5)
print ("*", cname, ",", cname, ",", cname, ",", cname, "*" " You hear a voice whisper your name and it bounces off the cold, inky black walls"" *", cname, ",", cname, ",", cname,", *" )
print ("\n")
time.sleep (4)
print ("Do you, (A) Get up and attempt to discover the source of the whispering?""\n""(B) Stay where you are and not move a muscle for fear of being discovered?"
"\n""(C) Get up and run as far away from the whispering as possible?")
choice1=input()
if choice1=="A" or choice1=="a":
print ("\n")
print ("You venture deep into the caverns and press along the dark and suprisingly.. soft walls.")
time.sleep(3)
print ("After many cuts and soft curses from the many sharp extrusions in the wall, you come across a mossy vined section of the wall.")
time.sleep(4)
print ("You look up and notice a faint white light hundreds of feet above which appears to be the source of the whispering, and the only way up, appears to be the treacherous vined wall...")
time.sleep(5)
print ("Do you wish to (A) try your luck on the treacherous vines or (B) keep looking for another way?")
choice1a=input()
if choice1a=="A" or choice1a=="a":
print ("\n")
print ("Many near death expeiences and torn soles later you crawl up onto the ledge.")
time.sleep(3)
print ("The whispering suddenly ceases and the burning light parts to reveal a shadowy creature standing there...")
time.sleep(4.5)
print ("Well well, an adventurous one, welcome to my cave of riddles, its scratchy voice whispered.")
time.sleep(4)
print ("Im feeling merciful today so how about you either (A) get a riddle with one guess to try and solve it or (B) have 5 tries to guess a number from 1-10? \nIf you win, you live, and if you lose, you die!")
choice1b=input()