#Need help with message_command to copy message ATTACHMENTS and post them in another log channel.

1 messages · Page 1 of 1 (latest)

white peak
#

Having problems. Been at it for hours, probably right at my fingertips

#

Current Code:

@client.message_command(name="Post RoE Violation")
async def postroe(
  ctx: discord.ApplicationContext, message: discord.Message
  ):
  guild = client.guilds[0]
  postchan = client.get_channel(1030092694199992410)
  await postchan.send(f'Incoming ROE Violation posted by {message.author.nick}.')
  await postchan.send(message.attachments)
  await ctx.respond('Roe Violation Posted')

And All I get is this:

Incoming ROE Violation posted by [KSF] TheNeonExplorer.
[<Attachment id=1029584173024935996 filename='Screenshot_20221011-223254_Star_Trek_Fleet_Command.jpg' url='https://cdn.discordapp.com/attachments/1014344547679092816/1029584173024935996/Screenshot_20221011-223254_Star_Trek_Fleet_Command.jpg%27%3E]
#

I want the picture to be exactly as it was posted in a separate read-only channel that only the bot can post in ( as well as admins/mods, obviously )

vague escarp
#

Attachment has a read method you can use to download it then turn it into a discord.File.

#

even better just use to_file

white peak
#

The samples are terrible. 😦

I tried, but maybe I'm not doing it right. . .

#

'Dont mind the comments, I had to comment it all out to avoid the bot crashing and not even starting. . .`

#
@client.message_command(name="Post RoE Violation")
async def postroe(
  ctx: discord.ApplicationContext, message: discord.Message
  ):
  guild = client.guilds[0]
  postchan = client.get_channel(1030092694199992410)
  await postchan.send(f'Incoming ROE Violation posted by {message.author.nick}.')
  print('Converting to File.')
  #files = await message.attachments.to_file(*, use_cached=False)
  #await postchan.send(file=files)
  #await ctx.respond('Roe Violation Posted')
half dock
#

and i don't think you should await it you should

#

use attachments[0] to get first member of a list

#

or loop through it

white peak
half dock
mortal harbor
lofty kelpBOT