0

i am trying to get it to print the line of code that the, print("command used, line") print(frameinfo.filename, frameinfo.lineno), is on but it prints the frameinfo = getframeinfo(currentframe()) instead. does anyone know how to fix this?

import discord
frameinfo = getframeinfo(currentframe())

@client.event
async def on_message(message):
   if message.author == client.user:
       return
   if message.content.startswith('~myid'):
       await message.channel.send(myid)
       print("command used, line")
       print(frameinfo.filename, frameinfo.lineno)
  • Hi, you might want to look a this question https://stackoverflow.com/questions/6810999/how-to-determine-file-function-and-line-number – Jack Lilhammers Mar 19 '21 at 10:52
  • 1
    Did you try making the `getframeinfo` call inside the function? Did you try reading the documentation for `getframeinfo` to understand how it works? Of course you will not get the frame info for the current frame if you try to use the "get frame info for the current frame" function *in advance, when you are not actually in that frame*. `frameinfo` *stores a result* - variables are not magic. – Karl Knechtel Mar 19 '21 at 10:52

0 Answers0