Sasoon
Sasoon

Reputation: 11

Copy discord messages into minecraft chat

I want to make a bot that copies messages from a discord server and then pastes them into the Minecraft chat. I'm not talking about rcon.

I copied some code that takes the last message and puts it in a text file:

async def copy(ctx):
    with open("file.txt", "w") as f:
        async for message in ctx.history(limit=1000):
            f.write(message.content + "\n")

But I can't find this text file. I've tried putting it in the same folder with main.py and replacing "file.txt" with a full path to the file but it still won't work.

If I manage to get this whole "copy message into txt/variable" thing I should be able to finish the "paste stuff into chat" thing.

Please help me I'm stupid.

Upvotes: 1

Views: 117

Answers (1)

Mike O.
Mike O.

Reputation: 47

Not Python-specific, although you can try AutoHotkey for this (assuming you are dealing with 2 different apps consuming 2 different windows). AutoIt is also a solid alternative for this. Both are Windows specific and if you are using some other operating system, then good luck finding a proper macro recorder.

If you only need to output the text to a file, Selenium might be a better solution, given the plethora of options, as Discord can be opened in a browser too.

For a pure Python solution, you might look into PyWinAuto (again, Windows-specific).

Upvotes: 1

Related Questions