#text length

1 messages · Page 1 of 1 (latest)

sonic wolf
#

I'm new to this topic, but I did when the ball and I had a question that was with 1000 characters

#

screen

harsh imp
#

len()

sonic wolf
#

With len()

#

There was a question "im bob?" but sends numbers. I do not understand something?

#

Did I do it right?

harsh imp
#

len(message) will give you the number of characters, including whitepsaces, in the string

sonic wolf
#

This is understandable, but how can I get my question instead of numbers?

harsh imp
#

huh?

#

Probably message

sonic wolf
#

This cogs, you said to use len(), did I use it correctly? It's just that if yes, then I get numbers instead of a message and it doesn't matter how many messages I had

harsh imp
#

because you're sending the length of the message in your embed response.

sonic wolf
#

and how to make it so that there is a message text instead, I can’t understand this

harsh imp
#

remove the len()

#

I highly suggest you stop what you're trying to do and go learn some python.

sonic wolf
harsh imp
#

It's a user error. See previously linked solution to resolve.

sonic wolf
#

okay

#

thank

harsh imp
#

I highly suggest you actually do go read through that wiki and do some of those courses, however, the issue is mostly you not clearly explaining what you're after.

#

You asked for the "text length" then you're asking why it's now showing the length of the text instead of the text itself. This is confusing. Could you clearly state what it is you're trying to do?

sonic wolf
#

hmm..

harsh imp
#

Could you provide a better explanation of the issue?

sonic wolf
#

look, I need to make sure that the text is limited so that you can send not a large number of messages, but for example the answer to the ball "The weather is great?" , this is what is needed so that it is not just a flood, but a question

#

it's easier? I just don't know how to explain it

#

As I understand it, there is no answer to this question, if this bot has this then it will also be present in mine and this cannot be changed

#

ok, thanks for the help, topic closed

harsh imp
#

Then you need to check the length of the message.

something like:

if len(message) > 100:  
    # this block is executed if the length of the
    # message exceeds 100 characters
    return # some error message or something 

 embed = disnake.Ember(description = message)
sonic wolf
#

I understand it worked, but how to notify a person who writes more than 100 messages that the maximum is 100?

#

just when I write more than 100 messages sends me

harsh imp
#

you need to respond if the len does exceed 100 characters

#
# trim any added whitespace at the end of the message
# "Hi, I'm DLCHAMP " becomes "Hi, I'm DLCHAMP"
message = message.strip() 

if len(message) > 100:
    return await inter.response.send_message('Messages cannot exceed 100 characters', ephemeral=True)

# message is good length, execute rest of code
sonic wolf
#

good

#

only because of "message = message.trim()" gave an error, removed it and everything worked, thanks

harsh imp
#

it's strip() not trim() I'm working on something in excel and my brain mixed them up

sonic wolf
#

ah, okay

#

thank

#

good bay

harsh imp
#

Please use /solved if this has been solved.