Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Discord Bot
#1
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!
Larz60+ write Jun-03-2021, 04:10 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Creating Discord Bot: Unused import statement 'import discord EyeballCandy 0 3,564 Feb-02-2020, 10:53 PM
Last Post: EyeballCandy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020