TTV jokzyz
TTV jokzyz

Reputation: 355

Concatenating from "int" to string in discord.py

I am trying to pull a site's status code by a discord command. First I define the request and such

r = requests.get('redactedsiteurl')
test = r.status_code

Then after going through and defining the command and all, I add the code to the embed

embed.description = '**Status Code:**' + r.status_code

This draws the following error:

Traceback (most recent call last):
  File "C:\Users\jokzc\AppData\Roaming\Python\Python38\site-packages\discord\client.py", line 312, in _run_event
    await coro(*args, **kwargs)
  File "test2.py", line 16, in on_message
    embed.description = '**Status Code:**' + r.status_code
TypeError: can only concatenate str (not "int") to str

Is there another method that would do what i want without concatenation? Thanks :)

Upvotes: 2

Views: 501

Answers (1)

ruohola
ruohola

Reputation: 24107

You can use f-strings:

embed.description = f'**Status Code:**{r.status_code}'

Upvotes: 1

Related Questions