#๐Ÿ”’ how to make a different randon number every time?

22 messages ยท Page 1 of 1 (latest)

waxen plover
#

i'm making a beg command for a current system for my bot, but every time i run the $beg command, it always returns the same number

code:
begamt = random.randint(10, 300) @client.command() async def beg(ctx): await ctx.reply("" + str(ctx.author.mention) + " begged and received $" + str(begamt))

deft bearBOT
#

@waxen plover

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

modern topaz
waxen plover
#

alr lemme try tat

dusty steeple
#

also an fstring would look nicer here

modern topaz
#

yup

waxen plover
#

smth like this?

dusty steeple
waxen plover
#

srry im kinda new

dusty steeple
#

use fstring's ability to directly slot variables into it, like

#

!e

num = 10
print(f'I have a number: {num}')
deft bearBOT
#

@dusty steeple :white_check_mark: Your 3.12 eval job has completed with return code 0.

I have a number: 10
glossy haven
#

you didn't put the randint into the function there

frosty locust
#

inside your function... your function begins at the "async def" line.. so it needs to be after that, and indented

modern topaz
#

maybe, if you cannot use basic concepts lijke function, you should improve it before doing such elaborated things like discord bot

glossy haven
#
@client.command()
async def beg(ctx):
  begamt = random.randint(10, 300)
  await ctx.reply(f"{ctx.author.mention} begged and received ${begamt}")
waxen plover
#

ohhhhhh okay!

#

thank you :)

#

!close

deft bearBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.