Answers for "python bot tutorial"

1

Discord.py bot example

#Anything commented out is optional

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='prefix here')

@bot.event
async def on_ready():
#   await bot.change_presence(activity=discord.Game(name="Rich Presence Here"))
    print('Logged in as: ' + bot.user.name)
    print('Ready!n')
    
@bot.command()
async def commandname(ctx, *, somevariable)
#If you don't need a variable, then you only need (ctx)
#	"""Command description"""
	Code goes here
	await ctx.send('Message')

bot.run('yourtoken')
Posted by: Guest on January-09-2021
1

python bots

#I'm assuming that people would like a chatbot: Here is an example of one that tells an adventure story.
#Feel free to make any changes.
#I'm not going to write out a completed bot, by the way.


#Importing the time and random modules.
import random
import time 

#Setting the counters.
choices=0
incorrect=1
incorrect1=1
incorrect2=1

#Asking the User's name.
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)

#Introduces the story of the game, sets the theme and gives the user their first choice on where to go.
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()
Posted by: Guest on March-04-2021

Python Answers by Framework

Browse Popular Code Answers by Language