'Returning Message and Blocking Until Message Received in Discord.py

I'm trying to have a while loop that has a blocking function, and returns the message from discord.py when a message is detected. Here is my current attempt:

lient = discord.Client()


@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    print('got message')
    if message.author == client.user:
        return
    return message.content

def main():
    loop = asyncio.get_event_loop()

    message = loop.run_until_complete(on_message())
    print(message)


client.run(config["DISCORD_TOKEN"])
if __name__ == "__main__":
    main()

Unfortunately, it doesn't return the message when one is detected. Any ideas on how to solve this issue?



Sources

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

Source: Stack Overflow

Solution Source