'AttributeError: 'TeleBot' object has no attribute 'chat'

I want to create a variable, message.chat.id outside of function for example like this

bot = telebot.teleBot("token")
global message
message = bot.message.chat.id

@bot.message_handler(commands=["start"])
def welcome():
    bot.send_message(message,"Welcome on here, pls describe yourself")

but the telebot attributes error does the message argument always have to be inside the function, it can't be outside the function to become a variable?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source