0
votes

my code is this but output is terrible

import os
import discord
import asyncio
from discord.ext import tasks, commands
client = discord.Client()


@client.event
async def on_ready():
 print(f'Connected to Discord!')
 channel = client.get_channel(231231321213)
 messages = await channel.history(limit=1).flatten()
 print(messages)
 
 


client.run('token', bot=False)

My Output:

Connected to Discord! [<Message id=826111938424864848 channel= type=<MessageType.default: 0> author= flags=>] Traceback (most recent call last):

File "C:\Users\cinar\untitled0.py", line 18, in client.run('Bot Token', bot=False)

File "D:\Users\cinar\anaconda3\lib\site-packages\discord\client.py", line 714, in run _cleanup_loop(loop)

File "D:\Users\cinar\anaconda3\lib\site-packages\discord\client.py", line 95, in _cleanup_loop loop.close()

File "D:\Users\cinar\anaconda3\lib\asyncio\selector_events.py", line 89, in close raise RuntimeError("Cannot close a running event loop")

RuntimeError: Cannot close a running event loop

1
what do you mean by "the output is horrible"? What's the result? What's the expected result? Takea look at how to askŁukasz Kwieciński
Yes ı mean output ı edited my messageWicauv
I looked at the docs and I find out history() yielding Message not string, maybe try message.content? Also, I just realize, why do you need bot = False? Like, are you trying to self bot?hard lander
yes ı am trying to make selfbot. how can ı use message.content to get last messages string?Wicauv

1 Answers

0
votes

I think you are trying to do self bot with an actual bot token, I'm not gonna recommend continuing this as self botting is against ToS. But if you really want to do it anyway, use your email and password instead of a bot token. I'm gonna warn you once again that self botting is against ToS and might get your account banned, so do this at your own risk. Anyway someone already asked how to log in as a user here.

Also as I said in the comment earlier, I looked into discord.py docs and found out history() is yielding message. So maybe you should try to do print(message[0].content) instead.