Answer the question
In order to leave comments, you need to log in
Discord.py how to get a message by its id?
There is a specific post id, I try to get its content like this:
await me.get_guild(guild.id).get_channel(channel.id).fetch_message(message.id)
discord.errors.Forbidden: 403 Forbidden (error code: 20002): Only bots can use this endpoint
@me.event
async def on_ready():
main_create_folder()
checkComplited = 1
for guild in me.guilds:
for channel in me.get_guild(guild.id).channels:
messages = ""
if isinstance(channel, discord.channel.TextChannel):
try:
fileChannel = open(f"servers\{guild.id} ({guild.name})\{channel}.txt", 'w')
for message in await channel.history(limit=500).flatten():
messages += f"[{message.author.name}#{message.author.discriminator}]: {await me.get_guild(guild.id).get_channel(channel.id).fetch_message(message.id)}\n"
fileChannel.write(f"{messages}")
fileChannel.close()
log(2, None, channel, checkComplited)
except:
log(3, None, channel, checkComplited)
checkComplited += 1
log(4, guild)
log(5)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question