C
C
cataclysm882021-06-16 07:39:15
Python
cataclysm88, 2021-06-16 07:39:15

How to return the server name in a private message of a discord bot?

There is this code:

if message.content.startswith('$info'):
        await message.author.send('Ты находишься на сервере {message.server.name}!')

Those. when we write $info in a chat, this code should send the name of the server in a private message, but {message.server.name} is sent.
What is my mistake and how to fix it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kentavr16, 2021-06-16
@Kentavr16

Google "python string interpolation". enjoy)

A
Alan Gibizov, 2021-06-16
@phaggi

Try like this:

message.author.send(f'Ты находишься на сервере {message.server.name}!')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question