#Making a simple math

1 messages · Page 1 of 1 (latest)

viscid trellis
#

so uhm

#

your answer is already an int

#

why would it not be

#

protip you can see the types of variables if you hover over them in most editors

#

your issue boils down to this

#

content is a str

#

answer is an int

slow violet
#

so I compile answer to str by str(answer)

viscid trellis
#

you convert it

#

compiling is a completely seperate thing you don't even really do in python :P

#

but yes, your idea is correct

slow violet
#

Bot still not say "Congratulations" 2982pepecry

#

by the way how can I handle the timeout (if no right answer on time)

slow violet
viscid trellis
#

I guess it werks

#

although I think you have to be the first person in history to use else in try except

slow violet
#

the timeout is now work but the answer is still not working catok

viscid trellis
#

I just slapped it in my bot

#

it werks

#

sooo

#

do you have message content intent?

#

can your bot see the channel?

viscid trellis
slow violet
viscid trellis
#

indeed

#

so the remaining problem is the message content intent

#

./tag msgcnt

random etherBOT
#

Why is some information about my messages from MessageCreateEvent unavailable?

You may have not enabled the Message Content Intent. This had been a thing for bots from August 31st, 2022 onward. For more info, refer to https://support-dev.discord.com/hc/en-us/articles/4404772028055

Firstly, go to your discord developer portal. In your bot application, in the bot section, tick this to be on. (check the attached screenshot: https://i.imgur.com/8Ps9Boi.png)
Secondly, in your bot's code, add the highlighted lines:

bot = hikari.GatewayBot( # or lightbulb.BotApp
    "your token",
    intents=hikari.Intents.ALL_UNPRIVILEGED | hikari.Intents.MESSAGE_CONTENT # Add this line
)

You should now receive all information about such messages. :)

Note: You will still receive this information for messages in which the bot is pinged and for any message in DMs, regardless of the intent.

slow violet
viscid trellis
#

well not using bare except is p straightforward

#

it is a bad practice because it handles all errors, not just the ones you want to handle

#

which may lead to errors being unintentionally eaten

slow violet
viscid trellis
#

if you imported asyncio, I guess

slow violet
#

and how to avoid "x" is possibly unbound

#

same as "answer" is possibly unbound

viscid trellis
#

:P

#

make it not possibly be unbound

slow violet
#

can you do an example please

viscid trellis
#
if foo > bar:
  x = 5

# x is possibly unbound if foo > bar
print(x)
slow violet
#

erm, by the way

view = miru.View()
view.add_item(miru.text_select(
  placeholder="Choose a number",
  options=[miru.SelectOption(label="One",value="1")]
 ))

await ctx.respond(components=view.build())```
do you know why is this not work?
viscid trellis
#

there's like 1 bazillion reasons

#

I recommend you read the miru docs

#

and not use outdated tutorials

#

also please stop pinging me every single time