Anonyo Noor
Anonyo Noor

Reputation: 553

How do I send every message in discord.py

So basically I want to recreate every discord channel in the console

import discord
from discord.ext import commands

b = commands.Bot(command_prefix = ".")
b.remove_command("help")

@b.event
async def on_message():
    print("What ever message the user sent")

b.run('token')

Every time a user sends a message, the message will be copied to the console. Is this possible? Also, is it possible to see what user sent it and what channel it is in? I know you can get channel and author IDs, but what about channel names and usernames?

Upvotes: 0

Views: 45

Answers (1)

@b.event
async def on_message(message):
    await b.process_commands(message)
    print(f"{message.author} in {message.channel} : {message.content}")

That should give you the message with the sender and where the message came from.

Upvotes: 1

Related Questions