reply to messages with images

This commit is contained in:
2026-03-31 19:39:22 +01:00
parent 9e4a3ffb16
commit 8a1f295591
3 changed files with 20 additions and 2 deletions

View File

@@ -117,7 +117,7 @@ namespace SkyBot.Commands
Height = height Height = height
}; };
await channel.SendMessageAsync(text, attachments: [attachment]); await MessageHelper.ReplyAsync(ctx, channel, text, [attachment]);
} }
} }
} }

View File

@@ -117,7 +117,7 @@ namespace SkyBot.Commands
Height = height Height = height
}; };
await channel.SendMessageAsync(text, attachments: [attachment]); await MessageHelper.ReplyAsync(ctx, channel, text, [attachment]);
} }
} }
} }

View File

@@ -29,6 +29,24 @@ namespace SkyBot.Helpers
return await ctx.Client.MessageService.SendMessage(msg); return await ctx.Client.MessageService.SendMessage(msg);
} }
public static async Task<TaskResult<Message>> ReplyAsync(CommandContext ctx, Channel channel, string content, List<MessageAttachment> attachments)
{
long? replyToId = ctx.Message.ReplyToId.HasValue ? ctx.Message.ReplyToId : ctx.Message.Id;
var msg = new Message(ctx.Client)
{
Content = content,
ChannelId = channel.Id,
PlanetId = ctx.Planet.Id,
AuthorUserId = ctx.Client.Me.Id,
AuthorMemberId = channel.Planet?.MyMember.Id,
ReplyToId = replyToId,
Fingerprint = Guid.NewGuid().ToString()
};
msg.SetAttachments(attachments);
return await ctx.Client.MessageService.SendMessage(msg);
}
public static async Task<TaskResult<Message>> EditAsync(Channel channel, Message message, string content) public static async Task<TaskResult<Message>> EditAsync(Channel channel, Message message, string content)
{ {
message.Content = content; message.Content = content;