S
S
Sergey Matkovsky2020-06-15 05:12:39
Python
Sergey Matkovsky, 2020-06-15 05:12:39

Discord.py how to make a bot so that I can send messages to a specific channel?

Is it possible to do something so that I can send messages from the console to the discord on behalf of the bot. Or rather, is it possible to somehow display msg as a message from the bot? If there are other ways, please explain in detail. Thanks in advance!
msg = input('Ваше сообщение')

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
shurshur, 2020-06-16
@anitop

discord.py is an asynchronous framework. You can’t just make synchronous code in it that waits for something. To read stdin, you need to work with it correctly through asyncio.
There are many examples on the Internet, and I also found such a module: https://github.com/vxgmichel/aioconsole

V
Vladislav Mukhin, 2021-03-17
@SladkayaDoza

Hey, send a message to a specific channel, it's easy))
and of course you need to read the documentation))
code example:

@Client.event
async def on_ready():
    while True:
        try:
            channel = await Client.fetch_channel(input("id Канала: "))
            await channel.send(content=input("Ваше сообщение: ")
        except Exception:
            print("Не хватает прав")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question