Python Forum

Full Version: Discord Bot
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello! I have found that while creating a discord bot; this line of code doesn't work!

async def start_dungeon(ctx, member : discord.Member, a: str)

This is the whole wall of code:

import random
import discord
from discord.ext import commands
from random import choice
import shutil
from discord.utils import get
import os
from os import system
import asyncio

client = commands.Bot(command_prefix = '$')

list2 = [3, 4, 5]
list3 = [4, 5, 6, 7]
list4 = ["spiders", "skeletons"]

spiderhp = 20
skeletonhp = 20

list5 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

dmg1 = random.choice(list5)

mob = random.choice(list4)

if mob == 'spiders':
    mobhp = spiderhp
elif mob == 'skeletons':
    mobhp = skeletonhp

@client.event
async def on_ready():
    await client.change_presence(activity=discord.Game('Nova Terra'))
    
    print('Connected to bot: {}'.format(client.user.name))
    print('Bot ID: {}'.format(client.user.id))

@client.command(
	help="Uses come crazy logic to determine if pong is actually the correct value or not.",
	brief="Prints pong back to the channel."
)

async def ping(ctx):
    await ctx.send(f'Pong! {round(client.latency * 1000)}ms')

@client.command()
async def hello(ctx):
    await ctx.send(f'Hi!')

@client.command(
	help="Changes the nickname.",
	brief="The name says it all."
)
async def nick(ctx, member : discord.Member, args):

	await member.edit(nick=args)

	await ctx.send(f'Nickname changed.')
	
@client.command(
	help="Looks like you need some help, lol.",
	brief="Prints the list of values back to the channel."
)
async def print(ctx, *args):
	response = ""

	for arg in args:
		response = response + " " + arg

	await ctx.channel.send(response)

@client.command(
  help="Chooses between two options.",
  brief="Chooses between two options."
)
async def choose(ctx, a: str, b: str):
  list1 = [a, b]
  await ctx.send(random.choice(list1))

@client.command()
async def start_dungeon(ctx, member : discord.Member, a: str)
:if a == 1:
    await ctx.send(f'You enter a level 1 dungeon. There are 4 rooms. You enter the first room. Using your torch, you see {random.choice(list3)} spiders. You take out your sword and slash at a spider dealing {dmg1} damage! Its health decreases to {spiderhp - dmg1}.')

client.run('Token')
If you have an answer; please tell! Thanks!